Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf expr: Accumulate rather than replace in the context counts

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>

authored by

Ian Rogers and committed by
Namhyung Kim
3787cdaf faebee18

+5 -1
+5 -1
tools/perf/util/expr.c
··· 166 166 data_ptr->kind = EXPR_ID_DATA__VALUE; 167 167 168 168 ret = hashmap__set(ctx->ids, id, data_ptr, &old_key, &old_data); 169 - if (ret) 169 + if (ret) { 170 170 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 + } 171 175 free(old_key); 172 176 free(old_data); 173 177 return ret;