Re: [PATCH 1/3] sched/core: Dequeue PSI signals for blocked tasks that are delayed

From: Johannes Weiner
Date: Thu Oct 10 2024 - 15:24:08 EST


On Thu, Oct 10, 2024 at 08:28:36AM +0000, K Prateek Nayak wrote:
> From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
>
> psi_dequeue() in for blocked task expects psi_sched_switch() to clear
> the TSK_.*RUNNING PSI flags and set the TSK_IOWAIT flags however
> psi_sched_switch() uses "!task_on_rq_queued(prev)" to detect if the task
> is blocked or still runnable which is no longer true with DELAY_DEQUEUE
> since a blocking task can be left queued on the runqueue.
>
> This can lead to PSI splats similar to:
>
> psi: inconsistent task state! task=... cpu=... psi_flags=4 clear=0 set=4
>
> when the task is requeued since the TSK_RUNNING flag was not cleared
> when the task was blocked.
>
> Explicitly communicate that the task was blocked to psi_sched_switch()
> even if it was delayed and is still on the runqueue.
>
> [ prateek: Broke off the relevant part from [1], commit message ]
>
> Link: https://lore.kernel.org/lkml/20241004123506.GR18071@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ [1]
> Fixes: 152e11f6df29 ("sched/fair: Implement delayed dequeue")
> Closes: https://lore.kernel.org/lkml/20240830123458.3557-1-spasswolf@xxxxxx/
> Closes: https://lore.kernel.org/all/cd67fbcd-d659-4822-bb90-7e8fbb40a856@xxxxxxxxxxxxx/
> Tested-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> Not-yet-signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Signed-off-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>

Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>