diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2022-10-03 17:04:02 +0100 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2022-10-03 17:04:02 +0100 |
commit | 97acb6a8fcc4e5c2cdc2693a35acdc5a7461aaa3 (patch) | |
tree | c4f1a18b38d655b7806a72515992bd9aae14ef53 /tools/perf/tests/bpf-script-example.c | |
parent | 6fa964c045a6bc3321a9186e87bfbcfd1059b0f1 (diff) | |
parent | 7860d720a84c74b2761c6b7995392a798ab0a3cb (diff) |
Merge drm/drm-next into drm-intel-gt-next
Daniele needs 84d4333c1e28 ("misc/mei: Add NULL check to component match
callback functions") in order to merge the DG2 HuC patches.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tools/perf/tests/bpf-script-example.c')
-rw-r--r-- | tools/perf/tests/bpf-script-example.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/tools/perf/tests/bpf-script-example.c b/tools/perf/tests/bpf-script-example.c index ab4b98b3165db..7981c69ed1b45 100644 --- a/tools/perf/tests/bpf-script-example.c +++ b/tools/perf/tests/bpf-script-example.c @@ -17,20 +17,31 @@ static void *(*bpf_map_lookup_elem)(void *map, void *key) = static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) = (void *) BPF_FUNC_map_update_elem; -struct bpf_map_def { - unsigned int type; - unsigned int key_size; - unsigned int value_size; - unsigned int max_entries; -}; +/* + * Following macros are taken from tools/lib/bpf/bpf_helpers.h, + * and are used to create BTF defined maps. It is easier to take + * 2 simple macros, than being able to include above header in + * runtime. + * + * __uint - defines integer attribute of BTF map definition, + * Such attributes are represented using a pointer to an array, + * in which dimensionality of array encodes specified integer + * value. + * + * __type - defines pointer variable with typeof(val) type for + * attributes like key or value, which will be defined by the + * size of the type. + */ +#define __uint(name, val) int (*name)[val] +#define __type(name, val) typeof(val) *name #define SEC(NAME) __attribute__((section(NAME), used)) -struct bpf_map_def SEC("maps") flip_table = { - .type = BPF_MAP_TYPE_ARRAY, - .key_size = sizeof(int), - .value_size = sizeof(int), - .max_entries = 1, -}; +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, int); + __type(value, int); +} flip_table SEC(".maps"); SEC("func=do_epoll_wait") int bpf_func__SyS_epoll_pwait(void *ctx) |