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

perf bpf: Add defines for map insertion/lookup

Starting with a helper for a basic pid_map(), a hash using a pid as a
key.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-gdwvq53wltvq6b3g5tdmh0cw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+11
+11
tools/perf/include/bpf/bpf.h
··· 18 18 unsigned int numa_node; 19 19 }; 20 20 21 + #define pid_map(name, value_type) \ 22 + struct bpf_map SEC("maps") name = { \ 23 + .type = BPF_MAP_TYPE_HASH, \ 24 + .key_size = sizeof(pid_t), \ 25 + .value_size = sizeof(value_type), \ 26 + .max_entries = 512, \ 27 + } 28 + 29 + static int (*bpf_map_update_elem)(struct bpf_map *map, void *key, void *value, u64 flags) = (void *)BPF_FUNC_map_update_elem; 30 + static void *(*bpf_map_lookup_elem)(struct bpf_map *map, void *key) = (void *)BPF_FUNC_map_lookup_elem; 31 + 21 32 #define SEC(NAME) __attribute__((section(NAME), used)) 22 33 23 34 #define probe(function, vars) \