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

perf bench uprobe: Add uretprobe variant of uprobe benchmarks

Name benchmarks with _ret at the end to avoid creating a new set of
benchmarks.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrei Vagin <avagin@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kees Kook <keescook@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240406040911.1603801-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
988052f4 459fee7b

+37 -3
+2
tools/perf/bench/bench.h
··· 46 46 int bench_uprobe_baseline(int argc, const char **argv); 47 47 int bench_uprobe_empty(int argc, const char **argv); 48 48 int bench_uprobe_trace_printk(int argc, const char **argv); 49 + int bench_uprobe_empty_ret(int argc, const char **argv); 50 + int bench_uprobe_trace_printk_ret(int argc, const char **argv); 49 51 int bench_pmu_scan(int argc, const char **argv); 50 52 51 53 #define BENCH_FORMAT_DEFAULT_STR "default"
+17 -3
tools/perf/bench/uprobe.c
··· 26 26 static int loops = LOOPS_DEFAULT; 27 27 28 28 enum bench_uprobe { 29 - BENCH_UPROBE__BASELINE, 30 - BENCH_UPROBE__EMPTY, 31 - BENCH_UPROBE__TRACE_PRINTK, 29 + BENCH_UPROBE__BASELINE, 30 + BENCH_UPROBE__EMPTY, 31 + BENCH_UPROBE__TRACE_PRINTK, 32 + BENCH_UPROBE__EMPTY_RET, 33 + BENCH_UPROBE__TRACE_PRINTK_RET, 32 34 }; 33 35 34 36 static const struct option options[] = { ··· 83 81 case BENCH_UPROBE__BASELINE: break; 84 82 case BENCH_UPROBE__EMPTY: bench_uprobe__attach_uprobe(empty); break; 85 83 case BENCH_UPROBE__TRACE_PRINTK: bench_uprobe__attach_uprobe(trace_printk); break; 84 + case BENCH_UPROBE__EMPTY_RET: bench_uprobe__attach_uprobe(empty_ret); break; 85 + case BENCH_UPROBE__TRACE_PRINTK_RET: bench_uprobe__attach_uprobe(trace_printk_ret); break; 86 86 default: 87 87 fprintf(stderr, "Invalid bench: %d\n", bench); 88 88 goto cleanup; ··· 200 196 int bench_uprobe_trace_printk(int argc, const char **argv) 201 197 { 202 198 return bench_uprobe(argc, argv, BENCH_UPROBE__TRACE_PRINTK); 199 + } 200 + 201 + int bench_uprobe_empty_ret(int argc, const char **argv) 202 + { 203 + return bench_uprobe(argc, argv, BENCH_UPROBE__EMPTY_RET); 204 + } 205 + 206 + int bench_uprobe_trace_printk_ret(int argc, const char **argv) 207 + { 208 + return bench_uprobe(argc, argv, BENCH_UPROBE__TRACE_PRINTK_RET); 203 209 }
+2
tools/perf/builtin-bench.c
··· 109 109 { "baseline", "Baseline libc usleep(1000) call", bench_uprobe_baseline, }, 110 110 { "empty", "Attach empty BPF prog to uprobe on usleep, system wide", bench_uprobe_empty, }, 111 111 { "trace_printk", "Attach trace_printk BPF prog to uprobe on usleep syswide", bench_uprobe_trace_printk, }, 112 + { "empty_ret", "Attach empty BPF prog to uretprobe on usleep, system wide", bench_uprobe_empty_ret, }, 113 + { "trace_printk_ret", "Attach trace_printk BPF prog to uretprobe on usleep syswide", bench_uprobe_trace_printk_ret,}, 112 114 { NULL, NULL, NULL }, 113 115 }; 114 116
+16
tools/perf/util/bpf_skel/bench_uprobe.bpf.c
··· 4 4 #include <bpf/bpf_tracing.h> 5 5 6 6 unsigned int nr_uprobes; 7 + unsigned int nr_uretprobes; 7 8 8 9 SEC("uprobe") 9 10 int BPF_UPROBE(empty) ··· 18 17 char fmt[] = "perf bench uprobe %u"; 19 18 20 19 bpf_trace_printk(fmt, sizeof(fmt), ++nr_uprobes); 20 + return 0; 21 + } 22 + 23 + SEC("uretprobe") 24 + int BPF_URETPROBE(empty_ret) 25 + { 26 + return 0; 27 + } 28 + 29 + SEC("uretprobe") 30 + int BPF_URETPROBE(trace_printk_ret) 31 + { 32 + char fmt[] = "perf bench uretprobe %u"; 33 + 34 + bpf_trace_printk(fmt, sizeof(fmt), ++nr_uretprobes); 21 35 return 0; 22 36 } 23 37