Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/hrtick: Mark hrtick timer LAZY_REARM

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.

hrtimer now provide 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.

Mark the hrtick timer accordingly.

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.475409346@kernel.org

+2 -1
+2 -1
kernel/sched/core.c
··· 998 998 { 999 999 INIT_CSD(&rq->hrtick_csd, __hrtick_start, rq); 1000 1000 rq->hrtick_sched = HRTICK_SCHED_NONE; 1001 - hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 1001 + hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, 1002 + HRTIMER_MODE_REL_HARD | HRTIMER_MODE_LAZY_REARM); 1002 1003 } 1003 1004 #else /* !CONFIG_SCHED_HRTICK: */ 1004 1005 static inline void hrtick_clear(struct rq *rq) { }