samples: bpf: Refactor BPF map performance test with libbpf
authorDaniel T. Lee <danieltimlee@gmail.com>
Tue, 7 Jul 2020 18:48:54 +0000 (03:48 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 7 Jul 2020 23:33:14 +0000 (01:33 +0200)
commitcc7f641d637bef0b31194d28667553f77c4ef947
treea86630f75e705e00f793d6c8b5c5bd3a58886ea6
parent88795b4adb01a30fbfd75ef1c1ef73b4442e38b2
samples: bpf: Refactor BPF map performance test with libbpf

Previously, in order to set the numa_node attribute at the time of map
creation using "libbpf", it was necessary to call bpf_create_map_node()
directly (bpf_load approach), instead of calling bpf_object_load()
that handles everything on its own, including map creation. And because
of this problem, this sample had problems with refactoring from bpf_load
to libbbpf.

However, by commit 1bdb6c9a1c43 ("libbpf: Add a bunch of attribute
getters/setters for map definitions") added the numa_node attribute and
allowed it to be set in the map.

By using libbpf instead of bpf_load, the inner map definition has
been explicitly declared with BTF-defined format. Also, the element of
ARRAY_OF_MAPS was also statically specified using the BTF format. And
for this reason some logic in fixup_map() was not needed and changed
or removed.

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200707184855.30968-4-danieltimlee@gmail.com
samples/bpf/map_perf_test_kern.c
samples/bpf/map_perf_test_user.c