* [PATCH] perf iostat: Do not compute interval deltas a second time
@ 2026-11-05 8:04 lirongqing
2026-11-05 8:13 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-11-05 8:04 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark, Li RongQing,
linux-perf-users, linux-kernel
From: Li RongQing <lirongqing@baidu.com>
process_counter_values() now computes deltas directly in evsel->counts
for global aggregation too. It saves the current cumulative raw count in
prev_raw_counts before iostat prints the interval.
Subtracting prev_raw_counts again can therefore underflow the count.
Worse, replacing the saved raw count with the interval delta corrupts
the baseline used to calculate the next interval.
Use the already computed delta and leave prev_raw_counts untouched.
Fixes: f976bc6b6bfc ("perf stat: Aggregate events using evsel->stats->aggr")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
tools/perf/arch/x86/util/iostat.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c
index 0cf0f93..fac6b4a 100644
--- a/tools/perf/arch/x86/util/iostat.c
+++ b/tools/perf/arch/x86/util/iostat.c
@@ -434,20 +434,12 @@ void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel,
struct perf_stat_output_ctx *out)
{
double iostat_value = 0;
- u64 prev_count_val = 0;
const char *iostat_metric = iostat_metric_by_idx(evsel->core.idx);
u8 die = ((struct iio_root_port *)evsel->priv)->die;
struct perf_counts_values *count = perf_counts(evsel->counts, die, 0);
if (count && count->run && count->ena) {
- if (evsel->prev_raw_counts && !out->force_header) {
- struct perf_counts_values *prev_count =
- perf_counts(evsel->prev_raw_counts, die, 0);
-
- prev_count_val = prev_count->val;
- prev_count->val = count->val;
- }
- iostat_value = (count->val - prev_count_val) /
+ iostat_value = count->val /
((double) count->run / count->ena);
}
out->print_metric(config, out->ctx, METRIC_THRESHOLD_UNKNOWN, "%8.0f", iostat_metric,
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf iostat: Do not compute interval deltas a second time
2026-11-05 8:04 [PATCH] perf iostat: Do not compute interval deltas a second time lirongqing
@ 2026-11-05 8:13 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-05 8:13 UTC (permalink / raw)
To: lirongqing, linux-perf-users
> From: Li RongQing <lirongqing@baidu.com>
>
> process_counter_values() now computes deltas directly in evsel->counts
> for global aggregation too. It saves the current cumulative raw count in
> prev_raw_counts before iostat prints the interval.
>
> Subtracting prev_raw_counts again can therefore underflow the count.
> Worse, replacing the saved raw count with the interval delta corrupts
> the baseline used to calculate the next interval.
>
> Use the already computed delta and leave prev_raw_counts untouched.
>
> Fixes: f976bc6b6bfc ("perf stat: Aggregate events using evsel->stats->aggr")
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105080429.2472-1-lirongqing@baidu.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 8:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 8:04 [PATCH] perf iostat: Do not compute interval deltas a second time lirongqing
2026-11-05 8:13 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox