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

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 <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

authored by

Alexei Starovoitov and committed by
Daniel Borkmann
6db2d81a 7608e4db

+14 -2
+2
tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
··· 48 48 { "test_verif_scale2.o", BPF_PROG_TYPE_SCHED_CLS }, 49 49 { "test_verif_scale3.o", BPF_PROG_TYPE_SCHED_CLS }, 50 50 51 + { "pyperf_global.o", BPF_PROG_TYPE_RAW_TRACEPOINT }, 52 + 51 53 /* full unroll by llvm */ 52 54 { "pyperf50.o", BPF_PROG_TYPE_RAW_TRACEPOINT }, 53 55 { "pyperf100.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
+7 -2
tools/testing/selftests/bpf/progs/pyperf.h
··· 154 154 __uint(value_size, sizeof(long long) * 127); 155 155 } stackmap SEC(".maps"); 156 156 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) 158 163 { 159 164 uint64_t pid_tgid = bpf_get_current_pid_tgid(); 160 165 pid_t pid = (pid_t)(pid_tgid >> 32); ··· 259 254 } 260 255 261 256 SEC("raw_tracepoint/kfree_skb") 262 - int on_event(struct pt_regs* ctx) 257 + int on_event(struct bpf_raw_tracepoint_args* ctx) 263 258 { 264 259 int i, ret = 0; 265 260 ret |= __on_event(ctx);
+5
tools/testing/selftests/bpf/progs/pyperf_global.c
··· 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"