Skip to content

Commit

Permalink
selftests/bpf: Add a test for a large global function
Browse files Browse the repository at this point in the history
test results:
pyperf50 with always_inlined the same function five times: processed 46378 insns
pyperf50 with global function: processed 6102 insns

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200110064124.1760511-5-ast@kernel.org
  • Loading branch information
Alexei Starovoitov authored and Daniel Borkmann committed Jan 10, 2020
1 parent 7608e4d commit 6db2d81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ void test_bpf_verif_scale(void)
{ "test_verif_scale2.o", BPF_PROG_TYPE_SCHED_CLS },
{ "test_verif_scale3.o", BPF_PROG_TYPE_SCHED_CLS },

{ "pyperf_global.o", BPF_PROG_TYPE_RAW_TRACEPOINT },

/* full unroll by llvm */
{ "pyperf50.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
{ "pyperf100.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
Expand Down
9 changes: 7 additions & 2 deletions tools/testing/selftests/bpf/progs/pyperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ struct {
__uint(value_size, sizeof(long long) * 127);
} stackmap SEC(".maps");

static __always_inline int __on_event(struct pt_regs *ctx)
#ifdef GLOBAL_FUNC
__attribute__((noinline))
#else
static __always_inline
#endif
int __on_event(struct bpf_raw_tracepoint_args *ctx)
{
uint64_t pid_tgid = bpf_get_current_pid_tgid();
pid_t pid = (pid_t)(pid_tgid >> 32);
Expand Down Expand Up @@ -254,7 +259,7 @@ static __always_inline int __on_event(struct pt_regs *ctx)
}

SEC("raw_tracepoint/kfree_skb")
int on_event(struct pt_regs* ctx)
int on_event(struct bpf_raw_tracepoint_args* ctx)
{
int i, ret = 0;
ret |= __on_event(ctx);
Expand Down
5 changes: 5 additions & 0 deletions tools/testing/selftests/bpf/progs/pyperf_global.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2020 Facebook */
#define STACK_MAX_LEN 50
#define GLOBAL_FUNC
#include "pyperf.h"

0 comments on commit 6db2d81

Please sign in to comment.