summaryrefslogtreecommitdiff
path: root/kernel/time/tick-sched.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <frederic@kernel.org>2023-02-22 15:46:44 +0100
committerThomas Gleixner <tglx@linutronix.de>2023-04-18 16:35:12 +0200
commit620a30fa0bd14878891b22bf2261e6ed4587c2b4 (patch)
tree9d193dac68bacb68e34c573819d7c570c96dbc6b /kernel/time/tick-sched.h
parent07b65a800b6d5b6afbd6a91487b47038eac97c21 (diff)
timers/nohz: Protect idle/iowait sleep time under seqcount
Reading idle/IO sleep time (eg: from /proc/stat) can race with idle exit updates because the state machine handling the stats is not atomic and requires a coherent read batch. As a result reading the sleep time may report irrelevant or backward values. Fix this with protecting the simple state machine within a seqcount. This is expected to be cheap enough not to add measurable performance impact on the idle path. Note this only fixes reader VS writer condition partitially. A race remains that involves remote updates of the CPU iowait task counter. It can hardly be fixed. Reported-by: Yu Liao <liaoyu15@huawei.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20230222144649.624380-4-frederic@kernel.org
Diffstat (limited to 'kernel/time/tick-sched.h')
-rw-r--r--kernel/time/tick-sched.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/kernel/time/tick-sched.h b/kernel/time/tick-sched.h
index c6663254d17d..5ed5a9d41d5a 100644
--- a/kernel/time/tick-sched.h
+++ b/kernel/time/tick-sched.h
@@ -75,6 +75,7 @@ struct tick_sched {
ktime_t idle_waketime;
/* Idle entry */
+ seqcount_t idle_sleeptime_seq;
ktime_t idle_entrytime;
/* Tick stop */