diff mbox series

[v2,1/2] tick-sched: Do not clear the iowait and idle times

Message ID 20200915193627.85423-2-tom.hromatka@oracle.com
State New
Headers show
Series iowait and idle fixes in /proc/stat | expand

Commit Message

Tom Hromatka Sept. 15, 2020, 7:36 p.m. UTC
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 <tom.hromatka@oracle.com>
---
 kernel/time/tick-sched.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Thomas Gleixner Sept. 24, 2020, 8:41 p.m. UTC | #1
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
diff mbox series

Patch

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