Re: [RESEND][PATCH v2] sched/wait: Fix a kthread_park race with wait_woken()

From: Valentin Schneider
Date: Mon Jun 12 2023 - 11:29:25 EST


On 02/06/23 21:23, John Stultz wrote:
> From: Arve Hjønnevåg <arve@xxxxxxxxxxx>
>
> kthread_park and wait_woken have a similar race that
> kthread_stop and wait_woken used to have before it was fixed in
> commit cb6538e740d7 ("sched/wait: Fix a kthread race with
> wait_woken()"). Extend that fix to also cover kthread_park.
>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Cc: Ben Segall <bsegall@xxxxxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxx>
> Cc: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
> Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> Cc: android-kernel-team <android-kernel-team@xxxxxxxxxx>
> Signed-off-by: Arve Hjønnevåg <arve@xxxxxxxxxxx>
> [jstultz: Made changes suggested by Peter to optimize
> memory loads]
> Signed-off-by: John Stultz <jstultz@xxxxxxxxxx>

Funny one, IIUC this will happen with any wakeup of a wait_woken()-user
that doesn't touch the wait_queue entry.

Reviewed-by: Valentin Schneider <vschneid@xxxxxxxxxx>

I do have on question: what about signals? Browsing through wait_woken()
users, it looks like a few of them have a wait-loop break condition hinging
on signal_pending() (iio_buffer_read() is one of them). signal_wake_up()
doesn't touch the wait_queue entry, so is that a similar issue or am I
looking at a non-problem?