Skip to content

Commit f745817

Browse files
namhyungacmel
authored andcommitted
perf mem: Add 'dtlb' output field
This is a breakdown of perf_mem_data_src.mem_dtlb values. It assumes PMU drivers would set PERF_MEM_TLB_HIT bit with an appropriate level. And having PERF_MEM_TLB_MISS means that it failed to find one in any levels of TLB. For now, it doesn't use PERF_MEM_TLB_{WK,OS} bits. Also it seems Intel machines don't distinguish L1 or L2 precisely. So I added ANY_HIT (printed as "L?-Hit") to handle the case. $ perf mem report -F overhead,dtlb,dso --stdio ... # --- D-TLB ---- # Overhead L?-Hit Miss Shared Object # ........ .............. ................. # 67.03% 99.5% 0.5% [unknown] 31.23% 99.2% 0.8% [kernel.kallsyms] 1.08% 97.8% 2.2% [i915] 0.36% 100.0% 0.0% [JIT] tid 6853 0.12% 100.0% 0.0% [drm] 0.05% 100.0% 0.0% [drm_kms_helper] 0.05% 100.0% 0.0% [ext4] 0.02% 100.0% 0.0% [aesni_intel] 0.02% 100.0% 0.0% [crc32c_intel] 0.02% 100.0% 0.0% [dm_crypt] ... Committer testing: # perf report --header | grep cpudesc # cpudesc : AMD Ryzen 9 9950X3D 16-Core Processor # perf mem report -F overhead,dtlb,dso --stdio | head -20 # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 2K of event 'cycles:P' # Total weight : 2637 # Sort order : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked,blocked,local_ins_lat,local_p_stage_cyc # # ---------- D-TLB ----------- # Overhead L1-Hit L2-Hit Miss Other Shared Object # ........ ............................ ................................. # 77.47% 18.4% 0.1% 0.6% 80.9% [kernel.kallsyms] 5.61% 36.5% 0.7% 1.4% 61.5% libxul.so 2.77% 39.7% 0.0% 12.3% 47.9% libc.so.6 2.01% 34.0% 1.9% 1.9% 62.3% libglib-2.0.so.0.8400.1 1.93% 31.4% 2.0% 2.0% 64.7% [amdgpu] 1.63% 48.8% 0.0% 0.0% 51.2% [JIT] tid 60168 1.14% 3.3% 0.0% 0.0% 96.7% [vdso] # 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 5e424a0 commit f745817

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

tools/perf/ui/browsers/hists.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,7 @@ __HPP_COLOR_MEM_STAT_FN(op, OP)
12881288
__HPP_COLOR_MEM_STAT_FN(cache, CACHE)
12891289
__HPP_COLOR_MEM_STAT_FN(memory, MEMORY)
12901290
__HPP_COLOR_MEM_STAT_FN(snoop, SNOOP)
1291+
__HPP_COLOR_MEM_STAT_FN(dtlb, DTLB)
12911292

12921293
#undef __HPP_COLOR_PERCENT_FN
12931294
#undef __HPP_COLOR_ACC_PERCENT_FN
@@ -1319,6 +1320,8 @@ void hist_browser__init_hpp(void)
13191320
hist_browser__hpp_color_mem_stat_memory;
13201321
perf_hpp__format[PERF_HPP__MEM_STAT_SNOOP].color =
13211322
hist_browser__hpp_color_mem_stat_snoop;
1323+
perf_hpp__format[PERF_HPP__MEM_STAT_DTLB].color =
1324+
hist_browser__hpp_color_mem_stat_dtlb;
13221325

13231326
res_sample_init();
13241327
}

tools/perf/ui/hist.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ static enum mem_stat_type hpp__mem_stat_type(struct perf_hpp_fmt *fmt)
354354
return PERF_MEM_STAT_MEMORY;
355355
case PERF_HPP__MEM_STAT_SNOOP:
356356
return PERF_MEM_STAT_SNOOP;
357+
case PERF_HPP__MEM_STAT_DTLB:
358+
return PERF_MEM_STAT_DTLB;
357359
default:
358360
break;
359361
}
@@ -653,6 +655,7 @@ HPP_MEM_STAT_FNS(op, OP)
653655
HPP_MEM_STAT_FNS(cache, CACHE)
654656
HPP_MEM_STAT_FNS(memory, MEMORY)
655657
HPP_MEM_STAT_FNS(snoop, SNOOP)
658+
HPP_MEM_STAT_FNS(dtlb, DTLB)
656659

657660
static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
658661
struct hist_entry *a __maybe_unused,
@@ -760,6 +763,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
760763
HPP__MEM_STAT_PRINT_FNS("Cache", cache, CACHE),
761764
HPP__MEM_STAT_PRINT_FNS("Memory", memory, MEMORY),
762765
HPP__MEM_STAT_PRINT_FNS("Snoop", snoop, SNOOP),
766+
HPP__MEM_STAT_PRINT_FNS("D-TLB", dtlb, DTLB),
763767
};
764768

765769
struct perf_hpp_list perf_hpp_list = {
@@ -1118,6 +1122,7 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
11181122
case PERF_HPP__MEM_STAT_CACHE:
11191123
case PERF_HPP__MEM_STAT_MEMORY:
11201124
case PERF_HPP__MEM_STAT_SNOOP:
1125+
case PERF_HPP__MEM_STAT_DTLB:
11211126
fmt->len = MEM_STAT_LEN * MEM_STAT_PRINT_LEN;
11221127
break;
11231128

tools/perf/util/hist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ enum {
592592
PERF_HPP__MEM_STAT_CACHE,
593593
PERF_HPP__MEM_STAT_MEMORY,
594594
PERF_HPP__MEM_STAT_SNOOP,
595+
PERF_HPP__MEM_STAT_DTLB,
595596

596597
PERF_HPP__MAX_INDEX
597598
};

tools/perf/util/mem-events.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,19 @@ int mem_stat_index(const enum mem_stat_type mst, const u64 val)
868868
default:
869869
return MEM_STAT_SNOOP_OTHER;
870870
}
871+
case PERF_MEM_STAT_DTLB:
872+
switch (src.mem_dtlb) {
873+
case PERF_MEM_TLB_L1 | PERF_MEM_TLB_HIT:
874+
return MEM_STAT_DTLB_L1_HIT;
875+
case PERF_MEM_TLB_L2 | PERF_MEM_TLB_HIT:
876+
return MEM_STAT_DTLB_L2_HIT;
877+
case PERF_MEM_TLB_L1 | PERF_MEM_TLB_L2 | PERF_MEM_TLB_HIT:
878+
return MEM_STAT_DTLB_ANY_HIT;
879+
default:
880+
if (src.mem_dtlb & PERF_MEM_TLB_MISS)
881+
return MEM_STAT_DTLB_MISS;
882+
return MEM_STAT_DTLB_OTHER;
883+
}
871884
default:
872885
break;
873886
}
@@ -942,6 +955,20 @@ const char *mem_stat_name(const enum mem_stat_type mst, const int idx)
942955
default:
943956
return "Other";
944957
}
958+
case PERF_MEM_STAT_DTLB:
959+
switch (idx) {
960+
case MEM_STAT_DTLB_L1_HIT:
961+
return "L1-Hit";
962+
case MEM_STAT_DTLB_L2_HIT:
963+
return "L2-Hit";
964+
case MEM_STAT_DTLB_ANY_HIT:
965+
return "L?-Hit";
966+
case MEM_STAT_DTLB_MISS:
967+
return "Miss";
968+
case MEM_STAT_DTLB_OTHER:
969+
default:
970+
return "Other";
971+
}
945972
default:
946973
break;
947974
}

tools/perf/util/mem-events.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ enum mem_stat_type {
9494
PERF_MEM_STAT_CACHE,
9595
PERF_MEM_STAT_MEMORY,
9696
PERF_MEM_STAT_SNOOP,
97+
PERF_MEM_STAT_DTLB,
9798
};
9899

99100
#define MEM_STAT_PRINT_LEN 7 /* 1 space + 5 digits + 1 percent sign */
@@ -134,6 +135,14 @@ enum mem_stat_snoop {
134135
MEM_STAT_SNOOP_OTHER,
135136
};
136137

138+
enum mem_stat_dtlb {
139+
MEM_STAT_DTLB_L1_HIT,
140+
MEM_STAT_DTLB_L2_HIT,
141+
MEM_STAT_DTLB_ANY_HIT,
142+
MEM_STAT_DTLB_MISS,
143+
MEM_STAT_DTLB_OTHER,
144+
};
145+
137146
int mem_stat_index(const enum mem_stat_type mst, const u64 data_src);
138147
const char *mem_stat_name(const enum mem_stat_type mst, const int idx);
139148

tools/perf/util/sort.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,7 @@ static struct hpp_dimension hpp_sort_dimensions[] = {
26272627
DIM_MEM(PERF_HPP__MEM_STAT_CACHE, "cache"),
26282628
DIM_MEM(PERF_HPP__MEM_STAT_MEMORY, "memory"),
26292629
DIM_MEM(PERF_HPP__MEM_STAT_SNOOP, "snoop"),
2630+
DIM_MEM(PERF_HPP__MEM_STAT_DTLB, "dtlb"),
26302631
};
26312632

26322633
#undef DIM_MEM

0 commit comments

Comments
 (0)