]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched: Optimize hrtimer handling
authorThomas Gleixner <tglx@kernel.org>
Tue, 24 Feb 2026 16:35:52 +0000 (17:35 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 27 Feb 2026 15:40:05 +0000 (16:40 +0100)
commit96d1610e0b20b5a627773874b4514ae922ad98f6
tree53660db37e290e25d0fbaa1344dc9e7cc34f6ff8
parentc3a92213eb3dd8ea6f664d16a08eda800e34eaad
sched: Optimize hrtimer handling

schedule() provides several mechanisms to update the hrtick timer:

  1) When the next task is picked

  2) When the balance callbacks are invoked before rq::lock is released

Each of them can result in a first expiring timer and cause a reprogram of
the clock event device.

Solve this by deferring the rearm to the end of schedule() right before
releasing rq::lock by setting a flag on entry which tells hrtick_start() to
cache the runtime constraint in rq::hrtick_delay without touching the timer
itself.

Right before releasing rq::lock evaluate the flags and either rearm or
cancel the hrtick timer.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260224163429.273068659@kernel.org
kernel/sched/core.c
kernel/sched/sched.h