iostat -x -g: group %util has division problem, so keeps shrinking with each report
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c
調査の方向性
iostat.c を読む: write_stats() は各レポートでデバイスごとにグループの dev_tp を 1 回インクリメントし、write_plain_ext_stat() は dev_in_grp = dev_tp - T_GROUP を %util の除数として導出するため、除数は間隔ごとに増加する。報告者の 8 行のパッチは、グループ統計がゼロにされたときにグループの dev_tp を T_GROUP にリセットし、h == hl でガードされるので、--pretty のマルチパス出力は正しいままになる。ビルド (./configure --disable-nls --disable-sensors && make) と、負荷をかけた状態での iostat -y -x -m -g 10 の実行によって検証する: グループの %util は、最初のレポートだけでなく、後続のすべてのレポートで sum(disk %util)/4 と等しくなければならない。
索引モデルが issue の本文から書いたものです。
説明
Hello,
I have found an issue under -g Group Mode where the summary total of util% doesn't add up correctly, due to how it calculates the average. Below, I'll show the commands exhibiting the problem, and then the commands showing the fixed output after compiling with the attached patch file.
Full disclosure: I am not a C developer, and I both diagnosed this issue and created the patch using claude. I did compile and test the patch on my own machine however, and it fixed the issue for me.
System info
iostat -V: sysstat version 12.7.9- Linux 7.2.8-200.fc44.x86_64 (Fedora 44)
- Also reproduced on current master (da7ff231, built from source).
Steps to reproduce
- run a light workload with fio to stimulate some disk activity:
fio --name=light --filename=./fiotest.tmp --size=256m --rw=randrw --bs=64k --rate=1m,1m --ioengine=psync --direct=1 --time_based --runtime=45 - watch with iostat in another terminal:
iostat -y -x -m -g home_disks nvme0n1 nvme2n1 nvme3n1 nvme5n1 10
Expected results
%util summary line is the average of its member disks' utilization, ie the sum/num disks
Actual results
Here is my output from the Steps to reproduce commands, I let iostat generate 3 reports with 10s interval while fio was running:
Linux 7.2.8-200.fc44.x86_64 (server.home) 10/04/2026 _x86_64_ (48 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
2.51 0.00 0.93 0.12 0.00 96.43
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 6.00 0.94 6.10 50.41 3.57 159.67 2.60 0.02 0.00 0.00 0.92 8.00 0.00 0.00 0.00 0.00 0.00 0.00 1.30 0.77 0.02 2.40
nvme2n1 0.40 0.30 2.00 83.33 7.00 756.00 2.60 0.02 0.00 0.00 1.96 8.00 0.00 0.00 0.00 0.00 0.00 0.00 1.30 1.31 0.01 0.78
nvme3n1 10.90 0.57 2.60 19.26 1.26 53.69 2.60 0.02 0.00 0.00 0.54 7.23 0.00 0.00 0.00 0.00 0.00 0.00 1.30 0.85 0.02 1.57
nvme5n1 0.70 0.55 4.20 85.71 7.00 807.43 2.60 0.02 0.00 0.00 1.65 7.23 0.00 0.00 0.00 0.00 0.00 0.00 1.30 1.31 0.01 0.93
home_disks 18.00 2.35 14.90 45.29 2.38 133.93 10.40 0.08 0.00 0.00 1.27 7.62 0.00 0.00 0.00 0.00 0.00 0.00 5.20 1.06 0.06 0.71
avg-cpu: %user %nice %system %iowait %steal %idle
2.42 0.00 0.79 0.09 0.00 96.70
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 4.30 0.24 1.40 24.56 3.95 58.05 12.20 0.88 3.90 24.22 0.19 73.44 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.50 0.02 1.92
nvme2n1 0.50 0.38 2.70 84.38 7.00 786.40 12.80 0.88 3.90 23.35 0.18 70.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 1.00 0.01 0.54
nvme3n1 0.40 0.30 2.10 84.00 7.00 770.00 11.00 0.66 3.30 23.08 0.19 61.53 0.00 0.00 0.00 0.00 0.00 0.00 0.20 1.00 0.01 0.43
nvme5n1 0.00 0.00 0.00 0.00 0.00 0.00 11.00 0.66 3.30 23.08 0.20 61.53 0.00 0.00 0.00 0.00 0.00 0.00 0.20 1.00 0.00 0.17
home_disks 5.20 0.93 6.20 54.39 4.48 182.85 47.00 3.07 14.40 23.45 0.19 66.93 0.00 0.00 0.00 0.00 0.00 0.00 0.80 0.88 0.03 0.25
avg-cpu: %user %nice %system %iowait %steal %idle
2.52 0.00 1.01 0.05 0.00 96.43
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 0.70 0.70 4.90 87.50 7.00 1024.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.49
nvme2n1 0.30 0.20 1.40 82.35 4.67 685.33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.14
nvme3n1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
nvme5n1 0.30 0.20 1.50 83.33 7.00 668.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.21
home_disks 1.30 1.10 7.80 85.71 6.46 863.69 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.05
The table below adds up each report's four per-disk %util values and compares their average (sum / 4, which is what the home_disks line should show) with the value iostat actually printed.
| Report | Disk %util (nvme0n1, nvme2n1, nvme3n1, nvme5n1) | Sum | Expected (sum / 4) | Shown on home_disks |
Shown = sum / |
|---|---|---|---|---|---|
| 1 | 2.40, 0.78, 1.57, 0.93 | 5.68 | 1.42 | 0.71 | 8 |
| 2 | 1.92, 0.54, 0.43, 0.17 | 3.06 | 0.77 | 0.25 | 12 |
| 3 | 0.49, 0.14, 0.00, 0.21 | 0.84 | 0.21 | 0.05 | 16 |
The rest of the columns besides %util add up correctly.
What claude thinks is happening
In
write_stats(), the group'sdev_tpis incremented once per device on every report ((g->dev_tp)++in theh == hlbranch) and is never reset.write_plain_ext_stat()then computesdev_in_grp = d->dev_tp - T_GROUPand dividesxds->utilby it, so the divisor grows by the number of devices each report.The attached patch (
iostat-group-util.patch, 8 lines) resets the group'sdev_tptoT_GROUPwhen the group's stats are zeroed at the start of a report. The reset is only done on the first pass (h == hl), so the multi-pass--prettylayout still counts correctly.
It thinks the regression was caused by 6857aa71, first released in 12.1.6 in 2019. I don't have the coding skills to personally validate the above explanation, other than to say that the patch worked.
Building and testing the patch
I built and tested the attached patch like so:
git clone https://github.com/sysstat/sysstat.git
cd sysstat
git apply iostat-group-util.patch
./configure --disable-nls --disable-sensors
make
./iostat -y -x -m -g home_disks nvme0n1 nvme2n1 nvme3n1 nvme5n1 10
New output showing the average is calculated correctly
Same test as before:
Linux 7.2.8-200.fc44.x86_64 (server.home) 10/04/26 _x86_64_ (48 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
2.48 0.00 0.91 0.20 0.00 96.42
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 7.40 0.58 3.10 29.52 3.26 80.70 13.70 0.48 2.20 13.84 0.07 36.03 0.00 0.00 0.00 0.00 0.00 0.00 0.90 0.44 0.03 2.52
nvme2n1 3.60 0.75 4.90 57.65 4.97 212.78 12.30 0.48 2.20 15.17 0.27 40.13 0.00 0.00 0.00 0.00 0.00 0.00 0.90 0.89 0.02 2.05
nvme3n1 4.20 0.34 2.00 32.26 4.88 83.62 14.30 0.95 3.70 20.56 0.34 67.72 0.00 0.00 0.00 0.00 0.00 0.00 0.80 1.12 0.03 2.47
nvme5n1 4.40 0.51 3.10 41.33 3.89 118.64 17.80 0.95 3.70 17.21 0.16 54.40 0.00 0.00 0.00 0.00 0.00 0.00 0.80 0.88 0.02 1.98
home_disks 19.60 2.18 13.10 40.06 4.06 114.10 58.10 2.86 11.80 16.88 0.21 50.33 0.00 0.00 0.00 0.00 0.00 0.00 3.40 0.82 0.09 2.25
avg-cpu: %user %nice %system %iowait %steal %idle
2.45 0.00 0.94 0.16 0.00 96.45
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 5.40 0.18 0.60 10.00 4.56 34.67 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.02 2.42
nvme2n1 1.40 0.18 1.00 41.67 6.36 133.43 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.87
nvme3n1 2.90 0.24 1.60 35.56 4.24 84.97 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 1.23
nvme5n1 1.80 0.21 1.30 41.94 6.50 118.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 1.16
home_disks 11.50 0.81 4.50 28.12 5.00 72.42 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.06 1.42
avg-cpu: %user %nice %system %iowait %steal %idle
2.47 0.00 0.95 0.10 0.00 96.48
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 2.90 0.15 0.60 17.14 4.93 51.45 13.10 0.83 4.30 24.71 0.08 64.61 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.50 0.02 1.59
nvme2n1 1.50 0.50 3.40 69.39 6.87 344.53 11.10 0.83 4.30 27.92 0.20 76.25 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.50 0.01 1.16
nvme3n1 0.40 0.09 0.60 60.00 7.00 219.00 11.40 1.01 4.60 28.75 0.20 90.81 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.00 0.01 19.13
nvme5n1 1.60 0.37 2.60 61.90 6.38 236.75 10.90 1.01 4.60 29.68 0.22 94.97 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.50 0.01 1.23
home_disks 6.40 1.11 7.20 52.94 5.88 176.94 46.50 3.67 17.80 27.68 0.17 80.93 0.00 0.00 0.00 0.00 0.00 0.00 0.80 0.38 0.05 5.78
avg-cpu: %user %nice %system %iowait %steal %idle
2.88 0.00 1.28 0.16 0.00 95.68
Device r/s rMB/s rrqm/s %rrqm r_await rareq-sz w/s wMB/s wrqm/s %wrqm w_await wareq-sz d/s dMB/s drqm/s %drqm d_await dareq-sz f/s f_await aqu-sz %util
nvme0n1 1.40 0.03 0.00 0.00 5.79 25.14 1.40 0.02 0.00 0.00 0.86 12.29 0.00 0.00 0.00 0.00 0.00 0.00 0.70 0.71 0.01 0.95
nvme2n1 0.30 0.10 0.70 70.00 7.00 346.67 1.40 0.02 0.00 0.00 1.64 12.29 0.00 0.00 0.00 0.00 0.00 0.00 0.70 1.29 0.01 0.44
nvme3n1 0.40 0.00 0.00 0.00 6.75 8.00 1.60 0.02 0.00 0.00 0.94 12.00 0.00 0.00 0.00 0.00 0.00 0.00 0.80 1.00 0.00 0.44
nvme5n1 0.70 0.12 0.70 50.00 6.86 170.29 1.60 0.02 0.00 0.00 1.62 12.00 0.00 0.00 0.00 0.00 0.00 0.00 0.80 1.50 0.01 0.72
home_disks 2.80 0.26 1.40 33.33 6.32 93.43 6.00 0.07 0.00 0.00 1.27 12.13 0.00 0.00 0.00 0.00 0.00 0.00 3.00 1.13 0.03 0.64
Summary table of above output showing the fixed calculations:
| Report | Disk %util (nvme0n1, nvme2n1, nvme3n1, nvme5n1) | Sum | Expected (sum / 4) | Shown on home_disks |
|---|---|---|---|---|
| 1 | 2.52, 2.05, 2.47, 1.98 | 9.02 | 2.255 | 2.25 |
| 2 | 2.42, 0.87, 1.23, 1.16 | 5.68 | 1.42 | 1.42 |
| 3 | 1.59, 1.16, 19.13, 1.23 | 23.11 | 5.78 | 5.78 |
| 4 | 0.95, 0.44, 0.44, 0.72 | 2.55 | 0.64 | 0.64 |
I hope this helps, thanks for creating/maintaining this software. Cheers
- 主要言語
- C
- スター
- 3.4k
- フォーク
- 490
- 平均マージ
- 3日 14時間
- マージ済み PR(30日)
- 5
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysstat/sysstat のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 40/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
sar: duplicate interrupts when using SUM while reading interrupts in 390x arch (from `/proc/interrupts`)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
sysstat/sysstat の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
libsdl-org/SDL#16444 ·
メンテナーはふだん 1 日以内に返信
-
bug Component component: net
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
RT-Thread/rt-thread#11852 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
MiSTer-devel/ao486_MiSTer#243 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
siderolabs/pkgs#1710 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
qmk/qmk_firmware#26498 ·
メンテナーはふだん 1 日以内に返信