From: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
To: Abel Wu <wuyun.abel@bytedance.com>
Cc: "open list:SCHEDULER" <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Josh Don <joshdon@google.com>,
Tianchen Ding <dtcccc@linux.alibaba.com>,
Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Subject: Re: [PATCH 1/2] sched/fair: Do not let idle entities preempt others
Date: Sat, 22 Feb 2025 22:42:48 +0530 [thread overview]
Message-ID: <e8451617-a0f8-4650-9347-a2c46aa3898b@linux.ibm.com> (raw)
In-Reply-To: <20250221111226.64455-2-wuyun.abel@bytedance.com>
Hi Abel,
On 21/02/25 16:42, Abel Wu wrote:
> A task with SCHED_IDLE policy doesn't preempt others by definition, and
> the semantics are intended to be preserved when extending to cgroups
> introduced in commit 304000390f88 ("sched: Cgroup SCHED_IDLE support").
>
> But current implementation allows idle entities to preempt each other
> on wakeup, which seems not behave as expected especially after
> commit faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
> so fix this by explicitly skip wakeup preemption for idle entities.
>
> Fixes: 304000390f88 ("sched: Cgroup SCHED_IDLE support")
> Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
> ---
> kernel/sched/fair.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 1c0ef435a7aa..4340178f29b7 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8778,12 +8778,15 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
> pse_is_idle = se_is_idle(pse);
>
> /*
> - * Preempt an idle entity in favor of a non-idle entity (and don't preempt
> - * in the inverse case).
> + * Preempt an idle entity in favor of a non-idle entity.
> */
> if (cse_is_idle && !pse_is_idle)
> goto preempt;
> - if (cse_is_idle != pse_is_idle)
> +
> + /*
> + * IDLE entities do not preempt others.
> + */
> + if (unlikely(pse_is_idle))
> return;
It makes sense that idle tasks don't preempt each other. The patch
preserves the original behavior: preemption occurs when the currently
running entity (cse) is SCHED_IDLE while the waking entity (pse) is not,
and it correctly returns when cse is not SCHED_IDLE while pse is
SCHED_IDLE.
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Thanks,
Madadi Vineeth Reddy
>
> /*
next prev parent reply other threads:[~2025-02-22 17:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 11:12 [PATCH 0/2] Fix SCHED_IDLE behavior on wakeup preemption Abel Wu
2025-02-21 11:12 ` [PATCH 1/2] sched/fair: Do not let idle entities preempt others Abel Wu
2025-02-21 11:48 ` Vincent Guittot
2025-02-21 19:54 ` Josh Don
2025-02-22 17:12 ` Madadi Vineeth Reddy [this message]
2025-02-22 17:48 ` Madadi Vineeth Reddy
2025-02-23 8:45 ` Abel Wu
2025-02-21 11:12 ` [PATCH 2/2] sched/fair: Fix premature check of WAKEUP_PREEMPTION Abel Wu
2025-02-21 11:49 ` Vincent Guittot
2025-02-21 15:57 ` Abel Wu
2025-02-22 18:16 ` Madadi Vineeth Reddy
2025-02-23 8:44 ` Abel Wu
2025-02-23 10:25 ` Madadi Vineeth Reddy
2025-02-23 11:22 ` Abel Wu
2025-02-24 13:47 ` Vincent Guittot
2025-02-24 14:10 ` Phil Auld
2025-02-25 17:14 ` Vincent Guittot
2025-02-25 6:29 ` Abel Wu
2025-02-25 17:15 ` Vincent Guittot
2025-02-26 7:34 ` Abel Wu
2025-02-25 6:56 ` Tianchen Ding
2025-02-24 13:22 ` Vincent Guittot
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=e8451617-a0f8-4650-9347-a2c46aa3898b@linux.ibm.com \
--to=vineethr@linux.ibm.com \
--cc=20250221111226.64455-2-wuyun.abel@bytedance.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=dtcccc@linux.alibaba.com \
--cc=joshdon@google.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wuyun.abel@bytedance.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