From: Peter Zijlstra <peterz@infradead.org>
To: Brian Silverman <brian@peloton-tech.com>
Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
bigeasy@linutronix.de, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Mike Galbraith <umgwanakikbuti@gmail.com>
Subject: Re: [PATCH] Force processes to non-realtime before mm_exit
Date: Thu, 14 Jul 2016 19:24:29 +0200 [thread overview]
Message-ID: <20160714172429.GH30935@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1464995924-16367-1-git-send-email-brian@peloton-tech.com>
On Fri, Jun 03, 2016 at 04:18:44PM -0700, Brian Silverman wrote:
> Without this, a realtime process which has called mlockall exiting
> causes large latencies for other realtime processes at the same or
> lower priorities. This seems like a fairly common use case too, because
> realtime processes generally want their memory locked into RAM.
So I'm not too sure.. SCHED_FIFO/RR are a complete trainwreck and
provide absolutely no isolation from badly behaving tasks what so ever,
so I'm not too inclined to protect them from exit either, its just one
more way in which they can cause pain.
But aside from the, the patch has issues..
> +++ b/kernel/exit.c
> @@ -730,6 +730,12 @@ void do_exit(long code)
> tsk->exit_code = code;
> taskstats_exit(tsk, group_dead);
>
> + if (tsk->policy == SCHED_FIFO || tsk->policy == SCHED_RR) {
> + struct sched_param param = { .sched_priority = 0 };
> +
> + sched_setscheduler_nocheck(current, SCHED_NORMAL, ¶m);
> + }
> +
> exit_mm(tsk);
That only does half a job. You forget about SCHED_DEADLINE and negative
nice tasks.
Something like the below perhaps... But yeah, unconvinced.
diff --git a/kernel/exit.c b/kernel/exit.c
index 84ae830234f8..25da16bcfb9b 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -812,6 +812,13 @@ void do_exit(long code)
tsk->exit_code = code;
taskstats_exit(tsk, group_dead);
+ /*
+ * Drop all scheduler priority before exit_mm() as that
+ * can involve a lot of work and we don't want a dying
+ * task to interfere with healthy/running tasks.
+ */
+ sched_normalize_task(tsk);
+
exit_mm(tsk);
if (group_dead)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d7f5376cfaac..14e1945c62e8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7585,14 +7585,29 @@ void ___might_sleep(const char *file, int line, int preempt_offset)
EXPORT_SYMBOL(___might_sleep);
#endif
-#ifdef CONFIG_MAGIC_SYSRQ
-void normalize_rt_tasks(void)
+void sched_normalize_task(struct task_struct *p)
{
- struct task_struct *g, *p;
struct sched_attr attr = {
.sched_policy = SCHED_NORMAL,
};
+ if (!dl_task(p) && !rt_task(p)) {
+ /*
+ * Renice negative nice level tasks.
+ */
+ if (task_nice(p) < 0)
+ set_user_nice(p, 0);
+ return;
+ }
+
+ __sched_setscheduler(p, &attr, false, false);
+}
+
+#ifdef CONFIG_MAGIC_SYSRQ
+void normalize_rt_tasks(void)
+{
+ struct task_struct *g, *p;
+
read_lock(&tasklist_lock);
for_each_process_thread(g, p) {
/*
@@ -7608,21 +7623,10 @@ void normalize_rt_tasks(void)
p->se.statistics.block_start = 0;
#endif
- if (!dl_task(p) && !rt_task(p)) {
- /*
- * Renice negative nice level userspace
- * tasks back to 0:
- */
- if (task_nice(p) < 0)
- set_user_nice(p, 0);
- continue;
- }
-
- __sched_setscheduler(p, &attr, false, false);
+ sched_normalize_task(p);
}
read_unlock(&tasklist_lock);
}
-
#endif /* CONFIG_MAGIC_SYSRQ */
#if defined(CONFIG_IA64) || defined(CONFIG_KGDB_KDB)
next prev parent reply other threads:[~2016-07-14 17:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 23:18 Brian Silverman
2016-06-05 0:28 ` Corey Minyard
2016-07-14 17:24 ` Peter Zijlstra [this message]
2016-09-02 15:02 ` Thomas Gleixner
[not found] <1462903464-11448-1-git-send-email-brian@peloton-tech.com>
[not found] ` <20160512085946.GB19035@linutronix.de>
[not found] ` <CAGt3f4m=+yimx-wxDjH9TCzAb5F6zUbxG_RAEhTrT4cZWFKKcg@mail.gmail.com>
[not found] ` <20160525163323.GB18036@linutronix.de>
[not found] ` <CAGt3f4=SyBqM-7Jeitx10Tm8yTrNBpSoFNvCZNZX7A3oixzUzA@mail.gmail.com>
[not found] ` <574602F0.2070608@linutronix.de>
2016-06-03 23:33 ` Brian Silverman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160714172429.GH30935@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=brian@peloton-tech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=umgwanakikbuti@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome