perf/bpf_counter: Use bpf_map_create instead of bpf_create_map
bpf_create_map is deprecated. Replace it with bpf_map_create. Also add a
__weak bpf_map_create() so that when older version of libbpf is linked as
a shared library, it falls back to bpf_create_map().
Fixes: 992c422541
("libbpf: Unify low-level map creation APIs w/ new bpf_map_create()")
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211207232340.2561471-1-song@kernel.org
This commit is contained in:
parent
fda684fb5e
commit
8d0f9e73ef
@ -307,6 +307,20 @@ static bool bperf_attr_map_compatible(int attr_map_fd)
|
|||||||
(map_info.value_size == sizeof(struct perf_event_attr_map_entry));
|
(map_info.value_size == sizeof(struct perf_event_attr_map_entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __weak
|
||||||
|
bpf_map_create(enum bpf_map_type map_type,
|
||||||
|
const char *map_name __maybe_unused,
|
||||||
|
__u32 key_size,
|
||||||
|
__u32 value_size,
|
||||||
|
__u32 max_entries,
|
||||||
|
const struct bpf_map_create_opts *opts __maybe_unused)
|
||||||
|
{
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
return bpf_create_map(map_type, key_size, value_size, max_entries, 0);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
static int bperf_lock_attr_map(struct target *target)
|
static int bperf_lock_attr_map(struct target *target)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
@ -320,10 +334,10 @@ static int bperf_lock_attr_map(struct target *target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (access(path, F_OK)) {
|
if (access(path, F_OK)) {
|
||||||
map_fd = bpf_create_map(BPF_MAP_TYPE_HASH,
|
map_fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL,
|
||||||
sizeof(struct perf_event_attr),
|
sizeof(struct perf_event_attr),
|
||||||
sizeof(struct perf_event_attr_map_entry),
|
sizeof(struct perf_event_attr_map_entry),
|
||||||
ATTR_MAP_SIZE, 0);
|
ATTR_MAP_SIZE, NULL);
|
||||||
if (map_fd < 0)
|
if (map_fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user