All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Zefan Li <lizefan@huawei.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Mike Galbraith <umgwanakikbuti@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Stefan Bader <stefan.bader@canonical.com>
Subject: Re: [PATCH] sched, autogroup: Fix failure when writing to cpu.rt_runtime_us
Date: Mon, 9 Feb 2015 12:27:15 +0100	[thread overview]
Message-ID: <20150209112715.GO24151@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20150209112237.GR5029@twins.programming.kicks-ass.net>

On Mon, Feb 09, 2015 at 12:22:37PM +0100, Peter Zijlstra wrote:
> Indeed, setting runtime=0 for the root group is a very bad thing
> regardless of this patch. It would disallow the kernel from creating RT
> threads, which it needs for 'correct' operation in a number of cases.
> 
> But lets make that a separate patch.

---
Subject: sched,rt: Avoid obvious configuration fail
From: Peter Zijlstra <peterz@infradead.org>
Date: Mon Feb  9 12:23:20 CET 2015

Setting the root group's cpu.rt_runtime_us to 0 is a bad thing; it
would disallow the kernel creating RT tasks.

One can of course still set it to 1, which will (likely) still wreck
your kernel, but at least make it clear that setting it to 0 is not
good.

Collect both sanity checks into the one place while we're there.

Suggested-by: Zefan Li <lizefan@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/sched/core.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7742,6 +7742,17 @@ static int tg_set_rt_bandwidth(struct ta
 {
 	int i, err = 0;
 
+	/*
+	 * Disallowing the root group RT runtime is BAD, it would disallow the
+	 * kernel creating (and or operating) RT threads.
+	 */
+	if (tg == &root_task_group && rt_runtime == 0)
+		return -EINVAL;
+
+	/* No period doesn't make any sense. */
+	if (rt_period == 0)
+		return -EINVAL;
+
 	mutex_lock(&rt_constraints_mutex);
 	read_lock(&tasklist_lock);
 	err = __rt_schedulable(tg, rt_period, rt_runtime);
@@ -7798,9 +7809,6 @@ static int sched_group_set_rt_period(str
 	rt_period = (u64)rt_period_us * NSEC_PER_USEC;
 	rt_runtime = tg->rt_bandwidth.rt_runtime;
 
-	if (rt_period == 0)
-		return -EINVAL;
-
 	return tg_set_rt_bandwidth(tg, rt_period, rt_runtime);
 }
 

  reply	other threads:[~2015-02-09 11:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05  8:33 [PATCH] sched, autogroup: Fix failure when writing to cpu.rt_runtime_us Zefan Li
2015-02-05 14:25 ` Peter Zijlstra
2015-02-06  1:30   ` Zefan Li
2015-02-06 10:58     ` Peter Zijlstra
2015-02-07  7:02       ` Zefan Li
2015-02-09 11:22         ` Peter Zijlstra
2015-02-09 11:27           ` Peter Zijlstra [this message]
2015-02-18 17:09             ` [tip:sched/core] sched/rt: Avoid obvious configuration fail tip-bot for Peter Zijlstra
2015-02-10  1:26           ` [PATCH] sched, autogroup: Fix failure when writing to cpu.rt_runtime_us Zefan Li
2015-02-18 17:09           ` [tip:sched/core] sched/autogroup: Fix failure to set cpu.rt_runtime_us tip-bot for Peter Zijlstra

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=20150209112715.GO24151@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@kernel.org \
    --cc=stefan.bader@canonical.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.