tools/testing/selftests/bpf/progs/test_global_func_ctx_args.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_global_func_ctx_args.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_global_func_ctx_args.c- Extension
.c- Size
- 3618 bytes
- Lines
- 173
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf/bpf_core_read.hbpf_misc.h
Detected Declarations
struct bpf_user_pt_regs_tstruct my_structfunction kprobe_typedef_ctx_subprogfunction kprobe_typedef_ctxfunction typesfunction kprobe_resolved_ctxfunction kprobe_workaround_ctx_subprogfunction kprobe_workaround_ctxfunction raw_tp_ctx_subprogfunction raw_tp_ctxfunction raw_tp_writable_ctx_subprogfunction raw_tp_writable_ctxfunction perf_event_ctx_subprogfunction perf_event_ctxfunction subprog_ctx_tagfunction subprog_multi_ctx_tagsfunction __log_levelfunction __log_levelfunction __log_level
Annotated Snippet
struct bpf_user_pt_regs_t {};
__weak int kprobe_workaround_ctx_subprog(struct bpf_user_pt_regs_t *ctx)
{
return bpf_get_stack(ctx, &stack, sizeof(stack), 0);
}
SEC("?kprobe")
__success
int kprobe_workaround_ctx(void *ctx)
{
return kprobe_workaround_ctx_subprog(ctx);
}
/*
* RAW_TRACEPOINT contexts
*/
__weak int raw_tp_ctx_subprog(struct bpf_raw_tracepoint_args *ctx)
{
return bpf_get_stack(ctx, &stack, sizeof(stack), 0);
}
SEC("?raw_tp")
__success
int raw_tp_ctx(void *ctx)
{
return raw_tp_ctx_subprog(ctx);
}
/*
* RAW_TRACEPOINT_WRITABLE contexts
*/
__weak int raw_tp_writable_ctx_subprog(struct bpf_raw_tracepoint_args *ctx)
{
return bpf_get_stack(ctx, &stack, sizeof(stack), 0);
}
SEC("?raw_tp")
__success
int raw_tp_writable_ctx(void *ctx)
{
return raw_tp_writable_ctx_subprog(ctx);
}
/*
* PERF_EVENT contexts
*/
__weak int perf_event_ctx_subprog(struct bpf_perf_event_data *ctx)
{
return bpf_get_stack(ctx, &stack, sizeof(stack), 0);
}
SEC("?perf_event")
__success
int perf_event_ctx(void *ctx)
{
return perf_event_ctx_subprog(ctx);
}
/* this global subprog can be now called from many types of entry progs, each
* with different context type
*/
__weak int subprog_ctx_tag(void *ctx __arg_ctx)
{
return bpf_get_stack(ctx, stack, sizeof(stack), 0);
}
struct my_struct { int x; };
__weak int subprog_multi_ctx_tags(void *ctx1 __arg_ctx,
struct my_struct *mem,
void *ctx2 __arg_ctx)
{
if (!mem)
return 0;
return bpf_get_stack(ctx1, stack, sizeof(stack), 0) +
mem->x +
bpf_get_stack(ctx2, stack, sizeof(stack), 0);
}
SEC("?raw_tp")
__success __log_level(2)
int arg_tag_ctx_raw_tp(void *ctx)
{
struct my_struct x = { .x = 123 };
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf/bpf_core_read.h`, `bpf_misc.h`.
- Detected declarations: `struct bpf_user_pt_regs_t`, `struct my_struct`, `function kprobe_typedef_ctx_subprog`, `function kprobe_typedef_ctx`, `function types`, `function kprobe_resolved_ctx`, `function kprobe_workaround_ctx_subprog`, `function kprobe_workaround_ctx`, `function raw_tp_ctx_subprog`, `function raw_tp_ctx`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.