diff --git a/sysstat-iowait-decr.patch b/sysstat-iowait-decr.patch new file mode 100644 index 0000000..189847a --- /dev/null +++ b/sysstat-iowait-decr.patch @@ -0,0 +1,63 @@ +From 1f5949d4a6fcb33065dbb1d509f356db039998ed Mon Sep 17 00:00:00 2001 +From: Sebastien GODARD +Date: Wed, 2 Sep 2020 19:04:04 +0200 +Subject: [PATCH] Workaround for iowait being decremented + +The iowait value reported by the kernel on NO_HZ systems can decrement +as a result of inaccurate iowait tracking. Waiting on IO can be first +accounted as iowait but then instead as idle. + +Function get_per_cpu_interval() considers iowait going backwards between +two readings as a CPU coming back online and resets the iowait value of +the first reading to 0. If iowait is decremented only because of +inaccurate tracking, this causes that almost all time between the two +readings is incorrectly recognized by sar as being spent in iowait. + +The patch updates the code in get_per_cpu_interval() to recognize this +situation. If the iowait value between two readings decremented but the +idle value did not then the code now considers it as a problem with the +iowait reporting and corrects the first value according to the second +reading. Otherwise, the code remains treating decremented iowait as a +CPU coming back online. + +Fixes #14. + +Signed-off-by: Sebastien GODARD +--- + rd_stats.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +diff --git a/rd_stats.c b/rd_stats.c +index 56d42d00..fb93f23f 100644 +--- a/rd_stats.c ++++ b/rd_stats.c +@@ -440,12 +440,26 @@ unsigned long long get_per_cpu_interval(struct stats_cpu *scc, + * value was greater than ULLONG_MAX - 0x7ffff (the counter probably + * overflew). + */ ++ if ((scc->cpu_iowait < scp->cpu_iowait) && (scp->cpu_iowait < (ULLONG_MAX - 0x7ffff))) { ++ /* ++ * The iowait value reported by the kernel can also decrement as ++ * a result of inaccurate iowait tracking. Waiting on IO can be ++ * first accounted as iowait but then instead as idle. ++ * Therefore if the idle value during the same period did not ++ * decrease then consider this is a problem with the iowait ++ * reporting and correct the previous value according to the new ++ * reading. Otherwise, treat this as CPU coming back online. ++ */ ++ if ((scc->cpu_idle > scp->cpu_idle) || (scp->cpu_idle >= (ULLONG_MAX - 0x7ffff))) { ++ scp->cpu_iowait = scc->cpu_iowait; ++ } ++ else { ++ scp->cpu_iowait = 0; ++ } ++ } + if ((scc->cpu_idle < scp->cpu_idle) && (scp->cpu_idle < (ULLONG_MAX - 0x7ffff))) { + scp->cpu_idle = 0; + } +- if ((scc->cpu_iowait < scp->cpu_iowait) && (scp->cpu_iowait < (ULLONG_MAX - 0x7ffff))) { +- scp->cpu_iowait = 0; +- } + + /* + * Don't take cpu_guest and cpu_guest_nice into account diff --git a/sysstat.changes b/sysstat.changes index 445e137..cfe6afc 100644 --- a/sysstat.changes +++ b/sysstat.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Fri Sep 18 14:47:02 UTC 2020 - Pedro Monreal + +- Fix average iowait output of sar [bsc#1174227] + * The iowait value reported by the kernel can also decrement as + a result of inaccurate iowait tracking. Waiting on IO can be + first accounted as iowait but then instead as idle. Therefore + if the idle value during the same period did not decrease then + consider this is a problem with the iowait reporting and correct + the previous value according to the new reading. Otherwise, treat + this as CPU coming back online. +- Add patch sysstat-iowait-decr.patch + ------------------------------------------------------------------- Mon Aug 31 11:43:51 UTC 2020 - Dirk Mueller diff --git a/sysstat.spec b/sysstat.spec index b912c97..83b6c72 100644 --- a/sysstat.spec +++ b/sysstat.spec @@ -35,6 +35,8 @@ Patch2: sysstat-8.0.4-pagesize.diff Patch3: sysstat-service.patch # PATCH-FIX-OPENSUSE Temporarily disable failing tests on s390x and ppc64 Patch4: sysstat-disable-test-failures.patch +# PATCH-FIX-OPENSUSE bsc#1174227 Workaround for iowait being decremented +Patch5: sysstat-iowait-decr.patch BuildRequires: findutils BuildRequires: gettext-runtime BuildRequires: pkgconfig @@ -77,6 +79,7 @@ from a sysstat package. %ifarch s390x ppc64 %patch4 -p1 %endif +%patch5 -p1 cp %{S:1} . # remove date and time from objects find ./ -name \*.c -exec sed -i -e 's: " compiled " __DATE__ " " __TIME__::g' {} \;