From: Chengming Zhou <zhouchengming@bytedance.com>
To: Peter Zijlstra <peterz@infradead.org>,
Chengming Zhou <zhouchengming@bytedance.com>
Cc: mingo@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, vschneid@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [External] Re: [PATCH 3/8] sched/fair: remove redundant cpu_cgrp_subsys->fork()
Date: Tue, 12 Jul 2022 00:25:05 +0800 [thread overview]
Message-ID: <e93b5c38-0291-d6e4-811a-9aed3d6e0f87@linux.dev> (raw)
In-Reply-To: <YswrSi46s+XLD18R@hirez.programming.kicks-ass.net>
On 2022/7/11 21:53, Peter Zijlstra wrote:
> On Mon, Jul 11, 2022 at 09:02:07PM +0800, Chengming Zhou wrote:
>> On 2022/7/11 15:35, Peter Zijlstra wrote:
>>> On Sat, Jul 09, 2022 at 11:13:48PM +0800, Chengming Zhou wrote:
>>>> We use cpu_cgrp_subsys->fork() to set task group for the new fair task
>>>> in cgroup_post_fork().
>>>>
>>>> Since commit b1e8206582f9 ("sched: Fix yet more sched_fork() races")
>>>> has already set task group for the new fair task in sched_cgroup_fork(),
>>>> so cpu_cgrp_subsys->fork() can be removed.
>>>>
>>>> cgroup_can_fork() --> pin parent's sched_task_group
>>>> sched_cgroup_fork()
>>>> __set_task_cpu --> set task group
>>>> cgroup_post_fork()
>>>> ss->fork() := cpu_cgroup_fork() --> set again
>>>>
>>>> After this patch's change, task_change_group_fair() only need to
>>>> care about task cgroup migration, make the code much simplier.
>>>
>>> This:
>>>
>>>> This patch also move the task se depth setting to set_task_rq(), which
>>>> will set correct depth for the new task se in sched_cgroup_fork().
>>>>
>>>> The se depth setting in attach_entity_cfs_rq() is removed since
>>>> set_task_rq() is a better place to do this when task moves across
>>>> CPUs/groups.
>>>
>>> really should have been it's own patch. And this actually scares me. Did
>>> you test with priority inheritance bumping the task to FIFO while things
>>> change?
>>>
>>> This has nothing to do with fork().
>>
>> Ok, will put this in another patch, so this patch still need this line:
>>
>> p->se.depth = tg->se[cpu] ? tg->se[cpu]->depth + 1 : 0;
>>
>> in set_task_rq() to set depth for new forked task.
>
> That would suggest you ordered your patches wrong.
Yeah, I understand now, should put this se depth change before..
>
>> I didn't test with "priority inheritance bumping the task to FIFO" case,
>> do you mean the rt_mutex_setprio() bump a fair task to FIFO?
>>
>> Sorry, I don't get how removing depth setting in attach_entity_cfs_rq()
>> affect that. Could you explain more so I can test it?
>
> Well, if you look at the commit that introduced that code:
>
> eb7a59b2c888 ("sched/fair: Reset se-depth when task switched to FAIR")
>
> then it's clear that the original problem was the task temporarily not
> being in the fair class. The most common way for that to be so is
> through PI.
Thanks for the hint, I read that commit, should be no problem if we have
se depth setting in set_task_rq().
That problem was we only maintain task se depth in task_move_group_fair(),
if a !fair task move task group, its se depth will not be updated, so
that commit fix the problem by update se depth in switched_to_fair().
In this patch we maintain se depth setting in set_task_rq(), which will be
called when CPU/cgroup change, so its depth will always be correct. So it's
ok to remove task se depth setting in attach_entity_cfs_rq().
Thanks.
>
next prev parent reply other threads:[~2022-07-11 16:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-09 15:13 [PATCH 0/8] sched: task load tracking optimization and cleanup Chengming Zhou
2022-07-09 15:13 ` [PATCH 1/8] sched/fair: combine detach into dequeue when migrating task Chengming Zhou
2022-07-11 13:07 ` Chengming Zhou
2022-07-09 15:13 ` [PATCH 2/8] sched/fair: update comments in enqueue/dequeue_entity() Chengming Zhou
2022-07-09 15:13 ` [PATCH 3/8] sched/fair: remove redundant cpu_cgrp_subsys->fork() Chengming Zhou
2022-07-11 7:35 ` Peter Zijlstra
2022-07-11 13:02 ` [External] " Chengming Zhou
2022-07-11 13:53 ` Peter Zijlstra
2022-07-11 16:25 ` Chengming Zhou [this message]
2022-07-09 15:13 ` [PATCH 4/8] sched/fair: reset sched_avg last_update_time before set_task_rq() Chengming Zhou
2022-07-09 15:13 ` [PATCH 5/8] sched/fair: fix load tracking for new forked !fair task Chengming Zhou
2022-07-09 15:13 ` [PATCH 6/8] sched/fair: stop load tracking when task switched_from_fair() Chengming Zhou
2022-07-09 15:13 ` [PATCH 7/8] sched/fair: delete superfluous set_task_rq_fair() Chengming Zhou
2022-07-09 15:13 ` [PATCH 8/8] sched/fair: delete superfluous SKIP_AGE_LOAD Chengming Zhou
2022-07-11 16:54 ` Chengming Zhou
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=e93b5c38-0291-d6e4-811a-9aed3d6e0f87@linux.dev \
--to=zhouchengming@bytedance.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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.