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 /* libbpf will adjust to valid page size */
19 __uint(max_entries, 1000);
20 } ringbuf1 SEC(".maps"),
21 ringbuf2 SEC(".maps");
24 __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
25 __uint(max_entries, 4);
27 __array(values, struct ringbuf_map);
28 } ringbuf_arr SEC(".maps") = {
36 __uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
37 __uint(max_entries, 1);
39 __array(values, struct ringbuf_map);
40 } ringbuf_hash SEC(".maps") = {
56 SEC("tp/syscalls/sys_enter_getpgid")
57 int test_ringbuf(void *ctx)
59 int cur_pid = bpf_get_current_pid_tgid() >> 32;
60 struct sample *sample;
66 rb = bpf_map_lookup_elem(&ringbuf_arr, &target_ring);
72 sample = bpf_ringbuf_reserve(rb, sizeof(*sample), 0);
79 bpf_get_current_comm(sample->comm, sizeof(sample->comm));
80 sample->value = value;
85 bpf_ringbuf_submit(sample, 0);