Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
e840430a22
!92 回合补丁,修复iowait计数器减少时mpstat报iowait高的问题
From: @jinzig 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-05-24 03:12:51 +00:00
jinzhiguang
c45189ea49 Fix the problem of mpstat showing extremely high iowait when iowait counter decreases.
Signed-off-by: jinzhiguang <jinzhiguang@kylinos.cn>
2024-05-24 09:09:49 +08:00
openeuler-ci-bot
b271aea1f6
!83 Fix the incorrect command 'is-enable' to 'is-enabled'.
From: @zhang-liang-pengkun 
Reviewed-by: @yanan-rock 
Signed-off-by: @yanan-rock
2024-03-25 06:51:28 +00:00
zhang-liang-pengkun
f691186716 Fix the incorrect command 'is-enable' to 'is-enabled'.
Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
2024-03-05 17:14:06 +08:00
openeuler-ci-bot
8f53a33a03
!77 [sync] PR-69: fix upgrade problem that sysstat.service changes from disable to enable
From: @openeuler-sync-bot 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2024-01-10 08:04:58 +00:00
zhouwenpei
4d9c4b1d0d fix upgrade problem that sysstat.service changes from disable to enable
(cherry picked from commit 6a71a475977c47c1df298574bcfcc8233fdf5e21)
2024-01-10 14:56:53 +08:00
openeuler-ci-bot
93cb4317f3
!66 [sync] PR-61: Try to avoid negative values
From: @openeuler-sync-bot 
Reviewed-by: @yanan-rock 
Signed-off-by: @yanan-rock
2023-06-20 09:14:42 +00:00
zhouwenpei
82bf859dd3 Try to avoid negative values
(cherry picked from commit a2f41021c44896b7b8a9a3f1459a01d49bdd5c48)
2023-06-20 17:11:27 +08:00
openeuler-ci-bot
9283f95f58
!59 [sync] PR-52: add missing patch
From: @openeuler-sync-bot 
Reviewed-by: @yanan-rock 
Signed-off-by: @yanan-rock
2023-05-30 12:20:22 +00:00
zhouwenpei
a6c693af09 add missing patch
(cherry picked from commit c641d529927d6ea307c71418d70c4bd1ae90de9b)
2023-05-30 17:00:03 +08:00
7 changed files with 636 additions and 17 deletions

View File

@ -0,0 +1,143 @@
From c9a11d35df4aecfcf22aef827bac6cd57def9d4e Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Sun, 23 Oct 2022 16:22:28 +0200
Subject: [PATCH] Add more overflow checks
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
Reference:https://github.com/sysstat/sysstat/commit/c9a11d35df4aecfcf22aef827bac6cd57def9d4e
Conflict:NA
---
common.c | 46 ++++++++++++++++++++++------------------------
common.h | 4 ++--
sa_common.c | 9 +++++++--
sadc.c | 6 ++++++
4 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/common.c b/common.c
index 28d475e..5ecd7ff 100644
--- a/common.c
+++ b/common.c
@@ -410,6 +410,28 @@ int get_wwnid_from_pretty(char *pretty, unsigned long long *wwn, unsigned int *p
return rc;
}
+/*
+ * **************************************************************************
+ * Check if the multiplication of the 3 values may be greater than UINT_MAX.
+ *
+ * IN:
+ * @val1 First value.
+ * @val2 Second value.
+ * @val3 Third value.
+ ***************************************************************************
+ */
+void check_overflow(unsigned long long val1, unsigned long long val2,
+ unsigned long long val3)
+{
+ if (val1 * val2 * val3 > UINT_MAX) {
+#ifdef DEBUG
+ fprintf(stderr, "%s: Overflow detected (%llu). Aborting...\n",
+ __FUNCTION__, val1 * val2 * val3);
+#endif
+ exit(4);
+ }
+}
+
#ifndef SOURCE_SADC
/*
***************************************************************************
@@ -1529,28 +1551,4 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char
return 0;
}
-/*
- ***************************************************************************
- * Check if the multiplication of the 3 values may be greater than UINT_MAX.
- *
- * IN:
- * @val1 First value.
- * @val2 Second value.
- * @val3 Third value.
- ***************************************************************************
- */
-void check_overflow(size_t val1, size_t val2, size_t val3)
-{
- if ((unsigned long long) val1 *
- (unsigned long long) val2 *
- (unsigned long long) val3 > UINT_MAX) {
-#ifdef DEBUG
- fprintf(stderr, "%s: Overflow detected (%llu). Aborting...\n",
- __FUNCTION__,
- (unsigned long long) val1 * (unsigned long long) val2 * (unsigned long long) val3);
-#endif
- exit(4);
- }
-}
-
#endif /* SOURCE_SADC undefined */
diff --git a/common.h b/common.h
index 75f837a..827e282 100644
--- a/common.h
+++ b/common.h
@@ -247,10 +247,10 @@ int extract_wwnid
(char *, unsigned long long *, unsigned int *);
int get_wwnid_from_pretty
(char *, unsigned long long *, unsigned int *);
+void check_overflow
+ (unsigned long long, unsigned long long, unsigned long long);
#ifndef SOURCE_SADC
-void check_overflow
- (size_t, size_t, size_t);
int count_bits
(void *, int);
int count_csvalues
diff --git a/sa_common.c b/sa_common.c
index ff90c1f..0ac04a2 100644
--- a/sa_common.c
+++ b/sa_common.c
@@ -456,8 +456,9 @@ void allocate_structures(struct activity *act[])
if (act[i]->nr_ini > 0) {
/* Look for a possible overflow */
- check_overflow((size_t) act[i]->msize, (size_t) act[i]->nr_ini,
- (size_t) act[i]->nr2);
+ check_overflow((unsigned long long) act[i]->msize,
+ (unsigned long long) act[i]->nr_ini,
+ (unsigned long long) act[i]->nr2);
for (j = 0; j < 3; j++) {
SREALLOC(act[i]->buf[j], void,
@@ -522,6 +523,10 @@ void reallocate_all_buffers(struct activity *a, __nr_t nr_min)
while (nr_realloc < nr_min);
}
+ /* Look for a possible overflow */
+ check_overflow((unsigned long long) a->msize, nr_realloc,
+ (unsigned long long) a->nr2);
+
for (j = 0; j < 3; j++) {
SREALLOC(a->buf[j], void,
(size_t) a->msize * nr_realloc * (size_t) a->nr2);
diff --git a/sadc.c b/sadc.c
index 5516a81..e7d4851 100644
--- a/sadc.c
+++ b/sadc.c
@@ -352,6 +352,12 @@ void sa_sys_init(void)
}
if (IS_COLLECTED(act[i]->options) && (act[i]->nr_ini > 0)) {
+
+ /* Look for a possible overflow */
+ check_overflow((unsigned long long) act[i]->msize,
+ (unsigned long long) act[i]->nr_ini,
+ (unsigned long long) act[i]->nr2);
+
/* Allocate structures for current activity (using nr_ini and nr2 results) */
SREALLOC(act[i]->_buf0, void,
(size_t) act[i]->msize * (size_t) act[i]->nr_ini * (size_t) act[i]->nr2);
--
2.33.0

View File

@ -0,0 +1,104 @@
From 44f1dc159242c1e434a3b836cda49f084c5a96cc Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Sun, 6 Nov 2022 15:48:16 +0100
Subject: [PATCH] Make sure values to be compared are unsigned integers
It seems safer to make sure that input values are unsigned int before
casting them to unsigned long long and making the comparison.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
Reference:https://github.com/sysstat/sysstat/commit/44f1dc159242c1e434a3b836cda49f084c5a96cc
Conflict:NA
---
common.c | 10 ++++++----
common.h | 2 +-
sa_common.c | 10 +++++-----
sadc.c | 6 +++---
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/common.c b/common.c
index 5ecd7ff..8808445 100644
--- a/common.c
+++ b/common.c
@@ -420,13 +420,15 @@ int get_wwnid_from_pretty(char *pretty, unsigned long long *wwn, unsigned int *p
* @val3 Third value.
***************************************************************************
*/
-void check_overflow(unsigned long long val1, unsigned long long val2,
- unsigned long long val3)
+void check_overflow(unsigned int val1, unsigned int val2,
+ unsigned int val3)
{
- if (val1 * val2 * val3 > UINT_MAX) {
+ if ((unsigned long long) val1 * (unsigned long long) val2 *
+ (unsigned long long) val3 > UINT_MAX) {
#ifdef DEBUG
fprintf(stderr, "%s: Overflow detected (%llu). Aborting...\n",
- __FUNCTION__, val1 * val2 * val3);
+ __FUNCTION__, (unsigned long long) val1 * (unsigned long long) val2 *
+ (unsigned long long) val3);
#endif
exit(4);
}
diff --git a/common.h b/common.h
index 827e282..8014fbd 100644
--- a/common.h
+++ b/common.h
@@ -248,7 +248,7 @@ int extract_wwnid
int get_wwnid_from_pretty
(char *, unsigned long long *, unsigned int *);
void check_overflow
- (unsigned long long, unsigned long long, unsigned long long);
+ (unsigned int, unsigned int, unsigned int);
#ifndef SOURCE_SADC
int count_bits
diff --git a/sa_common.c b/sa_common.c
index 0ac04a2..e9a0f86 100644
--- a/sa_common.c
+++ b/sa_common.c
@@ -456,9 +456,9 @@ void allocate_structures(struct activity *act[])
if (act[i]->nr_ini > 0) {
/* Look for a possible overflow */
- check_overflow((unsigned long long) act[i]->msize,
- (unsigned long long) act[i]->nr_ini,
- (unsigned long long) act[i]->nr2);
+ check_overflow((unsigned int) act[i]->msize,
+ (unsigned int) act[i]->nr_ini,
+ (unsigned int) act[i]->nr2);
for (j = 0; j < 3; j++) {
SREALLOC(act[i]->buf[j], void,
@@ -524,8 +524,8 @@ void reallocate_all_buffers(struct activity *a, __nr_t nr_min)
}
/* Look for a possible overflow */
- check_overflow((unsigned long long) a->msize, nr_realloc,
- (unsigned long long) a->nr2);
+ check_overflow((unsigned int) a->msize, (unsigned int) nr_realloc,
+ (unsigned int) a->nr2);
for (j = 0; j < 3; j++) {
SREALLOC(a->buf[j], void,
diff --git a/sadc.c b/sadc.c
index e7d4851..bcd8b59 100644
--- a/sadc.c
+++ b/sadc.c
@@ -354,9 +354,9 @@ void sa_sys_init(void)
if (IS_COLLECTED(act[i]->options) && (act[i]->nr_ini > 0)) {
/* Look for a possible overflow */
- check_overflow((unsigned long long) act[i]->msize,
- (unsigned long long) act[i]->nr_ini,
- (unsigned long long) act[i]->nr2);
+ check_overflow((unsigned int) act[i]->msize,
+ (unsigned int) act[i]->nr_ini,
+ (unsigned int) act[i]->nr2);
/* Allocate structures for current activity (using nr_ini and nr2 results) */
SREALLOC(act[i]->_buf0, void,
--
2.33.0

View File

@ -2,23 +2,23 @@ From 954ff2e2673cef48f0ed44668c466eab041db387 Mon Sep 17 00:00:00 2001
From: Pavel Kopylov <pkopylov@cloudlinux.com>
Date: Wed, 17 May 2023 11:33:45 +0200
Subject: [PATCH] Fix an overflow which is still possible for some values.
Reference:https://github.com/sysstat/sysstat/commit/6f8dc568e6ab072bb8205b732f04e685bf9237c0
Conflict:Adaptation Context
Conflict:NA
---
common.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
common.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/common.c b/common.c
index 28d475e..85b2457 100644
index 8808445..879d697 100644
--- a/common.c
+++ b/common.c
@@ -1541,15 +1541,16 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char
*/
void check_overflow(size_t val1, size_t val2, size_t val3)
@@ -423,15 +423,17 @@ int get_wwnid_from_pretty(char *pretty, unsigned long long *wwn, unsigned int *p
void check_overflow(unsigned int val1, unsigned int val2,
unsigned int val3)
{
- if ((unsigned long long) val1 *
- (unsigned long long) val2 *
- if ((unsigned long long) val1 * (unsigned long long) val2 *
- (unsigned long long) val3 > UINT_MAX) {
+ if ((val1 != 0) && (val2 != 0) && (val3 != 0) &&
+ (((unsigned long long) UINT_MAX / (unsigned long long) val1 <
@ -27,15 +27,17 @@ index 28d475e..85b2457 100644
+ (unsigned long long) val3))) {
#ifdef DEBUG
- fprintf(stderr, "%s: Overflow detected (%llu). Aborting...\n",
- __FUNCTION__,
- (unsigned long long) val1 * (unsigned long long) val2 * (unsigned long long) val3);
- __FUNCTION__, (unsigned long long) val1 * (unsigned long long) val2 *
- (unsigned long long) val3);
+ fprintf(stderr, "%s: Overflow detected (%u,%u,%u). Aborting...\n",
+ __FUNCTION__, val1, val2, val3);
#endif
- exit(4);
- }
+ exit(4);
}
+ }
}
#ifndef SOURCE_SADC
--
2.33.0
2.27.0

View File

@ -0,0 +1,100 @@
From c43167cca3d27940e81bfed06f6645a864d00216 Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Sun, 7 May 2023 10:16:40 +0200
Subject: [PATCH] iostat: Try to avoid negative values (#355)
Check for negative values to avoir displaying large numbers.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
Reference:https://github.com/sysstat/sysstat/commit/c43167cca3d27940e81bfed06f6645a864d00216
Conflict:NA
---
iostat.c | 28 +++++++++++++++++++++-------
rd_stats.c | 4 +++-
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/iostat.c b/iostat.c
index 41a1dbd..23b12f7 100644
--- a/iostat.c
+++ b/iostat.c
@@ -1001,6 +1001,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
if ((hpart == 1) || !hpart) {
/* r/s */
cprintf_f(NO_UNIT, 1, 7, 2,
+ ioi->rd_ios < ioj->rd_ios ? 0.0 :
S_VALUE(ioj->rd_ios, ioi->rd_ios, itv));
/* rkB/s */
if (!DISPLAY_UNIT(flags)) {
@@ -1024,6 +1025,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
if ((hpart == 2) || !hpart) {
/* w/s */
cprintf_f(NO_UNIT, 1, 7, 2,
+ ioi->wr_ios < ioj->wr_ios ? 0.0 :
S_VALUE(ioj->wr_ios, ioi->wr_ios, itv));
/* wkB/s */
if (!DISPLAY_UNIT(flags)) {
@@ -1047,6 +1049,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
if ((hpart == 3) || !hpart) {
/* d/s */
cprintf_f(NO_UNIT, 1, 7, 2,
+ ioi->dc_ios < ioj->dc_ios ? 0.0 :
S_VALUE(ioj->dc_ios, ioi->dc_ios, itv));
/* dkB/s */
if (!DISPLAY_UNIT(flags)) {
@@ -1148,9 +1151,12 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr,
}
else {
printf("\"r/s\": %.2f, \"w/s\": %.2f, \"d/s\": %.2f, ",
- S_VALUE(ioj->rd_ios, ioi->rd_ios, itv),
- S_VALUE(ioj->wr_ios, ioi->wr_ios, itv),
- S_VALUE(ioj->dc_ios, ioi->dc_ios, itv));
+ ioi->rd_ios < ioj->rd_ios ? 0.0
+ : S_VALUE(ioj->rd_ios, ioi->rd_ios, itv),
+ ioi->wr_ios < ioj->wr_ios ? 0.0
+ : S_VALUE(ioj->wr_ios, ioi->wr_ios, itv),
+ ioi->dc_ios < ioj->dc_ios ? 0.0
+ : S_VALUE(ioj->dc_ios, ioi->dc_ios, itv));
if (DISPLAY_MEGABYTES(flags)) {
sprintf(line, "\"rMB/s\": %%.2f, \"wMB/s\": %%.2f, \"dMB/s\": %%.2f, ");
}
@@ -1256,10 +1262,18 @@ void write_ext_stat(unsigned long long itv, int fctr, int hpart,
compute_ext_disk_stats(&sdc, &sdp, itv, &xds);
}
- /* rkB/s wkB/s dkB/s */
- xios.rsectors = S_VALUE(ioj->rd_sectors, ioi->rd_sectors, itv);
- xios.wsectors = S_VALUE(ioj->wr_sectors, ioi->wr_sectors, itv);
- xios.dsectors = S_VALUE(ioj->dc_sectors, ioi->dc_sectors, itv);
+ /*
+ * rkB/s wkB/s dkB/s
+ * Note: We've already tried to determine if a device had been
+ * removed then added again (see write_stats() function).
+ * Anyway we need to check again for possible negative values.
+ */
+ xios.rsectors = ioi->rd_sectors < ioj->rd_sectors ? 0.0 :
+ S_VALUE(ioj->rd_sectors, ioi->rd_sectors, itv);
+ xios.wsectors = ioi->wr_sectors < ioj->wr_sectors ? 0.0 :
+ S_VALUE(ioj->wr_sectors, ioi->wr_sectors, itv);
+ xios.dsectors = ioi->dc_sectors < ioj->dc_sectors ? 0.0 :
+ S_VALUE(ioj->dc_sectors, ioi->dc_sectors, itv);
if (DISPLAY_SHORT_OUTPUT(flags)) {
xios.sectors = xios.rsectors + xios.wsectors + xios.dsectors;
diff --git a/rd_stats.c b/rd_stats.c
index 58d8a44..fcae43e 100644
--- a/rd_stats.c
+++ b/rd_stats.c
@@ -369,7 +369,9 @@ void read_uptime(unsigned long long *uptime)
void compute_ext_disk_stats(struct stats_disk *sdc, struct stats_disk *sdp,
unsigned long long itv, struct ext_disk_stats *xds)
{
- xds->util = S_VALUE(sdp->tot_ticks, sdc->tot_ticks, itv);
+ xds->util = sdc->tot_ticks < sdp->tot_ticks ?
+ 0.0 :
+ S_VALUE(sdp->tot_ticks, sdc->tot_ticks, itv);
/*
* Kernel gives ticks already in milliseconds for all platforms
* => no need for further scaling.
--
2.33.0

View File

@ -0,0 +1,189 @@
From 3442cec3872d6c07eda21d147ebdd35ef2fea620 Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Sat, 27 May 2023 16:31:05 +0200
Subject: [PATCH] iostat: Try to avoid some more negative values (#355)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
Reference:https://github.com/sysstat/sysstat/commit/3442cec3872d6c07eda21d147ebdd35ef2fea620
Conflict:NA
---
iostat.c | 40 +++++++++++++++++++++++++++++-----------
rd_stats.c | 4 ++--
2 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/iostat.c b/iostat.c
index 23b12f7..04b6ae3 100644
--- a/iostat.c
+++ b/iostat.c
@@ -970,6 +970,8 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
if (DISPLAY_SHORT_OUTPUT(flags)) {
/* tps */
cprintf_f(NO_UNIT, 1, 8, 2,
+ ioi->rd_ios + ioi->wr_ios + ioi->dc_ios < ioj->rd_ios + ioj->wr_ios + ioj->dc_ios ?
+ 0.0 :
S_VALUE(ioj->rd_ios + ioj->wr_ios + ioj->dc_ios,
ioi->rd_ios + ioi->wr_ios + ioi->dc_ios, itv));
/* kB/s */
@@ -980,6 +982,8 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
xios->sectors);
/* rqm/s */
cprintf_f(NO_UNIT, 1, 8, 2,
+ ioi->rd_merges + ioi->wr_merges + ioi->dc_merges < ioj->rd_merges + ioj->wr_merges + ioj->dc_merges ?
+ 0.0 :
S_VALUE(ioj->rd_merges + ioj->wr_merges + ioj->dc_merges,
ioi->rd_merges + ioi->wr_merges + ioi->dc_merges, itv));
/* await */
@@ -990,6 +994,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
xds->arqsz / 2);
/* aqu-sz */
cprintf_f(NO_UNIT, 1, 7, 2,
+ ioi->rq_ticks < ioj->rq_ticks ? 0.0 :
S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
/*
* %util
@@ -1011,6 +1016,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
xios->rsectors);
/* rrqm/s */
cprintf_f(NO_UNIT, 1, 8, 2,
+ ioi->rd_merges < ioj->rd_merges ? 0.0 :
S_VALUE(ioj->rd_merges, ioi->rd_merges, itv));
/* %rrqm */
cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2,
@@ -1035,6 +1041,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
xios->wsectors);
/* wrqm/s */
cprintf_f(NO_UNIT, 1, 8, 2,
+ ioi->wr_merges < ioj->wr_merges ? 0.0 :
S_VALUE(ioj->wr_merges, ioi->wr_merges, itv));
/* %wrqm */
cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2,
@@ -1059,6 +1066,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
xios->dsectors);
/* drqm/s */
cprintf_f(NO_UNIT, 1, 8, 2,
+ ioi->dc_merges < ioj->dc_merges ? 0.0 :
S_VALUE(ioj->dc_merges, ioi->dc_merges, itv));
/* %drqm */
cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2,
@@ -1073,6 +1081,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart,
if ((hpart == 4) || !hpart) {
/* aqu-sz */
cprintf_f(NO_UNIT, 1, 7, 2,
+ ioi->rq_ticks < ioj->rq_ticks ? 0.0 :
S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
/*
* %util
@@ -1129,6 +1138,8 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr,
if (DISPLAY_SHORT_OUTPUT(flags)) {
printf("\"tps\": %.2f, \"",
+ ioi->rd_ios + ioi->wr_ios + ioi->dc_ios < ioj->rd_ios + ioj->wr_ios + ioj->dc_ios ?
+ 0.0 :
S_VALUE(ioj->rd_ios + ioj->wr_ios + ioj->dc_ios,
ioi->rd_ios + ioi->wr_ios + ioi->dc_ios, itv));
if (DISPLAY_MEGABYTES(flags)) {
@@ -1143,11 +1154,14 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr,
printf("\": %.2f, \"rqm/s\": %.2f, \"await\": %.2f, "
"\"areq-sz\": %.2f, \"aqu-sz\": %.2f, ",
xios->sectors /= fctr,
+ ioi->rd_merges + ioi->wr_merges + ioi->dc_merges < ioj->rd_merges + ioj->wr_merges + ioj->dc_merges ?
+ 0.0 :
S_VALUE(ioj->rd_merges + ioj->wr_merges + ioj->dc_merges,
ioi->rd_merges + ioi->wr_merges + ioi->dc_merges, itv),
xds->await,
xds->arqsz / 2,
- S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
+ ioi->rq_ticks < ioj->rq_ticks ? 0.0
+ : S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
}
else {
printf("\"r/s\": %.2f, \"w/s\": %.2f, \"d/s\": %.2f, ",
@@ -1175,9 +1189,12 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr,
"\"r_await\": %.2f, \"w_await\": %.2f, \"d_await\": %.2f, "
"\"rareq-sz\": %.2f, \"wareq-sz\": %.2f, \"dareq-sz\": %.2f, "
"\"aqu-sz\": %.2f, ",
- S_VALUE(ioj->rd_merges, ioi->rd_merges, itv),
- S_VALUE(ioj->wr_merges, ioi->wr_merges, itv),
- S_VALUE(ioj->dc_merges, ioi->dc_merges, itv),
+ ioi->rd_merges < ioj->rd_merges ? 0.0
+ : S_VALUE(ioj->rd_merges, ioi->rd_merges, itv),
+ ioi->wr_merges < ioj->wr_merges ? 0.0
+ : S_VALUE(ioj->wr_merges, ioi->wr_merges, itv),
+ ioi->dc_merges < ioj->dc_merges ? 0.0
+ : S_VALUE(ioj->dc_merges, ioi->dc_merges, itv),
xios->rrqm_pc,
xios->wrqm_pc,
xios->drqm_pc,
@@ -1187,7 +1204,8 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr,
xios->rarqsz / 2,
xios->warqsz / 2,
xios->darqsz / 2,
- S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
+ ioi->rq_ticks < ioj->rq_ticks ? 0.0
+ : S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0);
}
if (d->dev_tp > T_GROUP) {
@@ -1286,11 +1304,11 @@ void write_ext_stat(unsigned long long itv, int fctr, int hpart,
((ioi->rd_merges - ioj->rd_merges) + (ioi->rd_ios - ioj->rd_ios)) * 100 :
0.0;
/* r_await */
- xios.r_await = (ioi->rd_ios - ioj->rd_ios) ?
+ xios.r_await = (ioi->rd_ios > ioj->rd_ios) ?
(ioi->rd_ticks - ioj->rd_ticks) /
((double) (ioi->rd_ios - ioj->rd_ios)) : 0.0;
/* rareq-sz (still in sectors, not kB) */
- xios.rarqsz = (ioi->rd_ios - ioj->rd_ios) ?
+ xios.rarqsz = (ioi->rd_ios > ioj->rd_ios) ?
(ioi->rd_sectors - ioj->rd_sectors) / ((double) (ioi->rd_ios - ioj->rd_ios)) :
0.0;
}
@@ -1301,11 +1319,11 @@ void write_ext_stat(unsigned long long itv, int fctr, int hpart,
((ioi->wr_merges - ioj->wr_merges) + (ioi->wr_ios - ioj->wr_ios)) * 100 :
0.0;
/* w_await */
- xios.w_await = (ioi->wr_ios - ioj->wr_ios) ?
+ xios.w_await = (ioi->wr_ios > ioj->wr_ios) ?
(ioi->wr_ticks - ioj->wr_ticks) /
((double) (ioi->wr_ios - ioj->wr_ios)) : 0.0;
/* wareq-sz (still in sectors, not kB) */
- xios.warqsz = (ioi->wr_ios - ioj->wr_ios) ?
+ xios.warqsz = (ioi->wr_ios > ioj->wr_ios) ?
(ioi->wr_sectors - ioj->wr_sectors) / ((double) (ioi->wr_ios - ioj->wr_ios)) :
0.0;
}
@@ -1316,11 +1334,11 @@ void write_ext_stat(unsigned long long itv, int fctr, int hpart,
((ioi->dc_merges - ioj->dc_merges) + (ioi->dc_ios - ioj->dc_ios)) * 100 :
0.0;
/* d_await */
- xios.d_await = (ioi->dc_ios - ioj->dc_ios) ?
+ xios.d_await = (ioi->dc_ios > ioj->dc_ios) ?
(ioi->dc_ticks - ioj->dc_ticks) /
((double) (ioi->dc_ios - ioj->dc_ios)) : 0.0;
/* dareq-sz (still in sectors, not kB) */
- xios.darqsz = (ioi->dc_ios - ioj->dc_ios) ?
+ xios.darqsz = (ioi->dc_ios > ioj->dc_ios) ?
(ioi->dc_sectors - ioj->dc_sectors) / ((double) (ioi->dc_ios - ioj->dc_ios)) :
0.0;
}
diff --git a/rd_stats.c b/rd_stats.c
index fcae43e..610b843 100644
--- a/rd_stats.c
+++ b/rd_stats.c
@@ -376,10 +376,10 @@ void compute_ext_disk_stats(struct stats_disk *sdc, struct stats_disk *sdp,
* Kernel gives ticks already in milliseconds for all platforms
* => no need for further scaling.
*/
- xds->await = (sdc->nr_ios - sdp->nr_ios) ?
+ xds->await = (sdc->nr_ios > sdp->nr_ios) ?
((sdc->rd_ticks - sdp->rd_ticks) + (sdc->wr_ticks - sdp->wr_ticks) + (sdc->dc_ticks - sdp->dc_ticks)) /
((double) (sdc->nr_ios - sdp->nr_ios)) : 0.0;
- xds->arqsz = (sdc->nr_ios - sdp->nr_ios) ?
+ xds->arqsz = (sdc->nr_ios > sdp->nr_ios) ?
((sdc->rd_sect - sdp->rd_sect) + (sdc->wr_sect - sdp->wr_sect) + (sdc->dc_sect - sdp->dc_sect)) /
((double) (sdc->nr_ios - sdp->nr_ios)) : 0.0;
}
--
2.33.0

View File

@ -0,0 +1,59 @@
From 6ab627493544c685823f63b74636e82981d96ea8 Mon Sep 17 00:00:00 2001
From: Petr Pavlu <petr.pavlu@suse.com>
Date: Wed, 2 Sep 2020 10:24:43 +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.
---
rd_stats.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/rd_stats.c b/rd_stats.c
index 56d42d00..be762450 100644
--- a/rd_stats.c
+++ b/rd_stats.c
@@ -440,12 +440,24 @@ 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_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

View File

@ -1,13 +1,18 @@
Name: sysstat
Version: 12.2.1
Release: 5
Release: 10
Summary: System performance tools for the Linux operating system
License: GPLv2+
URL: http://sebastien.godard.pagesperso-orange.fr/
Source0: http://sebastien.godard.pagesperso-orange.fr/%{name}-%{version}.tar.xz
Patch6000: backport-CVE-2022-39377.patch
Patch6001: backport-CVE-2023-33204.patch
Patch6001: backport-0001-CVE-2023-33204.patch
Patch6002: backport-0002-CVE-2023-33204.patch
Patch6003: backport-0003-CVE-2023-33204.patch
Patch6004: backport-Try-to-avoid-negative-values.patch
Patch6005: backport-Try-to-avoid-some-more-negative-values.patch
Patch6006: backport-Workaround-for-iowait-being-decremented.patch
BuildRequires: gcc, gettext, lm_sensors-devel, systemd
@ -76,7 +81,9 @@ export compressafter="31"
%systemd_postun sysstat.service sysstat-collect.timer sysstat-summary.timer
%posttrans
/usr/bin/systemctl enable sysstat.service >/dev/null 2>&1
if [ "$(systemctl is-enabled sysstat.service)" == "enabled" ] ; then
/usr/bin/systemctl enable sysstat.service >/dev/null 2>&1
fi
%files -f %{name}.lang
%doc CHANGES COPYING CREDITS FAQ.md README.md %{name}-%{version}.lsm
@ -89,6 +96,21 @@ export compressafter="31"
%{_mandir}/man*/*
%changelog
* Thu May 23 2024 jinzhiguang <jinzhiguang@kylinos.cn> - 12.2.1-10
- Fix the problem of mpstat showing extremely high iowait when iowait counter decreases.
* Thu Feb 29 2024 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 12.2.1-9
- Fix the incorrect command 'is-enable' to 'is-enabled'.
* Wed Jan 10 2024 zhouwenpei <zhouwenpei1@h-partners.com> - 12.2.1-8
- fix upgrade problem that sysstat.service changes from disable to enable
* Tue Jun 20 2023 zhouwenpei <zhouwenpei1@h-partners.com> - 12.2.1-7
- Try to avoid negative values
* Mon May 29 2023 zhouwenpei <zhouwenpei1@h-partners.com> - 12.2.1-6
- add missing patch
* Thu May 25 2023 zhouwenpei <zhouwenpei1@h-partners.com> - 12.2.1-5
- fix CVE-2023-33204