xref: /linux/tools/testing/selftests/bpf/progs/get_cgroup_id_kern.c (revision 566ab427f827b0256d3e8ce0235d088e6a9c28bd)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2018 Facebook
3 
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 
7 __u64 cg_id;
8 __u64 expected_pid;
9 
10 SEC("tracepoint/syscalls/sys_enter_nanosleep")
11 int trace(void *ctx)
12 {
13 	__u32 pid = bpf_get_current_pid_tgid();
14 
15 	if (expected_pid == pid)
16 		cg_id = bpf_get_current_cgroup_id();
17 
18 	return 0;
19 }
20 
21 char _license[] SEC("license") = "GPL";
22