From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, linux-kernel@vger.kernel.org,
juri.lelli@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
kprateek.nayak@amd.com, joshdon@google.com, tj@kernel.org,
jakub@okonski.org
Subject: Re: [PATCH 1/3] sched/fair: Use guard in sched_group_set_idle()
Date: Thu, 5 Nov 2026 20:42:24 +0300 [thread overview]
Message-ID: <auy-i8DDjDRWEnNu@scheduler.schedules> (raw)
In-Reply-To: <20261105170157.453569788@infradead.org>
Hi Peter,
On Thu, Nov 05, 2026 at 05:55:26PM +0100, Peter Zijlstra wrote:
> Cleanup the code by using guards; prepares for further changes in this function.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/sched/fair.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -15790,12 +15790,9 @@ int sched_group_set_idle(struct task_gro
> if (idle < 0 || idle > 1)
> return -EINVAL;
>
> - mutex_lock(&shares_mutex);
> -
> - if (tg->idle == idle) {
> - mutex_unlock(&shares_mutex);
> + guard(mutex)(&shares_mutex);
> + if (tg->idle == idle)
> return 0;
> - }
>
> tg->idle = idle;
>
> @@ -15805,13 +15802,12 @@ int sched_group_set_idle(struct task_gro
> struct cfs_rq *grp_cfs_rq = tg_cfs_rq(tg, i);
> bool was_idle = cfs_rq_is_idle(grp_cfs_rq);
> long idle_task_delta;
> - struct rq_flags rf;
>
> - rq_lock_irqsave(rq, &rf);
> + guard(rq_lock_irqsave)(rq);
>
> grp_cfs_rq->idle = idle;
> if (WARN_ON_ONCE(was_idle == cfs_rq_is_idle(grp_cfs_rq)))
> - goto next_cpu;
> + continue;
>
> idle_task_delta = grp_cfs_rq->h_nr_queued -
> grp_cfs_rq->h_nr_idle;
> @@ -15830,9 +15826,6 @@ int sched_group_set_idle(struct task_gro
> if (cfs_rq_is_idle(cfs_rq))
> break;
> }
> -
> -next_cpu:
> - rq_unlock_irqrestore(rq, &rf);
> }
>
> /* Idle groups have minimum weight. */
> @@ -15841,7 +15834,6 @@ int sched_group_set_idle(struct task_gro
> else
> __sched_group_set_shares(tg, NICE_0_LOAD);
>
> - mutex_unlock(&shares_mutex);
> return 0;
> }
>
>
>
LGTM.
Reviewed-by: Kayra Cizmeci <kayracizmeci@gmail.com>
Cheers,
Kayra
next prev parent reply other threads:[~2026-11-05 17:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 16:55 [PATCH 0/3] sched/fair: Fix cgroup::idle preemption Peter Zijlstra
2026-11-05 16:55 ` [PATCH 1/3] sched/fair: Use guard in sched_group_set_idle() Peter Zijlstra
2026-11-05 17:42 ` Kayra Cizmeci [this message]
2026-11-05 16:55 ` [PATCH 2/3] sched/fair: Make cfs_rq::idle the sum of ancestor tg::idle Peter Zijlstra
2026-11-05 19:20 ` Kayra Cizmeci
2026-11-05 16:55 ` [RFC][PATCH 3/3] sched/eevdf: Fix sched idle task group preemption Peter Zijlstra
2026-11-05 20:10 ` Kayra Cizmeci
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=auy-i8DDjDRWEnNu@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jakub@okonski.org \
--cc=joshdon@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®