1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_tracing.h>
4 #include <bpf/bpf_helpers.h>
7 struct task_struct __kptr_untrusted *ptr;
11 __uint(type, BPF_MAP_TYPE_LRU_HASH);
12 __uint(max_entries, 1);
14 __type(value, struct map_value);
15 } lru_map SEC(".maps");
20 SEC("fentry/bpf_ktime_get_ns")
23 struct map_value v = {};
25 if (pid == bpf_get_current_task_btf()->pid)
26 bpf_map_update_elem(&lru_map, &(int){0}, &v, 0);
30 SEC("fentry/do_nanosleep")
31 int nanosleep(void *ctx)
33 struct map_value val = {}, *v;
34 struct task_struct *current;
36 bpf_map_update_elem(&lru_map, &(int){0}, &val, 0);
37 v = bpf_map_lookup_elem(&lru_map, &(int){0});
40 bpf_map_delete_elem(&lru_map, &(int){0});
41 current = bpf_get_current_task_btf();
49 char _license[] SEC("license") = "GPL";