Skip to content

Commit 450d060

Browse files
yonghong-songborkmann
authored andcommitted
bpftool: Add {i,d}tlb_misses support for bpftool profile
Commit 47c09d6("bpftool: Introduce "prog profile" command") introduced "bpftool prog profile" command which can be used to profile bpf program with metrics like # of instructions, This patch added support for itlb_misses and dtlb_misses. During an internal bpf program performance evaluation, I found these two metrics are also very useful. The following is an example output: $ bpftool prog profile id 324 duration 3 cycles itlb_misses 1885029 run_cnt 5134686073 cycles 306893 itlb_misses $ bpftool prog profile id 324 duration 3 cycles dtlb_misses 1827382 run_cnt 4943593648 cycles 5975636 dtlb_misses $ bpftool prog profile id 324 duration 3 cycles llc_misses 1836527 run_cnt 5019612972 cycles 4161041 llc_misses From the above, we can see quite some dtlb misses, 3 dtlb misses perf prog run. This might be something worth further investigation. Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 4e99d11 commit 450d060

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tools/bpf/bpftool/prog.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,34 @@ struct profile_metric {
17171717
.ratio_desc = "LLC misses per million insns",
17181718
.ratio_mul = 1e6,
17191719
},
1720+
{
1721+
.name = "itlb_misses",
1722+
.attr = {
1723+
.type = PERF_TYPE_HW_CACHE,
1724+
.config =
1725+
PERF_COUNT_HW_CACHE_ITLB |
1726+
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
1727+
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16),
1728+
.exclude_user = 1
1729+
},
1730+
.ratio_metric = 2,
1731+
.ratio_desc = "itlb misses per million insns",
1732+
.ratio_mul = 1e6,
1733+
},
1734+
{
1735+
.name = "dtlb_misses",
1736+
.attr = {
1737+
.type = PERF_TYPE_HW_CACHE,
1738+
.config =
1739+
PERF_COUNT_HW_CACHE_DTLB |
1740+
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
1741+
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16),
1742+
.exclude_user = 1
1743+
},
1744+
.ratio_metric = 2,
1745+
.ratio_desc = "dtlb misses per million insns",
1746+
.ratio_mul = 1e6,
1747+
},
17201748
};
17211749

17221750
static __u64 profile_total_count;
@@ -2109,7 +2137,7 @@ static int do_help(int argc, char **argv)
21092137
" struct_ops | fentry | fexit | freplace | sk_lookup }\n"
21102138
" ATTACH_TYPE := { msg_verdict | stream_verdict | stream_parser |\n"
21112139
" flow_dissector }\n"
2112-
" METRIC := { cycles | instructions | l1d_loads | llc_misses }\n"
2140+
" METRIC := { cycles | instructions | l1d_loads | llc_misses | itlb_misses | dtlb_misses }\n"
21132141
" " HELP_SPEC_OPTIONS "\n"
21142142
"",
21152143
bin_name, argv[-2]);

0 commit comments

Comments
 (0)