diff --git a/avoid-util-over-100.patch b/avoid-util-over-100.patch new file mode 100644 index 0000000000000000000000000000000000000000..feb9ecb903da22e51539c09e063b4c17ac5b320d --- /dev/null +++ b/avoid-util-over-100.patch @@ -0,0 +1,139 @@ +From 720cda5d4820b2c8ece44ba4017644b5b11a9c3f Mon Sep 17 00:00:00 2001 +From: zhujunhao +Date: Tue, 25 Mar 2025 09:34:57 +0800 +Subject: [PATCH] avoid util over 100 + +--- + iostat.c | 45 +++++++++++++++++---------------------------- + rd_stats.c | 3 +++ + 2 files changed, 20 insertions(+), 28 deletions(-) + +diff --git a/iostat.c b/iostat.c +index eaea928..5f75e0e 100644 +--- a/iostat.c ++++ b/iostat.c +@@ -1136,8 +1136,6 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, + struct io_stats *ioj, char *devname, struct ext_disk_stats *xds, + struct ext_io_stats *xios) + { +- int n; +- + /* If this is a group with no devices, skip it */ + if (d->dev_tp == T_GROUP) + return; +@@ -1146,14 +1144,6 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, + cprintf_in(IS_STR, "%-13s", devname, 0); + } + +- /* Compute number of devices in group */ +- if (d->dev_tp > T_GROUP) { +- n = d->dev_tp - T_GROUP; +- } +- else { +- n = 1; +- } +- + if (DISPLAY_SHORT_OUTPUT(flags)) { + /* tps */ + /* Origin (unmerged) flush operations are counted as writes */ +@@ -1188,7 +1178,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, + * %util + * Again: Ticks in milliseconds. + */ +- cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, xds->util / 10.0 / (double) n); ++ cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, xds->util / 10.0); + } + else { + if ((hpart == 1) || !hpart) { +@@ -1282,13 +1272,7 @@ void write_plain_ext_stat(unsigned long long itv, int fctr, int hpart, + * %util + * Again: Ticks in milliseconds. + */ +- if (d->dev_tp > T_GROUP) { +- n = d->dev_tp - T_GROUP; +- } +- else { +- n = 1; +- } +- cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, xds->util / 10.0 / (double) n); ++ cprintf_pc(DISPLAY_UNIT(flags), 1, 6, 2, xds->util / 10.0); + } + } + +@@ -1320,7 +1304,6 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr, + struct io_stats *ioj, char *devname, struct ext_disk_stats *xds, + struct ext_io_stats *xios) + { +- int n; + char line[256]; + + /* If this is a group with no devices, skip it */ +@@ -1407,13 +1390,7 @@ void write_json_ext_stat(int tab, unsigned long long itv, int fctr, + : S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0); + } + +- if (d->dev_tp > T_GROUP) { +- n = d->dev_tp - T_GROUP; +- } +- else { +- n = 1; +- } +- printf("\"util\": %.2f}", xds->util / 10.0 / (double) n); ++ printf("\"util\": %.2f}", xds->util / 10.0); + } + + /* +@@ -1441,10 +1418,19 @@ void write_ext_stat(unsigned long long itv, int fctr, int hpart, + struct stats_disk sdc, sdp; + struct ext_disk_stats xds; + struct ext_io_stats xios; ++ int n; + + memset(&xds, 0, sizeof(struct ext_disk_stats)); + memset(&xios, 0, sizeof(struct ext_io_stats)); + ++ /* Compute number of devices in group */ ++ if (d->dev_tp > T_GROUP) { ++ n = d->dev_tp - T_GROUP; ++ } ++ else { ++ n = 1; ++ } ++ + /* + * Counters overflows are possible, but don't need to be handled in + * a special way: The difference is still properly calculated if the +@@ -1460,8 +1446,11 @@ void write_ext_stat(unsigned long long itv, int fctr, int hpart, + sdc.nr_ios = ioi->rd_ios + ioi->wr_ios + ioi->dc_ios; + sdp.nr_ios = ioj->rd_ios + ioj->wr_ios + ioj->dc_ios; + +- sdc.tot_ticks = ioi->tot_ticks; +- sdp.tot_ticks = ioj->tot_ticks; ++ sdc.tot_ticks = ioi->tot_ticks / n; ++ sdp.tot_ticks = ioj->tot_ticks / n; ++ ++ sdc.rq_ticks = ioi->rq_ticks; ++ sdp.rq_ticks = ioj->rq_ticks; + + sdc.rd_ticks = ioi->rd_ticks; + sdp.rd_ticks = ioj->rd_ticks; +diff --git a/rd_stats.c b/rd_stats.c +index 3905ac3..a5eace7 100644 +--- a/rd_stats.c ++++ b/rd_stats.c +@@ -377,9 +377,12 @@ 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) + { ++ double aqu_sz = S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0; + xds->util = sdc->tot_ticks < sdp->tot_ticks ? + 0.0 : + S_VALUE(sdp->tot_ticks, sdc->tot_ticks, itv); ++ /* avoid util over 100 */ ++ xds->util = MINIMUM(xds->util, MINIMUM(aqu_sz, 1.0) * 1000); + /* + * Kernel gives ticks already in milliseconds for all platforms + * => no need for further scaling. +-- +2.33.0 + diff --git a/sysstat.spec b/sysstat.spec index 42aac4e2021356a677586e8e7fc09bc5d8ace2b0..e3582962f1735903c7080a7d841a5cc394c5b89b 100644 --- a/sysstat.spec +++ b/sysstat.spec @@ -1,6 +1,6 @@ Name: sysstat Version: 12.5.4 -Release: 11 +Release: 12 Summary: System performance tools for the Linux operating system License: GPLv2+ URL: http://sebastien.godard.pagesperso-orange.fr/ @@ -21,6 +21,7 @@ Requires(preun): systemd Requires(postun): systemd Patch9000: bugfix-sysstat-10.1.5-read-ttyAMA-first-for-arm64.patch +Patch9001: avoid-util-over-100.patch %description The sysstat package contains various utilities, common to many commercial @@ -95,6 +96,9 @@ fi %{_mandir}/man*/* %changelog +* Tue Mar 25 2025 lingsheng - 12.5.4-12 +- avoid util over 100 + * Thu Feb 29 2024 zhangliangpengkun - 12.5.4-11 - Fix the incorrect command 'is-enable' to 'is-enabled'.