Skip to content

Commit 7d99090

Browse files
committed
posix-timers: Clarify timer_wait_running() comment
Explain it better and add the CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y aspect for completeness. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lore.kernel.org/r/20230425183312.985681995@linutronix.de
1 parent 8ce8849 commit 7d99090

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

kernel/time/posix-timers.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,18 @@ static void common_timer_wait_running(struct k_itimer *timer)
836836
}
837837

838838
/*
839-
* On PREEMPT_RT this prevent priority inversion against softirq kthread in
840-
* case it gets preempted while executing a timer callback. See comments in
841-
* hrtimer_cancel_wait_running. For PREEMPT_RT=n this just results in a
842-
* cpu_relax().
839+
* On PREEMPT_RT this prevents priority inversion and a potential livelock
840+
* against the ksoftirqd thread in case that ksoftirqd gets preempted while
841+
* executing a hrtimer callback.
842+
*
843+
* See the comments in hrtimer_cancel_wait_running(). For PREEMPT_RT=n this
844+
* just results in a cpu_relax().
845+
*
846+
* For POSIX CPU timers with CONFIG_POSIX_CPU_TIMERS_TASK_WORK=n this is
847+
* just a cpu_relax(). With CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y this
848+
* prevents spinning on an eventually scheduled out task and a livelock
849+
* when the task which tries to delete or disarm the timer has preempted
850+
* the task which runs the expiry in task work context.
843851
*/
844852
static struct k_itimer *timer_wait_running(struct k_itimer *timer,
845853
unsigned long *flags)

0 commit comments

Comments
 (0)