diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2023-07-19 09:48:53 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2023-07-19 09:48:53 -0700 |
| commit | 9df76fe0c5ac7622dfd16c47f98f3d48e890890e (patch) | |
| tree | 591c3e53fbc4e755d8886eb178fe8e75cedc006c /tools/testing/selftests/bpf/progs/map_ptr_kern.c | |
| parent | 8daf847714ec55fe590d1135e26c531658b2ac1c (diff) | |
| parent | 72829b1c1f1601015cd7332b968befcf5e636c24 (diff) | |
| download | linux-9df76fe0c5ac7622dfd16c47f98f3d48e890890e.tar.gz linux-9df76fe0c5ac7622dfd16c47f98f3d48e890890e.tar.bz2 linux-9df76fe0c5ac7622dfd16c47f98f3d48e890890e.zip | |
Merge branch 'allow-bpf_map_sum_elem_count-for-all-program-types'
Anton Protopopov says:
====================
allow bpf_map_sum_elem_count for all program types
This series is a follow up to the recent change [1] which added
per-cpu insert/delete statistics for maps. The bpf_map_sum_elem_count
kfunc presented in the original series was only available to tracing
programs, so let's make it available to all.
The first patch makes types listed in the reg2btf_ids[] array to be
considered trusted by kfuncs.
The second patch allows to treat CONST_PTR_TO_MAP as trusted pointers from
kfunc's point of view by adding it to the reg2btf_ids[] array.
The third patch adds missing const to the map argument of the
bpf_map_sum_elem_count kfunc.
The fourth patch registers the bpf_map_sum_elem_count for all programs,
and patches selftests correspondingly.
[1] https://lore.kernel.org/bpf/20230705160139.19967-1-aspsk@isovalent.com/
v1 -> v2:
* treat the whole reg2btf_ids array as trusted (Alexei)
====================
Link: https://lore.kernel.org/r/20230719092952.41202-1-aspsk@isovalent.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/map_ptr_kern.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/map_ptr_kern.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testing/selftests/bpf/progs/map_ptr_kern.c index db388f593d0a..3325da17ec81 100644 --- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c +++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c @@ -103,6 +103,8 @@ struct { __type(value, __u32); } m_hash SEC(".maps"); +__s64 bpf_map_sum_elem_count(struct bpf_map *map) __ksym; + static inline int check_hash(void) { struct bpf_htab *hash = (struct bpf_htab *)&m_hash; @@ -115,6 +117,8 @@ static inline int check_hash(void) VERIFY(hash->elem_size == 64); VERIFY(hash->count.counter == 0); + VERIFY(bpf_map_sum_elem_count(map) == 0); + for (i = 0; i < HALF_ENTRIES; ++i) { const __u32 key = i; const __u32 val = 1; @@ -123,6 +127,7 @@ static inline int check_hash(void) return 0; } VERIFY(hash->count.counter == HALF_ENTRIES); + VERIFY(bpf_map_sum_elem_count(map) == HALF_ENTRIES); return 1; } |
