Re: [PATCH bpf-next] selftests/bpf: add fexit and kretprobe triggering benchmarks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 08, 2024 at 04:51:24PM -0800, Andrii Nakryiko wrote:
> We already have kprobe and fentry benchmarks. Let's add kretprobe and
> fexit ones for completeness.
> 
> Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>

jirka

> ---
>  tools/testing/selftests/bpf/bench.c           |  4 +++
>  .../selftests/bpf/benchs/bench_trigger.c      | 32 +++++++++++++++++++
>  .../selftests/bpf/progs/trigger_bench.c       | 14 ++++++++
>  3 files changed, 50 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/bench.c b/tools/testing/selftests/bpf/bench.c
> index 60df99b6ac72..8e02645afe31 100644
> --- a/tools/testing/selftests/bpf/bench.c
> +++ b/tools/testing/selftests/bpf/bench.c
> @@ -495,7 +495,9 @@ extern const struct bench bench_trig_base;
>  extern const struct bench bench_trig_tp;
>  extern const struct bench bench_trig_rawtp;
>  extern const struct bench bench_trig_kprobe;
> +extern const struct bench bench_trig_kretprobe;
>  extern const struct bench bench_trig_fentry;
> +extern const struct bench bench_trig_fexit;
>  extern const struct bench bench_trig_fentry_sleep;
>  extern const struct bench bench_trig_fmodret;
>  extern const struct bench bench_trig_uprobe_base;
> @@ -539,7 +541,9 @@ static const struct bench *benchs[] = {
>  	&bench_trig_tp,
>  	&bench_trig_rawtp,
>  	&bench_trig_kprobe,
> +	&bench_trig_kretprobe,
>  	&bench_trig_fentry,
> +	&bench_trig_fexit,
>  	&bench_trig_fentry_sleep,
>  	&bench_trig_fmodret,
>  	&bench_trig_uprobe_base,
> diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c b/tools/testing/selftests/bpf/benchs/bench_trigger.c
> index 064a1ef7a6fb..3f24be9cfcb9 100644
> --- a/tools/testing/selftests/bpf/benchs/bench_trigger.c
> +++ b/tools/testing/selftests/bpf/benchs/bench_trigger.c
> @@ -85,12 +85,24 @@ static void trigger_kprobe_setup(void)
>  	attach_bpf(ctx.skel->progs.bench_trigger_kprobe);
>  }
>  
> +static void trigger_kretprobe_setup(void)
> +{
> +	setup_ctx();
> +	attach_bpf(ctx.skel->progs.bench_trigger_kretprobe);
> +}
> +
>  static void trigger_fentry_setup(void)
>  {
>  	setup_ctx();
>  	attach_bpf(ctx.skel->progs.bench_trigger_fentry);
>  }
>  
> +static void trigger_fexit_setup(void)
> +{
> +	setup_ctx();
> +	attach_bpf(ctx.skel->progs.bench_trigger_fexit);
> +}
> +
>  static void trigger_fentry_sleep_setup(void)
>  {
>  	setup_ctx();
> @@ -261,6 +273,16 @@ const struct bench bench_trig_kprobe = {
>  	.report_final = hits_drops_report_final,
>  };
>  
> +const struct bench bench_trig_kretprobe = {
> +	.name = "trig-kretprobe",
> +	.validate = trigger_validate,
> +	.setup = trigger_kretprobe_setup,
> +	.producer_thread = trigger_producer,
> +	.measure = trigger_measure,
> +	.report_progress = hits_drops_report_progress,
> +	.report_final = hits_drops_report_final,
> +};
> +
>  const struct bench bench_trig_fentry = {
>  	.name = "trig-fentry",
>  	.validate = trigger_validate,
> @@ -271,6 +293,16 @@ const struct bench bench_trig_fentry = {
>  	.report_final = hits_drops_report_final,
>  };
>  
> +const struct bench bench_trig_fexit = {
> +	.name = "trig-fexit",
> +	.validate = trigger_validate,
> +	.setup = trigger_fexit_setup,
> +	.producer_thread = trigger_producer,
> +	.measure = trigger_measure,
> +	.report_progress = hits_drops_report_progress,
> +	.report_final = hits_drops_report_final,
> +};
> +
>  const struct bench bench_trig_fentry_sleep = {
>  	.name = "trig-fentry-sleep",
>  	.validate = trigger_validate,
> diff --git a/tools/testing/selftests/bpf/progs/trigger_bench.c b/tools/testing/selftests/bpf/progs/trigger_bench.c
> index 694e7cec1823..eb94f9c0186f 100644
> --- a/tools/testing/selftests/bpf/progs/trigger_bench.c
> +++ b/tools/testing/selftests/bpf/progs/trigger_bench.c
> @@ -33,6 +33,13 @@ int bench_trigger_kprobe(void *ctx)
>  	return 0;
>  }
>  
> +SEC("kretprobe/" SYS_PREFIX "sys_getpgid")
> +int bench_trigger_kretprobe(void *ctx)
> +{
> +	__sync_add_and_fetch(&hits, 1);
> +	return 0;
> +}
> +
>  SEC("fentry/" SYS_PREFIX "sys_getpgid")
>  int bench_trigger_fentry(void *ctx)
>  {
> @@ -40,6 +47,13 @@ int bench_trigger_fentry(void *ctx)
>  	return 0;
>  }
>  
> +SEC("fexit/" SYS_PREFIX "sys_getpgid")
> +int bench_trigger_fexit(void *ctx)
> +{
> +	__sync_add_and_fetch(&hits, 1);
> +	return 0;
> +}
> +
>  SEC("fentry.s/" SYS_PREFIX "sys_getpgid")
>  int bench_trigger_fentry_sleep(void *ctx)
>  {
> -- 
> 2.43.0
> 
> 




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux