mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: lirongqing <lirongqing@baidu.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	Li RongQing <lirongqing@baidu.com>,
	<linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] perf iostat: Do not compute interval deltas a second time
Date: Thu, 5 Nov 2026 16:04:29 +0800	[thread overview]
Message-ID: <20261105080429.2472-1-lirongqing@baidu.com> (raw)

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


             reply	other threads:[~2026-11-05  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  8:04 lirongqing [this message]
2026-11-09  5:26 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261105080429.2472-1-lirongqing@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®