tools/testing/selftests/bpf/progs/test_sleepable_tracepoints.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_sleepable_tracepoints.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_sleepable_tracepoints.c- Extension
.c- Size
- 2414 bytes
- Lines
- 113
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hasm/unistd.hbpf/bpf_tracing.hbpf/bpf_core_read.hbpf/bpf_helpers.h
Detected Declarations
function copy_getcwd_argfunction BPF_PROGfunction BPF_PROGfunction handle_sys_enter_tpfunction handle_sys_exit_tpfunction BPF_PROGfunction handle_tp_barefunction handle_sys_enter_tp_aliasfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction handle_tp_non_syscall
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
#include <vmlinux.h>
#include <asm/unistd.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
#include <bpf/bpf_helpers.h>
char _license[] SEC("license") = "GPL";
int target_pid;
int prog_triggered;
long err;
char copied_byte;
static int copy_getcwd_arg(char *ubuf)
{
err = bpf_copy_from_user(&copied_byte, sizeof(copied_byte), ubuf);
if (err)
return err;
prog_triggered = 1;
return 0;
}
SEC("tp_btf.s/sys_enter")
int BPF_PROG(handle_sys_enter_tp_btf, struct pt_regs *regs, long id)
{
if ((bpf_get_current_pid_tgid() >> 32) != target_pid ||
id != __NR_getcwd)
return 0;
return copy_getcwd_arg((void *)PT_REGS_PARM1_SYSCALL(regs));
}
SEC("raw_tp.s/sys_enter")
int BPF_PROG(handle_sys_enter_raw_tp, struct pt_regs *regs, long id)
{
if ((bpf_get_current_pid_tgid() >> 32) != target_pid ||
id != __NR_getcwd)
return 0;
return copy_getcwd_arg((void *)PT_REGS_PARM1_CORE_SYSCALL(regs));
}
SEC("tp.s/syscalls/sys_enter_getcwd")
int handle_sys_enter_tp(struct syscall_trace_enter *args)
{
if ((bpf_get_current_pid_tgid() >> 32) != target_pid)
return 0;
return copy_getcwd_arg((void *)args->args[0]);
}
SEC("tp.s/syscalls/sys_exit_getcwd")
int handle_sys_exit_tp(struct syscall_trace_exit *args)
{
struct pt_regs *regs;
if ((bpf_get_current_pid_tgid() >> 32) != target_pid)
return 0;
regs = (struct pt_regs *)bpf_task_pt_regs(bpf_get_current_task_btf());
return copy_getcwd_arg((void *)PT_REGS_PARM1_CORE_SYSCALL(regs));
}
SEC("raw_tp.s")
int BPF_PROG(handle_raw_tp_bare, struct pt_regs *regs, long id)
{
return 0;
}
SEC("tp.s")
int handle_tp_bare(void *ctx)
{
return 0;
}
SEC("tracepoint.s/syscalls/sys_enter_getcwd")
int handle_sys_enter_tp_alias(struct syscall_trace_enter *args)
{
return 0;
}
SEC("raw_tracepoint.s/sys_enter")
int BPF_PROG(handle_sys_enter_raw_tp_alias, struct pt_regs *regs, long id)
{
return 0;
}
Annotation
- Immediate include surface: `vmlinux.h`, `asm/unistd.h`, `bpf/bpf_tracing.h`, `bpf/bpf_core_read.h`, `bpf/bpf_helpers.h`.
- Detected declarations: `function copy_getcwd_arg`, `function BPF_PROG`, `function BPF_PROG`, `function handle_sys_enter_tp`, `function handle_sys_exit_tp`, `function BPF_PROG`, `function handle_tp_bare`, `function handle_sys_enter_tp_alias`, `function BPF_PROG`, `function BPF_PROG`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.