]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hrtimer: Provide LAZY_REARM mode
authorPeter Zijlstra <peterz@infradead.org>
Tue, 24 Feb 2026 16:36:01 +0000 (17:36 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 27 Feb 2026 15:40:06 +0000 (16:40 +0100)
commitb7dd64778aa3f89de9afa1e81171cfe110ddc525
tree375c1b79b73330fb22205022be0b0a57b66bbd81
parentc8cdb9b516407a0b8c653c9c1d6f0931c3864384
hrtimer: Provide LAZY_REARM mode

The hrtick timer is frequently rearmed before expiry and most of the time
the new expiry is past the armed one. As this happens on every context
switch it becomes expensive with scheduling heavy work loads especially in
virtual machines as the "hardware" reprogamming implies a VM exit.

Add a lazy rearm mode flag which skips the reprogamming if:

    1) The timer was the first expiring timer before the rearm

    2) The new expiry time is farther out than the armed time

This avoids a massive amount of reprogramming operations of the hrtick
timer for the price of eventually taking the alredy armed interrupt for
nothing.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260224163429.408524456@kernel.org
include/linux/hrtimer.h
include/linux/hrtimer_types.h
kernel/time/hrtimer.c