~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/include/bpf/bpf.h

Version: ~ [ linux-5.1-rc5 ] ~ [ linux-5.0.7 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.34 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.111 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.168 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.178 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.138 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.65 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 #define SEC(NAME) __attribute__((section(NAME),  used))
 49 
 50 #define probe(function, vars) \
 51         SEC(#function "=" #function " " #vars) function
 52 
 53 #define syscall_enter(name) \
 54         SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name
 55 
 56 #define syscall_exit(name) \
 57         SEC("syscalls:sys_exit_" #name) syscall_exit_ ## name
 58 
 59 #define license(name) \
 60 char _license[] SEC("license") = #name; \
 61 int _version SEC("version") = LINUX_VERSION_CODE;
 62 
 63 static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read;
 64 static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str;
 65 
 66 static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) = (void *)BPF_FUNC_perf_event_output;
 67 
 68 #endif /* _PERF_BPF_H */
 69 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp