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

Configure Feed

Select the types of activity you want to include in your feed.

perf bpf examples: With no BPF events remove examples

The examples were used to give demonstrations of BPF events but such
functionality is now subsumed by using --filter with 'perf record' or
the direct use of BPF skeletons.

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: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Carsten Haitzler <carsten.haitzler@arm.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Fangrui Song <maskray@google.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Tom Rix <trix@redhat.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: YueHaibing <yuehaibing@huawei.com>
Cc: bpf@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20230810184853.2860737-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
5056c99e 5e6da6be

-130
-5
tools/perf/Makefile.perf
··· 958 958 endif 959 959 $(call QUIET_INSTALL, libexec) \ 960 960 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 961 - ifndef NO_LIBBPF 962 - $(call QUIET_INSTALL, bpf-examples) \ 963 - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \ 964 - $(INSTALL) examples/bpf/*.c -m 644 -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf' 965 - endif 966 961 $(call QUIET_INSTALL, perf-archive) \ 967 962 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 968 963 $(call QUIET_INSTALL, perf-iostat) \
-53
tools/perf/examples/bpf/5sec.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - Description: 4 - 5 - . Disable strace like syscall tracing (--no-syscalls), or try tracing 6 - just some (-e *sleep). 7 - 8 - . Attach a filter function to a kernel function, returning when it should 9 - be considered, i.e. appear on the output. 10 - 11 - . Run it system wide, so that any sleep of >= 5 seconds and < than 6 12 - seconds gets caught. 13 - 14 - . Ask for callgraphs using DWARF info, so that userspace can be unwound 15 - 16 - . While this is running, run something like "sleep 5s". 17 - 18 - . If we decide to add tv_nsec as well, then it becomes: 19 - 20 - int probe(hrtimer_nanosleep, rqtp->tv_sec rqtp->tv_nsec)(void *ctx, int err, long sec, long nsec) 21 - 22 - I.e. add where it comes from (rqtp->tv_nsec) and where it will be 23 - accessible in the function body (nsec) 24 - 25 - # perf trace --no-syscalls -e tools/perf/examples/bpf/5sec.c/call-graph=dwarf/ 26 - 0.000 perf_bpf_probe:func:(ffffffff9811b5f0) tv_sec=5 27 - hrtimer_nanosleep ([kernel.kallsyms]) 28 - __x64_sys_nanosleep ([kernel.kallsyms]) 29 - do_syscall_64 ([kernel.kallsyms]) 30 - entry_SYSCALL_64 ([kernel.kallsyms]) 31 - __GI___nanosleep (/usr/lib64/libc-2.26.so) 32 - rpl_nanosleep (/usr/bin/sleep) 33 - xnanosleep (/usr/bin/sleep) 34 - main (/usr/bin/sleep) 35 - __libc_start_main (/usr/lib64/libc-2.26.so) 36 - _start (/usr/bin/sleep) 37 - ^C# 38 - 39 - Copyright (C) 2018 Red Hat, Inc., Arnaldo Carvalho de Melo <acme@redhat.com> 40 - */ 41 - 42 - #include <linux/bpf.h> 43 - #include <bpf/bpf_helpers.h> 44 - 45 - #define NSEC_PER_SEC 1000000000L 46 - 47 - SEC("hrtimer_nanosleep=hrtimer_nanosleep rqtp") 48 - int hrtimer_nanosleep(void *ctx, int err, long long sec) 49 - { 50 - return sec / NSEC_PER_SEC == 5ULL; 51 - } 52 - 53 - char _license[] SEC("license") = "GPL";
-12
tools/perf/examples/bpf/empty.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/bpf.h> 3 - #include <bpf/bpf_helpers.h> 4 - 5 - struct syscall_enter_args; 6 - 7 - SEC("raw_syscalls:sys_enter") 8 - int sys_enter(struct syscall_enter_args *args) 9 - { 10 - return 0; 11 - } 12 - char _license[] SEC("license") = "GPL";
-27
tools/perf/examples/bpf/hello.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/bpf.h> 3 - #include <bpf/bpf_helpers.h> 4 - 5 - struct __bpf_stdout__ { 6 - __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); 7 - __type(key, int); 8 - __type(value, __u32); 9 - __uint(max_entries, __NR_CPUS__); 10 - } __bpf_stdout__ SEC(".maps"); 11 - 12 - #define puts(from) \ 13 - ({ const int __len = sizeof(from); \ 14 - char __from[sizeof(from)] = from; \ 15 - bpf_perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \ 16 - &__from, __len & (sizeof(from) - 1)); }) 17 - 18 - struct syscall_enter_args; 19 - 20 - SEC("raw_syscalls:sys_enter") 21 - int sys_enter(struct syscall_enter_args *args) 22 - { 23 - puts("Hello, world\n"); 24 - return 0; 25 - } 26 - 27 - char _license[] SEC("license") = "GPL";
-33
tools/perf/examples/bpf/sys_enter_openat.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Hook into 'openat' syscall entry tracepoint 4 - * 5 - * Test it with: 6 - * 7 - * perf trace -e tools/perf/examples/bpf/sys_enter_openat.c cat /etc/passwd > /dev/null 8 - * 9 - * It'll catch some openat syscalls related to the dynamic linked and 10 - * the last one should be the one for '/etc/passwd'. 11 - * 12 - * The syscall_enter_openat_args can be used to get the syscall fields 13 - * and use them for filtering calls, i.e. use in expressions for 14 - * the return value. 15 - */ 16 - 17 - #include <bpf/bpf.h> 18 - 19 - struct syscall_enter_openat_args { 20 - unsigned long long unused; 21 - long syscall_nr; 22 - long dfd; 23 - char *filename_ptr; 24 - long flags; 25 - long mode; 26 - }; 27 - 28 - int syscall_enter(openat)(struct syscall_enter_openat_args *args) 29 - { 30 - return 1; 31 - } 32 - 33 - license(GPL);