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

perf mem: Add 'snoop' output field

This is a breakdown of perf_mem_data_src.mem_snoop values. For now, it
doesn't use mem_snoopx values like FWD and PEER.

$ perf mem report -F overhead,snoop,comm --stdio
...
# ---------- Snoop -----------
# Overhead Hit HitM Miss Other Command
# ........ ............................ ...............
#
34.24% 0.6% 0.0% 0.0% 99.4% gnome-shell
12.02% 1.0% 0.0% 0.0% 99.0% chrome
9.32% 1.0% 0.0% 0.3% 98.7% Isolated Web Co
6.85% 1.0% 0.3% 0.0% 98.6% swapper
6.30% 0.8% 0.8% 0.0% 98.5% Xorg
3.02% 2.4% 0.0% 0.0% 97.6% VizCompositorTh
2.35% 0.0% 0.0% 0.0% 100.0% firefox-esr
2.04% 0.0% 0.0% 0.0% 100.0% JS Helper
1.51% 3.2% 0.0% 0.0% 96.8% threaded-ml
1.44% 0.0% 0.0% 0.0% 100.0% AudioIP~allback
...

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lore.kernel.org/r/20250430205548.789750-11-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
5e424a01 abe4dc24

+41
+3
tools/perf/ui/browsers/hists.c
··· 1287 1287 __HPP_COLOR_MEM_STAT_FN(op, OP) 1288 1288 __HPP_COLOR_MEM_STAT_FN(cache, CACHE) 1289 1289 __HPP_COLOR_MEM_STAT_FN(memory, MEMORY) 1290 + __HPP_COLOR_MEM_STAT_FN(snoop, SNOOP) 1290 1291 1291 1292 #undef __HPP_COLOR_PERCENT_FN 1292 1293 #undef __HPP_COLOR_ACC_PERCENT_FN ··· 1317 1316 hist_browser__hpp_color_mem_stat_cache; 1318 1317 perf_hpp__format[PERF_HPP__MEM_STAT_MEMORY].color = 1319 1318 hist_browser__hpp_color_mem_stat_memory; 1319 + perf_hpp__format[PERF_HPP__MEM_STAT_SNOOP].color = 1320 + hist_browser__hpp_color_mem_stat_snoop; 1320 1321 1321 1322 res_sample_init(); 1322 1323 }
+5
tools/perf/ui/hist.c
··· 352 352 return PERF_MEM_STAT_CACHE; 353 353 case PERF_HPP__MEM_STAT_MEMORY: 354 354 return PERF_MEM_STAT_MEMORY; 355 + case PERF_HPP__MEM_STAT_SNOOP: 356 + return PERF_MEM_STAT_SNOOP; 355 357 default: 356 358 break; 357 359 } ··· 652 650 HPP_MEM_STAT_FNS(op, OP) 653 651 HPP_MEM_STAT_FNS(cache, CACHE) 654 652 HPP_MEM_STAT_FNS(memory, MEMORY) 653 + HPP_MEM_STAT_FNS(snoop, SNOOP) 655 654 656 655 static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused, 657 656 struct hist_entry *a __maybe_unused, ··· 759 756 HPP__MEM_STAT_PRINT_FNS("Mem Op", op, OP), 760 757 HPP__MEM_STAT_PRINT_FNS("Cache", cache, CACHE), 761 758 HPP__MEM_STAT_PRINT_FNS("Memory", memory, MEMORY), 759 + HPP__MEM_STAT_PRINT_FNS("Snoop", snoop, SNOOP), 762 760 }; 763 761 764 762 struct perf_hpp_list perf_hpp_list = { ··· 1117 1113 case PERF_HPP__MEM_STAT_OP: 1118 1114 case PERF_HPP__MEM_STAT_CACHE: 1119 1115 case PERF_HPP__MEM_STAT_MEMORY: 1116 + case PERF_HPP__MEM_STAT_SNOOP: 1120 1117 fmt->len = MEM_STAT_LEN * MEM_STAT_PRINT_LEN; 1121 1118 break; 1122 1119
+1
tools/perf/util/hist.h
··· 591 591 PERF_HPP__MEM_STAT_OP, 592 592 PERF_HPP__MEM_STAT_CACHE, 593 593 PERF_HPP__MEM_STAT_MEMORY, 594 + PERF_HPP__MEM_STAT_SNOOP, 594 595 595 596 PERF_HPP__MAX_INDEX 596 597 };
+23
tools/perf/util/mem-events.c
··· 857 857 default: 858 858 return MEM_STAT_MEMORY_OTHER; 859 859 } 860 + case PERF_MEM_STAT_SNOOP: 861 + switch (src.mem_snoop) { 862 + case PERF_MEM_SNOOP_HIT: 863 + return MEM_STAT_SNOOP_HIT; 864 + case PERF_MEM_SNOOP_HITM: 865 + return MEM_STAT_SNOOP_HITM; 866 + case PERF_MEM_SNOOP_MISS: 867 + return MEM_STAT_SNOOP_MISS; 868 + default: 869 + return MEM_STAT_SNOOP_OTHER; 870 + } 860 871 default: 861 872 break; 862 873 } ··· 927 916 case MEM_STAT_MEMORY_PMEM: 928 917 return "PMEM"; 929 918 case MEM_STAT_MEMORY_OTHER: 919 + default: 920 + return "Other"; 921 + } 922 + case PERF_MEM_STAT_SNOOP: 923 + switch (idx) { 924 + case MEM_STAT_SNOOP_HIT: 925 + return "Hit"; 926 + case MEM_STAT_SNOOP_HITM: 927 + return "HitM"; 928 + case MEM_STAT_SNOOP_MISS: 929 + return "Miss"; 930 + case MEM_STAT_SNOOP_OTHER: 930 931 default: 931 932 return "Other"; 932 933 }
+8
tools/perf/util/mem-events.h
··· 93 93 PERF_MEM_STAT_OP, 94 94 PERF_MEM_STAT_CACHE, 95 95 PERF_MEM_STAT_MEMORY, 96 + PERF_MEM_STAT_SNOOP, 96 97 }; 97 98 98 99 #define MEM_STAT_PRINT_LEN 7 /* 1 space + 5 digits + 1 percent sign */ ··· 125 124 MEM_STAT_MEMORY_IO, 126 125 MEM_STAT_MEMORY_PMEM, 127 126 MEM_STAT_MEMORY_OTHER, 127 + }; 128 + 129 + enum mem_stat_snoop { 130 + MEM_STAT_SNOOP_HIT, 131 + MEM_STAT_SNOOP_HITM, 132 + MEM_STAT_SNOOP_MISS, 133 + MEM_STAT_SNOOP_OTHER, 128 134 }; 129 135 130 136 int mem_stat_index(const enum mem_stat_type mst, const u64 data_src);
+1
tools/perf/util/sort.c
··· 2626 2626 DIM_MEM(PERF_HPP__MEM_STAT_OP, "op"), 2627 2627 DIM_MEM(PERF_HPP__MEM_STAT_CACHE, "cache"), 2628 2628 DIM_MEM(PERF_HPP__MEM_STAT_MEMORY, "memory"), 2629 + DIM_MEM(PERF_HPP__MEM_STAT_SNOOP, "snoop"), 2629 2630 }; 2630 2631 2631 2632 #undef DIM_MEM