Skip to content

Commit 6db2d81

Browse files
Alexei Starovoitovborkmann
authored andcommitted
selftests/bpf: Add a test for a large global function
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 <[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 7608e4d commit 6db2d81

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ void test_bpf_verif_scale(void)
4848
{ "test_verif_scale2.o", BPF_PROG_TYPE_SCHED_CLS },
4949
{ "test_verif_scale3.o", BPF_PROG_TYPE_SCHED_CLS },
5050

51+
{ "pyperf_global.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
52+
5153
/* full unroll by llvm */
5254
{ "pyperf50.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
5355
{ "pyperf100.o", BPF_PROG_TYPE_RAW_TRACEPOINT },

tools/testing/selftests/bpf/progs/pyperf.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ struct {
154154
__uint(value_size, sizeof(long long) * 127);
155155
} stackmap SEC(".maps");
156156

157-
static __always_inline int __on_event(struct pt_regs *ctx)
157+
#ifdef GLOBAL_FUNC
158+
__attribute__((noinline))
159+
#else
160+
static __always_inline
161+
#endif
162+
int __on_event(struct bpf_raw_tracepoint_args *ctx)
158163
{
159164
uint64_t pid_tgid = bpf_get_current_pid_tgid();
160165
pid_t pid = (pid_t)(pid_tgid >> 32);
@@ -254,7 +259,7 @@ static __always_inline int __on_event(struct pt_regs *ctx)
254259
}
255260

256261
SEC("raw_tracepoint/kfree_skb")
257-
int on_event(struct pt_regs* ctx)
262+
int on_event(struct bpf_raw_tracepoint_args* ctx)
258263
{
259264
int i, ret = 0;
260265
ret |= __on_event(ctx);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) 2020 Facebook */
3+
#define STACK_MAX_LEN 50
4+
#define GLOBAL_FUNC
5+
#include "pyperf.h"

0 commit comments

Comments
 (0)