Skip to content

Commit 2ea97b7

Browse files
committed
hrtimers: Make hrtimer_update_function() less expensive
The sanity checks in hrtimer_update_function() are expensive for high frequency usage like in the io/uring code due to locking. Hide the sanity checks behind CONFIG_PROVE_LOCKING, which has a decent chance to be enabled on a regular basis for testing. Fixes: 8f02e35 ("hrtimers: Introduce hrtimer_update_function()") Reported-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/87ikpllali.ffs@tglx
1 parent a64dcfb commit 2ea97b7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

include/linux/hrtimer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,15 @@ static inline int hrtimer_callback_running(struct hrtimer *timer)
333333
static inline void hrtimer_update_function(struct hrtimer *timer,
334334
enum hrtimer_restart (*function)(struct hrtimer *))
335335
{
336+
#ifdef CONFIG_PROVE_LOCKING
336337
guard(raw_spinlock_irqsave)(&timer->base->cpu_base->lock);
337338

338339
if (WARN_ON_ONCE(hrtimer_is_queued(timer)))
339340
return;
340341

341342
if (WARN_ON_ONCE(!function))
342343
return;
343-
344+
#endif
344345
timer->function = function;
345346
}
346347

0 commit comments

Comments
 (0)