libbpf: use explicit map reuse flag to skip map creation steps
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 4 Jan 2024 01:38:40 +0000 (17:38 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 4 Jan 2024 05:22:49 +0000 (21:22 -0800)
Instead of inferring whether map already point to previously
created/pinned BPF map (which user can specify with bpf_map__reuse_fd()) API),
use explicit map->reused flag that is set in such case.

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240104013847.3875810-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c

index f1521a400f02284abcbd59e4cf6732faad842861..3b678b6172138f15ca07044304771237bee8e492 100644 (file)
@@ -5465,7 +5465,7 @@ retry:
                        }
                }
 
-               if (map->fd >= 0) {
+               if (map->reused) {
                        pr_debug("map '%s': skipping creation (preset fd=%d)\n",
                                 map->name, map->fd);
                } else {