Re: [PATCH v33 1/7] sched/psi: Preserve sleep-persistent PSI flags on off-CPU sleeping dequeues

From: Zhan Xusheng

Date: Mon Oct 26 2026 - 01:16:29 EST


Hi John,

On Fri, Oct 23, 2026 at 10:04:12PM +0000, John Stultz wrote:
> + if (p->in_memstall)
> + clear |= TSK_MEMSTALL_RUNNING;
> + if (p->in_iowait)
> + set |= TSK_IOWAIT;
> +
> + psi_task_change(p, clear, set);

In this case psi_task_switch() also clears wake_clock when the task going
to sleep is the psi_avgs_work() worker, so the worker doesn't re-arm its
own work. psi_task_change() always passes wake_clock=true, so that check
is lost here.

The worker can get here: psi_avgs_work() takes group->avgs_lock, which
psi_show(), psi_trigger_create() and psi_trigger_destroy() can hold while
sleeping, so it can block on a sleeping owner and be dequeued through
this branch. TSK_ONCPU is already clear by then, since find_proxy_task()
doesn't park a chain that contains curr.

The cost is an extra aggregation period, not the ping-pong described in
psi_task_switch(), but it keeps the averaging clock from shutting off
while idle. Should this branch do the same PF_WQ_WORKER check?

Thanks,
Zhan Xusheng