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>
This commit is contained in:
Namhyung Kim 2025-04-30 13:55:47 -07:00 committed by Arnaldo Carvalho de Melo
parent abe4dc24a8
commit 5e424a0178
6 changed files with 41 additions and 0 deletions

View File

@ -1287,6 +1287,7 @@ __HPP_COLOR_ACC_PERCENT_FN(latency_acc, latency, PERF_HPP_FMT_TYPE__LATENCY)
__HPP_COLOR_MEM_STAT_FN(op, OP)
__HPP_COLOR_MEM_STAT_FN(cache, CACHE)
__HPP_COLOR_MEM_STAT_FN(memory, MEMORY)
__HPP_COLOR_MEM_STAT_FN(snoop, SNOOP)
#undef __HPP_COLOR_PERCENT_FN
#undef __HPP_COLOR_ACC_PERCENT_FN
@ -1316,6 +1317,8 @@ void hist_browser__init_hpp(void)
hist_browser__hpp_color_mem_stat_cache;
perf_hpp__format[PERF_HPP__MEM_STAT_MEMORY].color =
hist_browser__hpp_color_mem_stat_memory;
perf_hpp__format[PERF_HPP__MEM_STAT_SNOOP].color =
hist_browser__hpp_color_mem_stat_snoop;
res_sample_init();
}

View File

@ -352,6 +352,8 @@ static enum mem_stat_type hpp__mem_stat_type(struct perf_hpp_fmt *fmt)
return PERF_MEM_STAT_CACHE;
case PERF_HPP__MEM_STAT_MEMORY:
return PERF_MEM_STAT_MEMORY;
case PERF_HPP__MEM_STAT_SNOOP:
return PERF_MEM_STAT_SNOOP;
default:
break;
}
@ -650,6 +652,7 @@ HPP_AVERAGE_FNS(weight3, weight3)
HPP_MEM_STAT_FNS(op, OP)
HPP_MEM_STAT_FNS(cache, CACHE)
HPP_MEM_STAT_FNS(memory, MEMORY)
HPP_MEM_STAT_FNS(snoop, SNOOP)
static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
struct hist_entry *a __maybe_unused,
@ -756,6 +759,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
HPP__MEM_STAT_PRINT_FNS("Mem Op", op, OP),
HPP__MEM_STAT_PRINT_FNS("Cache", cache, CACHE),
HPP__MEM_STAT_PRINT_FNS("Memory", memory, MEMORY),
HPP__MEM_STAT_PRINT_FNS("Snoop", snoop, SNOOP),
};
struct perf_hpp_list perf_hpp_list = {
@ -1113,6 +1117,7 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
case PERF_HPP__MEM_STAT_OP:
case PERF_HPP__MEM_STAT_CACHE:
case PERF_HPP__MEM_STAT_MEMORY:
case PERF_HPP__MEM_STAT_SNOOP:
fmt->len = MEM_STAT_LEN * MEM_STAT_PRINT_LEN;
break;

View File

@ -591,6 +591,7 @@ enum {
PERF_HPP__MEM_STAT_OP,
PERF_HPP__MEM_STAT_CACHE,
PERF_HPP__MEM_STAT_MEMORY,
PERF_HPP__MEM_STAT_SNOOP,
PERF_HPP__MAX_INDEX
};

View File

@ -857,6 +857,17 @@ int mem_stat_index(const enum mem_stat_type mst, const u64 val)
default:
return MEM_STAT_MEMORY_OTHER;
}
case PERF_MEM_STAT_SNOOP:
switch (src.mem_snoop) {
case PERF_MEM_SNOOP_HIT:
return MEM_STAT_SNOOP_HIT;
case PERF_MEM_SNOOP_HITM:
return MEM_STAT_SNOOP_HITM;
case PERF_MEM_SNOOP_MISS:
return MEM_STAT_SNOOP_MISS;
default:
return MEM_STAT_SNOOP_OTHER;
}
default:
break;
}
@ -919,6 +930,18 @@ const char *mem_stat_name(const enum mem_stat_type mst, const int idx)
default:
return "Other";
}
case PERF_MEM_STAT_SNOOP:
switch (idx) {
case MEM_STAT_SNOOP_HIT:
return "Hit";
case MEM_STAT_SNOOP_HITM:
return "HitM";
case MEM_STAT_SNOOP_MISS:
return "Miss";
case MEM_STAT_SNOOP_OTHER:
default:
return "Other";
}
default:
break;
}

View File

@ -93,6 +93,7 @@ enum mem_stat_type {
PERF_MEM_STAT_OP,
PERF_MEM_STAT_CACHE,
PERF_MEM_STAT_MEMORY,
PERF_MEM_STAT_SNOOP,
};
#define MEM_STAT_PRINT_LEN 7 /* 1 space + 5 digits + 1 percent sign */
@ -126,6 +127,13 @@ enum mem_stat_memory {
MEM_STAT_MEMORY_OTHER,
};
enum mem_stat_snoop {
MEM_STAT_SNOOP_HIT,
MEM_STAT_SNOOP_HITM,
MEM_STAT_SNOOP_MISS,
MEM_STAT_SNOOP_OTHER,
};
int mem_stat_index(const enum mem_stat_type mst, const u64 data_src);
const char *mem_stat_name(const enum mem_stat_type mst, const int idx);

View File

@ -2626,6 +2626,7 @@ static struct hpp_dimension hpp_sort_dimensions[] = {
DIM_MEM(PERF_HPP__MEM_STAT_OP, "op"),
DIM_MEM(PERF_HPP__MEM_STAT_CACHE, "cache"),
DIM_MEM(PERF_HPP__MEM_STAT_MEMORY, "memory"),
DIM_MEM(PERF_HPP__MEM_STAT_SNOOP, "snoop"),
};
#undef DIM_MEM