Skip to content

Commit 3ce74f1

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
tick: Move got_idle_tick away from common flags
tick_nohz_idle_got_tick() is called by cpuidle_reflect() within the idle loop with interrupts enabled. This function modifies the struct tick_sched's bitfield "got_idle_tick". However this bitfield is stored within the same mask as other bitfields that can be modified from interrupts. Fortunately so far it looks like the only race that can happen is while writing ->got_idle_tick to 0, an interrupt fires and writes the ->idle_active field to 0. It's then possible that the interrupted write to ->got_idle_tick writes back the old value of ->idle_active back to 1. However if that happens, the worst possible outcome is that the time spent between that interrupt and the upcoming call to tick_nohz_idle_exit() is accounted as idle, which is negligible quantity. Still all the bitfield writes within this struct tick_sched's shadow mask should be IRQ-safe. Therefore move this bitfield out to its own storage to avoid further suprises. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240225225508.11587-12-frederic@kernel.org
1 parent d9b1865 commit 3ce74f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/time/tick-sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ struct tick_sched {
6161
unsigned int tick_stopped : 1;
6262
unsigned int idle_active : 1;
6363
unsigned int do_timer_last : 1;
64-
unsigned int got_idle_tick : 1;
6564

6665
/* Tick handling: jiffies stall check */
6766
unsigned int stalled_jiffies;
@@ -73,6 +72,7 @@ struct tick_sched {
7372
ktime_t next_tick;
7473
unsigned long idle_jiffies;
7574
ktime_t idle_waketime;
75+
unsigned int got_idle_tick;
7676

7777
/* Idle entry */
7878
seqcount_t idle_sleeptime_seq;

0 commit comments

Comments
 (0)