1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2021 William Findlay
3 #include "vmlinux.h"
4 #include <bpf/bpf_helpers.h>
5 
6 struct {
7     __uint(type, BPF_MAP_TYPE_RINGBUF);
8     __uint(max_entries, 4096 /* one page */);
9 } ringbuf1 SEC(".maps");
10 
11 struct {
12     __uint(type, BPF_MAP_TYPE_RINGBUF);
13     __uint(max_entries, 4096 /* one page */);
14 } ringbuf2 SEC(".maps");
15 
16 SEC("tp/syscalls/sys_enter_getpid")
handle__sys_enter_getpid(void * ctx)17 int handle__sys_enter_getpid(void *ctx)
18 {
19     int *value;
20 
21     value = bpf_ringbuf_reserve(&ringbuf1, sizeof(int), 0);
22     if (value) {
23         *value = 1;
24         bpf_ringbuf_submit(value, 0);
25     }
26 
27     value = bpf_ringbuf_reserve(&ringbuf2, sizeof(int), 0);
28     if (value) {
29         *value = 2;
30         bpf_ringbuf_submit(value, 0);
31     }
32 
33     return 0;
34 }
35 
36 char LICENSE[] SEC("license") = "GPL";
37