Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at master 43 lines 753 B view raw
1// SPDX-License-Identifier: GPL-2.0 2#include <linux/bpf.h> 3#include <bpf/bpf_helpers.h> 4#include "bpf_misc.h" 5#include "bpf_test_utils.h" 6 7struct { 8 __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 9 __uint(max_entries, 1); 10 __uint(key_size, sizeof(__u32)); 11 __array(values, void (void)); 12} jmp_table SEC(".maps"); 13 14SEC("?uprobe") 15int uprobe_normal(void *ctx) 16{ 17 bpf_tail_call_static(ctx, &jmp_table, 0); 18 return 0; 19} 20 21SEC("?uprobe.s") 22int uprobe_sleepable_1(void *ctx) 23{ 24 bpf_tail_call_static(ctx, &jmp_table, 0); 25 return 0; 26} 27 28int executed = 0; 29int my_pid = 0; 30 31SEC("?uprobe.s") 32int uprobe_sleepable_2(void *ctx) 33{ 34 int pid = bpf_get_current_pid_tgid() >> 32; 35 36 if (pid != my_pid) 37 return 0; 38 39 executed++; 40 return 0; 41} 42 43char __license[] SEC("license") = "GPL";