1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
7 char _license[] SEC("license") = "GPL";
16 __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
17 __uint(max_entries, 3);
18 __type(key, struct key_t);
20 } hashmap1 SEC(".maps");
22 /* will set before prog run */
23 volatile const __s32 num_cpus = 0;
25 /* will collect results during prog run */
26 __u32 key_sum_a = 0, key_sum_b = 0, key_sum_c = 0;
29 SEC("iter/bpf_map_elem")
30 int dump_bpf_percpu_hash_map(struct bpf_iter__bpf_map_elem *ctx)
32 struct key_t *key = ctx->key;
33 void *pptr = ctx->value;
37 if (key == (void *)0 || pptr == (void *)0)
45 for (i = 0; i < num_cpus; i++) {
46 val_sum += *(__u32 *)pptr;