Skip to content

Commit a1625c2

Browse files
committed
perf expr: Accumulate rather than replace in the context counts
JIRA: https://issues.redhat.com/browse/RHEL-78198 upstream ======== commit 3787cda Author: Ian Rogers <irogers@google.com> Date: Thu Jul 10 16:51:20 2025 -0700 description =========== 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> Link: https://lore.kernel.org/r/20250710235126.1086011-8-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent e979fbf commit a1625c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/perf/util/expr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,12 @@ int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *id,
166166
data_ptr->kind = EXPR_ID_DATA__VALUE;
167167

168168
ret = hashmap__set(ctx->ids, id, data_ptr, &old_key, &old_data);
169-
if (ret)
169+
if (ret) {
170170
free(data_ptr);
171+
} else if (old_data) {
172+
data_ptr->val.val += old_data->val.val;
173+
data_ptr->val.source_count += old_data->val.source_count;
174+
}
171175
free(old_key);
172176
free(old_data);
173177
return ret;

0 commit comments

Comments
 (0)