1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2020 Facebook */ 3 #include "bpf_iter.h" 4 #include <bpf/bpf_helpers.h> 5 6 char _license[] SEC("license") = "GPL"; 7 8 SEC("iter/bpf_map") 9 int dump_bpf_map(struct bpf_iter__bpf_map *ctx) 10 { 11 struct seq_file *seq = ctx->meta->seq; 12 __u64 seq_num = ctx->meta->seq_num; 13 struct bpf_map *map = ctx->map; 14 15 if (map == (void *)0) { 16 BPF_SEQ_PRINTF(seq, " %%%%%% END %%%%%%\n"); 17 return 0; 18 } 19 20 if (seq_num == 0) 21 BPF_SEQ_PRINTF(seq, " id refcnt usercnt locked_vm\n"); 22 23 BPF_SEQ_PRINTF(seq, "%8u %8ld %8ld %10lu\n", map->id, map->refcnt.counter, 24 map->usercnt.counter, 25 0LLU); 26 return 0; 27 } 28