From: sashiko-bot@kernel.org
To: "Vincent Guittot" <vincent.guittot@linaro.org>,
sched-ext@lists.linux.dev
Subject: Re: [PATCH 09/20 v3] sched/fair: Optimize push task mechanism for fair
Date: Fri, 06 Nov 2026 16:00:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-201755@kernel.org> (raw)
In-Reply-To: <20261106151947.3991524-10-vincent.guittot@linaro.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/fair: unpinned rq lock and double clock update in
fair_push_task()
--
commit 9e72e6e57764d3850fa10b1a2d1c221ab1149151
Author: Vincent Guittot <vincent.guittot@linaro.org>
sched/fair: Optimize push task mechanism for fair
This commit replaces the runqueue unlock and task_rq_lock() sequence in
fair_push_task() with a raw_spin_trylock() on next_task->pi_lock and
open-coded task migration to new_rq.
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e37f8b55a2934..e2999d3f88e46 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10148,8 +10148,7 @@ static bool fair_push_task(struct rq *rq)
> {
> struct task_struct *next_task;
> int prev_cpu, new_cpu;
> - struct rq_flags rf;
> - struct rq *cur_rq;
> + struct rq *new_rq;
>
> next_task = pick_next_pushable_fair_task(rq);
> if (!next_task)
> @@ -10158,38 +10157,41 @@ static bool fair_push_task(struct rq *rq)
> if (is_migration_disabled(next_task))
> return true;
>
> - /* We might release rq lock */
> - get_task_struct(next_task);
> -
> prev_cpu = rq->cpu;
>
> /*
> - * We need to release rq lock and take both task and rq w/o
> - * triggering a deadlock.
> + * The safe lock ordering for task and rq is task 1st then rq but we
> + * already get the rq so just try to get task too. If task is already
> + * locked, it is waiting for the rq's lock and it is about to change
> + * task state so skipping the push sequence in order to speed up the
> + * release of the lock is the best choice.
> */
> - raw_spin_rq_unlock(rq);
> -
> - cur_rq = task_rq_lock(next_task, &rf);
> -
> - /* Task already migrated */
> - if (cur_rq->cpu != prev_cpu)
> - goto skip_push;
> + if (!raw_spin_trylock(&next_task->pi_lock))
> + return true;
>
> new_cpu = select_task_rq_fair(next_task, prev_cpu, 0);
>
> /* Task doesn't need to migrate */
> if (new_cpu == prev_cpu)
> - goto skip_push;
> + goto no_push;
> +
> + new_rq = cpu_rq(new_cpu);
>
> - update_rq_clock(cur_rq);
> - cur_rq = move_queued_task(cur_rq, &rf, next_task, new_cpu);
> + deactivate_task(rq, next_task, 0);
> + set_task_cpu(next_task, new_cpu);
> + raw_spin_rq_unlock(rq);
>
> -skip_push:
> - task_rq_unlock(cur_rq, next_task, &rf);
> + raw_spin_rq_lock(new_rq);
> + WARN_ON_ONCE(task_cpu(next_task) != new_cpu);
> + activate_task(new_rq, next_task, 0);
> + wakeup_preempt(new_rq, next_task, 0);
> + raw_spin_rq_unlock(new_rq);
>
> - /* Restore rq state */
> + /* Restore rq lock state */
> raw_spin_rq_lock(rq);
[Severity: Medium]
Does replacing move_queued_task() with open-coded locking and
deactivate_task(rq, next_task, 0) trigger double-clock-update warnings and
skip runqueue lock pinning?
fair_push_task() runs from __balance_callbacks() after the caller has
updated rq's clock (setting RQCF_UPDATED in rq->clock_update_flags) and
called rq_unpin_lock(), which leaves RQCF_UPDATED set. Calling
deactivate_task(rq, next_task, 0) without DEQUEUE_NOCLOCK calls
dequeue_task() -> update_rq_clock(rq) while RQCF_UPDATED is still set,
triggering WARN_ON_ONCE(rq->clock_update_flags & RQCF_UPDATED) under
WARN_DOUBLE_CLOCK and setting SCX_RQ_CLK_VALID after rq_unpin_lock() has
already invalidated it.
On new_rq, using raw_spin_rq_lock() and raw_spin_rq_unlock() instead of
rq_lock()/rq_unlock() (or attach_one_task()) skips rq_pin_lock() and
rq_unpin_lock(). Because the previous lock holder on new_rq also left
RQCF_UPDATED set upon rq_unpin_lock(), activate_task() -> enqueue_task() ->
update_rq_clock(new_rq) triggers the same RQCF_UPDATED warning on new_rq,
bypasses lockdep pinning and assert_balance_callbacks_empty(), and leaves
SCX_RQ_CLK_VALID set after unlocking new_rq.
Passing DEQUEUE_NOCLOCK to deactivate_task() (since rq's clock was updated
before __balance_callbacks()) and using attach_one_task(new_rq, next_task)
would avoid both issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106151947.3991524-2-vincent.guittot@linaro.org?part=9
next prev parent reply other threads:[~2026-11-06 16:00 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 15:19 [PATCH 00/18 v3] Improving latency of short slice tasks Vincent Guittot
2026-11-06 15:19 ` [PATCH 01/20 v3] sched/eevdf: Decay positive lag of sleeping entities Vincent Guittot
2026-11-06 15:43 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 02/20 v3] sched/eevdf: Reset lag at wakeup when prev CPU has been idle Vincent Guittot
2026-11-06 16:22 ` Kayra Cizmeci
2026-11-09 15:27 ` Vincent Guittot
2026-11-09 15:45 ` Peter Zijlstra
2026-11-09 16:27 ` Vincent Guittot
2026-11-11 9:03 ` Peter Zijlstra
2026-11-12 7:02 ` Vincent Guittot
2026-11-11 10:04 ` K Prateek Nayak
2026-11-12 7:33 ` Vincent Guittot
2026-11-06 15:19 ` [PATCH 03/20 v3] sched/eevdf: Reset lag at wakeup when migrating and prev " Vincent Guittot
2026-11-06 18:05 ` Kayra Cizmeci
2026-11-06 15:19 ` [PATCH 04/20 v3] sched/eevdf: Reset lag when waking up on idle cpu Vincent Guittot
2026-11-06 18:39 ` Kayra Cizmeci
2026-11-06 15:19 ` [PATCH 05/20 v3] sched/eevdf: Add per cpu cached min_slice Vincent Guittot
2026-11-07 6:53 ` Kayra Cizmeci
2026-11-09 15:27 ` Vincent Guittot
2026-11-06 15:19 ` [PATCH 06/20 v3] sched/eevdf: Add min slice check when selecting CPU Vincent Guittot
2026-11-06 15:40 ` sashiko-bot
2026-11-07 8:57 ` Kayra Cizmeci
2026-11-09 13:55 ` Peter Zijlstra
2026-11-09 14:15 ` Kayra Cizmeci
2026-11-09 15:37 ` Vincent Guittot
2026-11-09 15:34 ` Vincent Guittot
2026-11-09 15:55 ` Vincent Guittot
2026-11-09 19:56 ` Kayra Cizmeci
2026-11-10 13:32 ` Vincent Guittot
2026-11-06 15:19 ` [PATCH 07/20 v3] sched/fair: Prepare select_task_rq_fair() to be called for new cases Vincent Guittot
2026-11-06 15:39 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 08/20 v3] sched/fair: Add push task mechanism for fair Vincent Guittot
2026-11-06 16:15 ` sashiko-bot
2026-11-09 14:43 ` Peter Zijlstra
2026-11-09 16:07 ` Vincent Guittot
2026-11-11 8:59 ` Peter Zijlstra
2026-11-12 7:01 ` Vincent Guittot
2026-11-09 15:54 ` Peter Zijlstra
2026-11-09 16:14 ` Vincent Guittot
2026-11-11 9:01 ` Peter Zijlstra
2026-11-12 7:01 ` Vincent Guittot
2026-11-12 7:36 ` Vincent Guittot
2026-11-12 9:49 ` Peter Zijlstra
2026-11-12 11:29 ` Vincent Guittot
2026-11-12 12:19 ` Peter Zijlstra
2026-11-06 15:19 ` [PATCH 09/20 v3] sched/fair: Optimize " Vincent Guittot
2026-11-06 16:00 ` sashiko-bot [this message]
2026-11-06 15:19 ` [PATCH 10/20 v3] sched/core: Add rq flag to tick parameters Vincent Guittot
2026-11-06 15:19 ` [PATCH 11/20 v3] sched/fair: Add force push task mechanism for fair Vincent Guittot
2026-11-06 16:16 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 12/20 v3] sched/fair: Support not wakeup case in select_idle_sibling Vincent Guittot
2026-11-06 15:51 ` sashiko-bot
2026-11-13 5:31 ` kernel test robot
2026-11-06 15:19 ` [PATCH 13/20] sched/eevdf: Try to push short slice task on a better CPU Vincent Guittot
2026-11-06 16:12 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 14/20 v3] sched/eevdf: Push short slice task that are not picked Vincent Guittot
2026-11-06 16:14 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 15/20 v3] sched/fair: Enable push task for preempt short Vincent Guittot
2026-11-06 16:27 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 16/20 v3] energy model: Add a get previous state function Vincent Guittot
2026-11-10 19:55 ` Rafael J. Wysocki (Intel)
2026-11-06 15:19 ` [PATCH 17/20 v3] sched/fair: Rework feec() to use cost instead of spare capacity Vincent Guittot
2026-11-06 16:30 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 18/20 v3] energy model: Remove unused em_cpu_energy() Vincent Guittot
2026-11-06 15:19 ` [PATCH 19/20 v3] sched/fair: Take into account slice in EAS Vincent Guittot
2026-11-06 16:26 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 20/20 v3] sched/fair: Fix tasks stacking on same idle CPU Vincent Guittot
2026-11-06 16:53 ` sashiko-bot
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=sashiko-outbox-201755@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=vincent.guittot@linaro.org \
/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