From: Ian Rogers <irogers@google.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>,
Kan Liang <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
Xu Yang <xu.yang_2@nxp.com>, Howard Chu <howardchu95@gmail.com>,
"Dr. David Alan Gilbert" <linux@treblig.org>,
Levi Yun <yeoreum.yun@arm.com>, Andi Kleen <ak@linux.intel.com>,
Thomas Richter <tmricht@linux.ibm.com>,
Weilin Wang <weilin.wang@intel.com>,
Tiezhu Yang <yangtiezhu@loongson.cn>,
Gautam Menghani <gautam@linux.ibm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 07/12] perf expr: Accumulate rather than replace in the context counts
Date: Wed, 9 Jul 2025 14:40:24 -0700 [thread overview]
Message-ID: <20250709214029.1769089-8-irogers@google.com> (raw)
In-Reply-To: <20250709214029.1769089-1-irogers@google.com>
Metrics will fill in the context to have mappings from an event to a
count. When counts are added they replace existing mappings which
generally shouldn't exist with aggregation. Switch to accumulating to
better support cases where perf stat's aggregation isn't used and we
may see a counter more than once.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/expr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index 6413537442aa..ca70a14c7cdf 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -166,8 +166,12 @@ int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *id,
data_ptr->kind = EXPR_ID_DATA__VALUE;
ret = hashmap__set(ctx->ids, id, data_ptr, &old_key, &old_data);
- if (ret)
+ if (ret) {
free(data_ptr);
+ } else if (old_data) {
+ data_ptr->val.val += old_data->val.val;
+ data_ptr->val.source_count += old_data->val.source_count;
+ }
free(old_key);
free(old_data);
return ret;
--
2.50.0.727.gbf7dc18ff4-goog
next prev parent reply other threads:[~2025-07-09 21:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 21:40 [PATCH v1 00/12] Python motivated fixes and cleanup Ian Rogers
2025-07-09 21:40 ` [PATCH v1 01/12] perf hwmon_pmu: Avoid shortening hwmon PMU name Ian Rogers
2025-07-09 21:40 ` [PATCH v1 02/12] perf parse-events: Minor tidy up of event_type helper Ian Rogers
2025-07-09 21:40 ` [PATCH v1 03/12] perf spark: Fix includes and add SPDX Ian Rogers
2025-07-09 21:40 ` [PATCH v1 04/12] perf pmu: Tolerate failure to read the type for wellknown PMUs Ian Rogers
2025-07-09 21:40 ` [PATCH v1 05/12] perf metricgroup: Factor out for-each function and move out printing Ian Rogers
2025-07-09 21:40 ` [PATCH v1 06/12] perf stat: Move metric list from config to evlist Ian Rogers
2025-07-09 21:40 ` Ian Rogers [this message]
2025-07-09 21:40 ` [PATCH v1 08/12] perf jevents: If the long_desc and desc are identical then drop the long_desc Ian Rogers
2025-07-09 21:40 ` [PATCH v1 09/12] perf python: In str(evsel) use the evsel__pmu_name helper Ian Rogers
2025-07-09 21:40 ` [PATCH v1 10/12] perf python: Fix thread check in pyrf_evsel__read Ian Rogers
2025-07-09 21:40 ` [PATCH v1 11/12] perf python: Correct pyrf_evsel__read for tool PMUs Ian Rogers
2025-07-09 21:40 ` [PATCH v1 12/12] perf python: Improve leader copying from evlist Ian Rogers
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=20250709214029.1769089-8-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=gautam@linux.ibm.com \
--cc=howardchu95@gmail.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux@treblig.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tmricht@linux.ibm.com \
--cc=weilin.wang@intel.com \
--cc=xu.yang_2@nxp.com \
--cc=yangtiezhu@loongson.cn \
--cc=yeoreum.yun@arm.com \
/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®