posix-timers: Prevent RT livelock in itimer_delete()
authorThomas Gleixner <tglx@linutronix.de>
Thu, 1 Jun 2023 20:16:34 +0000 (22:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:20:59 +0000 (16:20 +0200)
commite7aff15ba29ba4b3052786b1636fa5c4aa39e179
tree2c8546836411fab70a0e92b02f2f85cb7d427d19
parent9a534100382a13ac590702b9ae7670a642b33db8
posix-timers: Prevent RT livelock in itimer_delete()

[ Upstream commit 9d9e522010eb5685d8b53e8a24320653d9d4cbbf ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/time/posix-timers.c