All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peng Huang" <penghuang@google.com>, sched-ext@lists.linux.dev
Subject: Re: [PATCH] sched_ext: Update other_load_avgs on set_next_task_scx
Date: Sun, 22 Nov 2026 03:53:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-227686@kernel.org> (raw)
In-Reply-To: <20261122033316.2819845-1-penghuang@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched_ext: set_next_task_scx() misses PELT decay on idle and
  in ops.running()
--

commit 06ffe41f90ea50855b518361481cd90702ee1876
Author: Peng Huang <penghuang@google.com>

sched_ext: Update other_load_avgs on set_next_task_scx

This commit updates RT, DL, IRQ, and HW pressure load averages in
set_next_task_scx() when picking a new SCX task (SNT_PICK) in addition to
when SCX_RQ_CAN_STOP_TICK toggles.

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index a9e36b5bb0386..f46553d8eb3b9 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -3553,6 +3553,7 @@ static void kick_sync_wait_bal_cb(struct rq *rq);
>  static void set_next_task_scx(struct rq *rq, struct task_struct *p, enum snt_e type)
>  {
>  	bool first = type == SNT_PICK;
> +	bool update_load_avgs = first;
>  	bool can_stop_tick;
>  
>  	/*
> @@ -3619,10 +3620,6 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, enum snt_e t
>  	 * @p is getting newly scheduled or got kicked after someone updated its
>  	 * slice. Update SCX_RQ_CAN_STOP_TICK to reflect whether the tick can be
>  	 * stopped. See scx_can_stop_tick().
> -	 *
> -	 * Moreover, refresh the load_avgs just when transitioning in and out of
> -	 * nohz. In the future, we might want to add a mechanism to update
> -	 * load_avgs periodically on tick-stopped CPUs.
>  	 */
>  	if (can_stop_tick) {
>  		if (!(rq->scx.flags & SCX_RQ_CAN_STOP_TICK)) {
> @@ -3634,13 +3631,12 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, enum snt_e t
>  			 */
>  			rq->scx.flags |= SCX_RQ_CAN_STOP_TICK;
>  			sched_update_tick_dependency(rq);
> -
> -			update_other_load_avgs(rq);
> +			update_load_avgs = true;
>  		}
>  	} else {
>  		if (rq->scx.flags & SCX_RQ_CAN_STOP_TICK) {
>  			rq->scx.flags &= ~SCX_RQ_CAN_STOP_TICK;
> -			update_other_load_avgs(rq);
> +			update_load_avgs = true;
>  		}
>  
>  		/*
> @@ -3651,6 +3647,15 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, enum snt_e t
>  		if (tick_nohz_full_cpu(cpu_of(rq)))
>  			tick_nohz_dep_set_cpu(cpu_of(rq), TICK_DEP_BIT_SCHED);
>  	}
> +
> +	/*
> +	 * Refresh other-class (RT/DL/IRQ/HW) load averages when picking a new
> +	 * task or toggling nohz tick dependency while CFS PELT is dormant.
> +	 * In the future, we might want to add a mechanism to update load_avgs
> +	 * periodically on tick-stopped CPUs.
> +	 */
> +	if (update_load_avgs)
> +		update_other_load_avgs(rq);
>  }

[Severity: Medium]
Does calling update_other_load_avgs() only in set_next_task_scx() leave
rq->avg_rt, rq->avg_dl, rq->avg_irq, and rq->avg_hw undecayed when an SCX
task goes idle after an RT or DL interval?

On an RT/DL -> SCX switch, put_prev_set_next_task() calls
put_prev_task_rt() or put_prev_task_dl(), which updates avg_rt or avg_dl
at rq_clock_pelt(rq), and then immediately calls set_next_task_scx() at
the same clock timestamp where no time has elapsed to decay those averages.
When the SCX task later blocks and the CPU goes idle without an
intervening tick, put_prev_set_next_task() calls put_prev_task_scx() and
set_next_task_idle() without calling set_next_task_scx(), so
update_idle_rq_clock_pelt() and effective_cpu_util() still see the
undecayed utilization from before the SCX task ran.

In addition, within set_next_task_scx(), update_other_load_avgs() runs
after scx_start_task_running() invokes ops.running(), so a BPF scheduler
calling scx_bpf_cpuperf_set() or scx_bpf_cidperf_set() from ops.running()
triggers effective_cpu_util() before the averages are refreshed, and
same-task repicks (SNT_REPICK) return early without updating them.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122033316.2819845-1-penghuang@google.com?part=1

  reply	other threads:[~2026-11-22  3:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  3:33 [PATCH] sched_ext: Update other_load_avgs on set_next_task_scx Peng Huang
2026-11-22  3:53 ` sashiko-bot [this message]
2026-11-22  6:21 ` [PATCH v2] sched_ext: Update other_load_avgs on set_next_task_scx and idle entry Peng Huang
2026-11-23  9:47   ` Tejun Heo
2026-11-23 20:19     ` Peng Huang

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-227686@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=penghuang@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    /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.