posix-timers: Prevent RT livelock in itimer_delete()
authorThomas Gleixner <tglx@linutronix.de>
Thu, 1 Jun 2023 20:16:34 +0000 (22:16 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 18 Jun 2023 20:40:42 +0000 (22:40 +0200)
commit9d9e522010eb5685d8b53e8a24320653d9d4cbbf
tree46167f5414553b9e15b75c94bb78c109f48c68f8
parentb7a7ce1bb77b19ff2859d365da96285340fbc145
posix-timers: Prevent RT livelock in itimer_delete()

itimer_delete() has a retry loop when the timer is concurrently expired. On
non-RT kernels this just spin-waits until the timer callback has completed,
except for posix CPU timers which have HAVE_POSIX_CPU_TIMERS_TASK_WORK
enabled.

In that case and on RT kernels the existing task could live lock when
preempting the task which does the timer delivery.

Replace spin_unlock() with an invocation of timer_wait_running() to handle
it the same way as the other retry loops in the posix timer code.

Fixes: ec8f954a40da ("posix-timers: Use a callback for cancel synchronization on PREEMPT_RT")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/87v8g7c50d.ffs@tglx
kernel/time/posix-timers.c