tools/testing/selftests/bpf/progs/get_cgroup_id_kern.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/get_cgroup_id_kern.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/get_cgroup_id_kern.c
Extension
.c
Size
387 bytes
Lines
22
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018 Facebook

#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>

__u64 cg_id;
__u64 expected_pid;

SEC("tracepoint/syscalls/sys_enter_nanosleep")
int trace(void *ctx)
{
	__u32 pid = bpf_get_current_pid_tgid();

	if (expected_pid == pid)
		cg_id = bpf_get_current_cgroup_id();

	return 0;
}

char _license[] SEC("license") = "GPL";

Annotation

Implementation Notes