Skip to content

Commit 5e424a0

Browse files
namhyungacmel
authored andcommitted
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 <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent abe4dc2 commit 5e424a0

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

tools/perf/ui/browsers/hists.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ __HPP_COLOR_ACC_PERCENT_FN(latency_acc, latency, PERF_HPP_FMT_TYPE__LATENCY)
12871287
__HPP_COLOR_MEM_STAT_FN(op, OP)
12881288
__HPP_COLOR_MEM_STAT_FN(cache, CACHE)
12891289
__HPP_COLOR_MEM_STAT_FN(memory, MEMORY)
1290+
__HPP_COLOR_MEM_STAT_FN(snoop, SNOOP)
12901291

12911292
#undef __HPP_COLOR_PERCENT_FN
12921293
#undef __HPP_COLOR_ACC_PERCENT_FN
@@ -1316,6 +1317,8 @@ void hist_browser__init_hpp(void)
13161317
hist_browser__hpp_color_mem_stat_cache;
13171318
perf_hpp__format[PERF_HPP__MEM_STAT_MEMORY].color =
13181319
hist_browser__hpp_color_mem_stat_memory;
1320+
perf_hpp__format[PERF_HPP__MEM_STAT_SNOOP].color =
1321+
hist_browser__hpp_color_mem_stat_snoop;
13191322

13201323
res_sample_init();
13211324
}

tools/perf/ui/hist.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ static enum mem_stat_type hpp__mem_stat_type(struct perf_hpp_fmt *fmt)
352352
return PERF_MEM_STAT_CACHE;
353353
case PERF_HPP__MEM_STAT_MEMORY:
354354
return PERF_MEM_STAT_MEMORY;
355+
case PERF_HPP__MEM_STAT_SNOOP:
356+
return PERF_MEM_STAT_SNOOP;
355357
default:
356358
break;
357359
}
@@ -650,6 +652,7 @@ HPP_AVERAGE_FNS(weight3, weight3)
650652
HPP_MEM_STAT_FNS(op, OP)
651653
HPP_MEM_STAT_FNS(cache, CACHE)
652654
HPP_MEM_STAT_FNS(memory, MEMORY)
655+
HPP_MEM_STAT_FNS(snoop, SNOOP)
653656

654657
static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
655658
struct hist_entry *a __maybe_unused,
@@ -756,6 +759,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
756759
HPP__MEM_STAT_PRINT_FNS("Mem Op", op, OP),
757760
HPP__MEM_STAT_PRINT_FNS("Cache", cache, CACHE),
758761
HPP__MEM_STAT_PRINT_FNS("Memory", memory, MEMORY),
762+
HPP__MEM_STAT_PRINT_FNS("Snoop", snoop, SNOOP),
759763
};
760764

761765
struct perf_hpp_list perf_hpp_list = {
@@ -1113,6 +1117,7 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
11131117
case PERF_HPP__MEM_STAT_OP:
11141118
case PERF_HPP__MEM_STAT_CACHE:
11151119
case PERF_HPP__MEM_STAT_MEMORY:
1120+
case PERF_HPP__MEM_STAT_SNOOP:
11161121
fmt->len = MEM_STAT_LEN * MEM_STAT_PRINT_LEN;
11171122
break;
11181123

tools/perf/util/hist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ enum {
591591
PERF_HPP__MEM_STAT_OP,
592592
PERF_HPP__MEM_STAT_CACHE,
593593
PERF_HPP__MEM_STAT_MEMORY,
594+
PERF_HPP__MEM_STAT_SNOOP,
594595

595596
PERF_HPP__MAX_INDEX
596597
};

tools/perf/util/mem-events.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,17 @@ int mem_stat_index(const enum mem_stat_type mst, const u64 val)
857857
default:
858858
return MEM_STAT_MEMORY_OTHER;
859859
}
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+
}
860871
default:
861872
break;
862873
}
@@ -919,6 +930,18 @@ const char *mem_stat_name(const enum mem_stat_type mst, const int idx)
919930
default:
920931
return "Other";
921932
}
933+
case PERF_MEM_STAT_SNOOP:
934+
switch (idx) {
935+
case MEM_STAT_SNOOP_HIT:
936+
return "Hit";
937+
case MEM_STAT_SNOOP_HITM:
938+
return "HitM";
939+
case MEM_STAT_SNOOP_MISS:
940+
return "Miss";
941+
case MEM_STAT_SNOOP_OTHER:
942+
default:
943+
return "Other";
944+
}
922945
default:
923946
break;
924947
}

tools/perf/util/mem-events.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum mem_stat_type {
9393
PERF_MEM_STAT_OP,
9494
PERF_MEM_STAT_CACHE,
9595
PERF_MEM_STAT_MEMORY,
96+
PERF_MEM_STAT_SNOOP,
9697
};
9798

9899
#define MEM_STAT_PRINT_LEN 7 /* 1 space + 5 digits + 1 percent sign */
@@ -126,6 +127,13 @@ enum mem_stat_memory {
126127
MEM_STAT_MEMORY_OTHER,
127128
};
128129

130+
enum mem_stat_snoop {
131+
MEM_STAT_SNOOP_HIT,
132+
MEM_STAT_SNOOP_HITM,
133+
MEM_STAT_SNOOP_MISS,
134+
MEM_STAT_SNOOP_OTHER,
135+
};
136+
129137
int mem_stat_index(const enum mem_stat_type mst, const u64 data_src);
130138
const char *mem_stat_name(const enum mem_stat_type mst, const int idx);
131139

tools/perf/util/sort.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,7 @@ static struct hpp_dimension hpp_sort_dimensions[] = {
26262626
DIM_MEM(PERF_HPP__MEM_STAT_OP, "op"),
26272627
DIM_MEM(PERF_HPP__MEM_STAT_CACHE, "cache"),
26282628
DIM_MEM(PERF_HPP__MEM_STAT_MEMORY, "memory"),
2629+
DIM_MEM(PERF_HPP__MEM_STAT_SNOOP, "snoop"),
26292630
};
26302631

26312632
#undef DIM_MEM

0 commit comments

Comments
 (0)