aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/arraymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/arraymap.c')
-rw-r--r--kernel/bpf/arraymap.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 0c17aab3ce5f..f9d24121be99 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -358,6 +358,29 @@ static void array_map_seq_show_elem(struct bpf_map *map, void *key,
358 rcu_read_unlock(); 358 rcu_read_unlock();
359} 359}
360 360
361static void percpu_array_map_seq_show_elem(struct bpf_map *map, void *key,
362 struct seq_file *m)
363{
364 struct bpf_array *array = container_of(map, struct bpf_array, map);
365 u32 index = *(u32 *)key;
366 void __percpu *pptr;
367 int cpu;
368
369 rcu_read_lock();
370
371 seq_printf(m, "%u: {\n", *(u32 *)key);
372 pptr = array->pptrs[index & array->index_mask];
373 for_each_possible_cpu(cpu) {
374 seq_printf(m, "\tcpu%d: ", cpu);
375 btf_type_seq_show(map->btf, map->btf_value_type_id,
376 per_cpu_ptr(pptr, cpu), m);
377 seq_puts(m, "\n");
378 }
379 seq_puts(m, "}\n");
380
381 rcu_read_unlock();
382}
383
361static int array_map_check_btf(const struct bpf_map *map, 384static int array_map_check_btf(const struct bpf_map *map,
362 const struct btf_type *key_type, 385 const struct btf_type *key_type,
363 const struct btf_type *value_type) 386 const struct btf_type *value_type)
@@ -398,6 +421,7 @@ const struct bpf_map_ops percpu_array_map_ops = {
398 .map_lookup_elem = percpu_array_map_lookup_elem, 421 .map_lookup_elem = percpu_array_map_lookup_elem,
399 .map_update_elem = array_map_update_elem, 422 .map_update_elem = array_map_update_elem,
400 .map_delete_elem = array_map_delete_elem, 423 .map_delete_elem = array_map_delete_elem,
424 .map_seq_show_elem = percpu_array_map_seq_show_elem,
401 .map_check_btf = array_map_check_btf, 425 .map_check_btf = array_map_check_btf,
402}; 426};
403 427