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

perf bpf: Remove now unused BPF headers

Example code has migrated to use standard BPF header files, remove
unnecessary perf equivalents. Update install step to not try to copy
these.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20221103045437.163510-8-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
cfddf0d4 71811e8c

-146
-5
tools/perf/Makefile.perf
··· 960 960 $(call QUIET_INSTALL, libexec) \ 961 961 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 962 962 ifndef NO_LIBBPF 963 - $(call QUIET_INSTALL, bpf-headers) \ 964 - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \ 965 - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux'; \ 966 - $(INSTALL) include/bpf/*.h -m 644 -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \ 967 - $(INSTALL) include/bpf/linux/*.h -m 644 -t '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf/linux' 968 963 $(call QUIET_INSTALL, bpf-examples) \ 969 964 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'; \ 970 965 $(INSTALL) examples/bpf/*.c -m 644 -t '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
-70
tools/perf/include/bpf/bpf.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #ifndef _PERF_BPF_H 3 - #define _PERF_BPF_H 4 - 5 - #include <uapi/linux/bpf.h> 6 - 7 - /* 8 - * A helper structure used by eBPF C program to describe map attributes to 9 - * elf_bpf loader, taken from tools/testing/selftests/bpf/bpf_helpers.h: 10 - */ 11 - struct bpf_map { 12 - unsigned int type; 13 - unsigned int key_size; 14 - unsigned int value_size; 15 - unsigned int max_entries; 16 - unsigned int map_flags; 17 - unsigned int inner_map_idx; 18 - unsigned int numa_node; 19 - }; 20 - 21 - #define bpf_map(name, _type, type_key, type_val, _max_entries) \ 22 - struct bpf_map SEC("maps") name = { \ 23 - .type = BPF_MAP_TYPE_##_type, \ 24 - .key_size = sizeof(type_key), \ 25 - .value_size = sizeof(type_val), \ 26 - .max_entries = _max_entries, \ 27 - }; \ 28 - struct ____btf_map_##name { \ 29 - type_key key; \ 30 - type_val value; \ 31 - }; \ 32 - struct ____btf_map_##name __attribute__((section(".maps." #name), used)) \ 33 - ____btf_map_##name = { } 34 - 35 - /* 36 - * FIXME: this should receive .max_entries as a parameter, as careful 37 - * tuning of these limits is needed to avoid hitting limits that 38 - * prevents other BPF constructs, such as tracepoint handlers, 39 - * to get installed, with cryptic messages from libbpf, etc. 40 - * For the current need, 'perf trace --filter-pids', 64 should 41 - * be good enough, but this surely needs to be revisited. 42 - */ 43 - #define pid_map(name, value_type) bpf_map(name, HASH, pid_t, value_type, 64) 44 - 45 - static int (*bpf_map_update_elem)(struct bpf_map *map, void *key, void *value, u64 flags) = (void *)BPF_FUNC_map_update_elem; 46 - static void *(*bpf_map_lookup_elem)(struct bpf_map *map, void *key) = (void *)BPF_FUNC_map_lookup_elem; 47 - 48 - static void (*bpf_tail_call)(void *ctx, void *map, int index) = (void *)BPF_FUNC_tail_call; 49 - 50 - #define SEC(NAME) __attribute__((section(NAME), used)) 51 - 52 - #define probe(function, vars) \ 53 - SEC(#function "=" #function " " #vars) function 54 - 55 - #define syscall_enter(name) \ 56 - SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name 57 - 58 - #define syscall_exit(name) \ 59 - SEC("syscalls:sys_exit_" #name) syscall_exit_ ## name 60 - 61 - #define license(name) \ 62 - char _license[] SEC("license") = #name; \ 63 - int _version SEC("version") = LINUX_VERSION_CODE; 64 - 65 - static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read; 66 - static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str; 67 - 68 - static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) = (void *)BPF_FUNC_perf_event_output; 69 - 70 - #endif /* _PERF_BPF_H */
-24
tools/perf/include/bpf/linux/socket.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - #ifndef _UAPI_LINUX_SOCKET_H 3 - #define _UAPI_LINUX_SOCKET_H 4 - 5 - /* 6 - * Desired design of maximum size and alignment (see RFC2553) 7 - */ 8 - #define _K_SS_MAXSIZE 128 /* Implementation specific max size */ 9 - #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) 10 - /* Implementation specific desired alignment */ 11 - 12 - typedef unsigned short __kernel_sa_family_t; 13 - 14 - struct __kernel_sockaddr_storage { 15 - __kernel_sa_family_t ss_family; /* address family */ 16 - /* Following field(s) are implementation specific */ 17 - char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; 18 - /* space to achieve desired size, */ 19 - /* _SS_MAXSIZE value minus size of ss_family */ 20 - } __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */ 21 - 22 - #define sockaddr_storage __kernel_sockaddr_storage 23 - 24 - #endif /* _UAPI_LINUX_SOCKET_H */
-21
tools/perf/include/bpf/pid_filter.h
··· 1 - // SPDX-License-Identifier: LGPL-2.1 2 - 3 - #ifndef _PERF_BPF_PID_FILTER_ 4 - #define _PERF_BPF_PID_FILTER_ 5 - 6 - #include <bpf.h> 7 - 8 - #define pid_filter(name) pid_map(name, bool) 9 - 10 - static int pid_filter__add(struct bpf_map *pids, pid_t pid) 11 - { 12 - bool value = true; 13 - return bpf_map_update_elem(pids, &pid, &value, BPF_NOEXIST); 14 - } 15 - 16 - static bool pid_filter__has(struct bpf_map *pids, pid_t pid) 17 - { 18 - return bpf_map_lookup_elem(pids, &pid) != NULL; 19 - } 20 - 21 - #endif // _PERF_BPF_PID_FILTER_
-16
tools/perf/include/bpf/stdio.h
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - 3 - #include <bpf.h> 4 - 5 - struct bpf_map SEC("maps") __bpf_stdout__ = { 6 - .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, 7 - .key_size = sizeof(int), 8 - .value_size = sizeof(u32), 9 - .max_entries = __NR_CPUS__, 10 - }; 11 - 12 - #define puts(from) \ 13 - ({ const int __len = sizeof(from); \ 14 - char __from[__len] = from; \ 15 - perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \ 16 - &__from, __len & (sizeof(from) - 1)); })
-10
tools/perf/include/bpf/unistd.h
··· 1 - // SPDX-License-Identifier: LGPL-2.1 2 - 3 - #include <bpf.h> 4 - 5 - static int (*bpf_get_current_pid_tgid)(void) = (void *)BPF_FUNC_get_current_pid_tgid; 6 - 7 - static pid_t getpid(void) 8 - { 9 - return bpf_get_current_pid_tgid(); 10 - }