From: Tom Hromatka <tom.hromatka@oracle.com>
To: tom.hromatka@oracle.com, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org,
adobriyan@gmail.com
Subject: [PATCH 1/2] tick-sched: Do not clear the iowait and idle times
Date: Wed, 10 Jun 2020 15:05:48 -0600 [thread overview]
Message-ID: <20200610210549.61193-2-tom.hromatka@oracle.com> (raw)
In-Reply-To: <20200610210549.61193-1-tom.hromatka@oracle.com>
A customer reported that when a cpu goes offline and then comes back
online, the overall cpu idle and iowait data in /proc/stat decreases.
This is wreaking havoc with their cpu usage calculations.
Prior to this patch:
user nice system idle iowait
cpu 1390748 636 209444 9802206 19598
cpu1 178384 75 24545 1392450 3025
take cpu1 offline and bring it back online
user nice system idle iowait
cpu 1391209 636 209682 8453440 16595
cpu1 178440 75 24572 627 0
To prevent this, do not clear the idle and iowait times for the
cpu that has come back online.
With this patch:
user nice system idle iowait
cpu 129913 17 17590 166512 704
cpu1 15916 3 2395 20989 47
take cpu1 offline and bring it back online
user nice system idle iowait
cpu 130089 17 17686 184625 711
cpu1 15942 3 2401 23088 47
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
---
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 3e2dc9b8858c..8103bad7bbd6 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1375,13 +1375,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
+ /* save off and restore the idle_sleeptime and the iowait_sleeptime
+ * to avoid discontinuities and ensure that they are monotonically
+ * increasing
+ */
+ 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.3
next prev parent reply other threads:[~2020-06-10 21:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 21:05 [PATCH 0/2] iowait and idle fixes in /proc/stat Tom Hromatka
2020-06-10 21:05 ` Tom Hromatka [this message]
2020-06-10 21:05 ` [PATCH 2/2] /proc/stat: Simplify iowait and idle calculations when cpu is offline Tom Hromatka
2020-07-14 18:55 ` [PATCH 0/2] iowait and idle fixes in /proc/stat Tom Hromatka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200610210549.61193-2-tom.hromatka@oracle.com \
--to=tom.hromatka@oracle.com \
--cc=adobriyan@gmail.com \
--cc=fweisbec@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).