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

From: John Stultz

Date: Wed Nov 25 2026 - 20:39:01 EST


On Sun, Oct 25, 2026 at 10:16 PM Zhan Xusheng <zhanxusheng1024@xxxxxxxxx> wrote:
> 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?

Hey! Thanks so much for the review and feedback here!

Though, I'm not sure I fully see the issue you're concerned about.
Nor can I see how adding a similari PF_WQ_WORKER check would work
here.

Apologies for being a bit dense here, could you expand a bit on the
specific detail you're thinking about?

thanks
-john