Prior to this commit, the cpu idle and iowait data in /proc/stat were
cleared when a CPU goes down. When the CPU came back online, both idle
and iowait times were restarted from 0.
This commit preserves the CPU's idle and iowait values when a CPU goes
offline and comes back online.
Signed-off-by: Tom Hromatka <[email protected]>
---
kernel/time/tick-sched.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index f0199a4ba1ad..4fbf67171dde 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1383,13 +1383,22 @@ void tick_setup_sched_timer(void)
void tick_cancel_sched_timer(int cpu)
{
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
+ ktime_t idle_sleeptime, iowait_sleeptime;
# ifdef CONFIG_HIGH_RES_TIMERS
if (ts->sched_timer.base)
hrtimer_cancel(&ts->sched_timer);
# endif
+ /*
+ * Preserve idle and iowait sleep times accross a CPU offline/online
+ * sequence as they are accumulative.
+ */
+ idle_sleeptime = ts->idle_sleeptime;
+ iowait_sleeptime = ts->iowait_sleeptime;
memset(ts, 0, sizeof(*ts));
+ ts->idle_sleeptime = idle_sleeptime;
+ ts->iowait_sleeptime = iowait_sleeptime;
}
#endif
--
2.25.4
On Tue, Sep 15 2020 at 13:36, Tom Hromatka wrote:
> Prior to this commit, the cpu idle and iowait data in /proc/stat were
> cleared when a CPU goes down. When the CPU came back online, both idle
> and iowait times were restarted from 0.
Starting a commit message with 'Prior to this commit' is
pointless. Describe the factual problem which made you come up with this
change.
>
> This commit preserves the CPU's idle and iowait values when a CPU goes
> offline and comes back online.
'This commit does' is just a variation of 'This patch does'.
git grep 'This patch' Documentation/process/
Thanks,
tglx