1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
5 #include <bpf/bpf_helpers.h>
7 char _license
[] SEC("license") = "GPL";
17 __uint(type
, BPF_MAP_TYPE_RINGBUF
);
18 __uint(max_entries
, 1 << 12);
19 } ringbuf1
SEC(".maps"),
20 ringbuf2
SEC(".maps");
23 __uint(type
, BPF_MAP_TYPE_ARRAY_OF_MAPS
);
24 __uint(max_entries
, 4);
26 __array(values
, struct ringbuf_map
);
27 } ringbuf_arr
SEC(".maps") = {
44 SEC("tp/syscalls/sys_enter_getpgid")
45 int test_ringbuf(void *ctx
)
47 int cur_pid
= bpf_get_current_pid_tgid() >> 32;
48 struct sample
*sample
;
55 rb
= bpf_map_lookup_elem(&ringbuf_arr
, &target_ring
);
61 sample
= bpf_ringbuf_reserve(rb
, sizeof(*sample
), 0);
68 bpf_get_current_comm(sample
->comm
, sizeof(sample
->comm
));
69 sample
->value
= value
;
74 bpf_ringbuf_submit(sample
, 0);