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: Fri, 6 Feb 2015 11:58:40 +0100 [thread overview]
Message-ID: <20150206105840.GJ23123@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <54D4194B.2040808@huawei.com>
On Fri, Feb 06, 2015 at 09:30:51AM +0800, Zefan Li wrote:
> After running the test program, we have:
>
> root
> |
> autogroup <-- the RT test program is now here
>
> root.rt_runtime = 950000
> autogroup.rt_runtime = 0
>
> Now if you try to change the rt_runtime of the root cgroup, it returns
> -EBUSY.
>
> That comes from:
>
> static int tg_rt_schedulable(struct task_group *tg, void *data)
> (
> ...
> if (rt_bandwidth_enabled() && !runtime && tg_has_rt_tasks(tg))
> return -EBUSY;
> ...
> }
>
> static inline int tg_has_rt_tasks(struct task_group *tg)
> {
> struct task_struct *g, *p;
>
> for_each_process_thread(g, p) {
> if (rt_task(p) && task_group(p) == tg)
> return 1;
> }
>
> return 0;
> }
>
> here tg == autogroup, p == the test program, and task_group(p)
> returns autogroup, which is wrong.
No its not.
> See this commit:
>
> commit f44937718ce3b8360f72f6c68c9481712517a867
> Author: Mike Galbraith <efault@gmx.de>
> Date: Thu Jan 13 04:54:50 2011 +0100
>
> sched, autogroup: Fix CONFIG_RT_GROUP_SCHED sched_setscheduler() failure
> ...
> + /*
> + * Autogroup RT tasks are redirected to the root task group
> ...
> + * the policy change to proceed. Thereafter, task_group()
> + * returns &root_task_group, ...
> + */
That comment is misleading; if you look at the actual code what we do is
redirect RT programs to _run_ in the root_task_group, but their
task_group() should still be autogroup.
Otherwise people could escape their cgroup by switching to and from a RT
class.
So what I think you want is something like the below; preferably with a
comment on ;-)
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1f37fe7f77a4..f4fd048ce7cf 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7644,6 +7644,9 @@ static inline int tg_has_rt_tasks(struct task_group *tg)
{
struct task_struct *g, *p;
+ if (task_group_is_autogroup(tg))
+ return 0;
+
for_each_process_thread(g, p) {
if (rt_task(p) && task_group(p) == tg)
return 1;
next prev parent reply other threads:[~2015-02-06 10:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 8:33 Zefan Li
2015-02-05 14:25 ` Peter Zijlstra
2015-02-06 1:30 ` Zefan Li
2015-02-06 10:58 ` Peter Zijlstra [this message]
2015-02-07 7:02 ` Zefan Li
2015-02-09 11:22 ` Peter Zijlstra
2015-02-09 11:27 ` Peter Zijlstra
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=20150206105840.GJ23123@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome