tools/testing/selftests/bpf/progs/test_ctx.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_ctx.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_ctx.c- Extension
.c- Size
- 1026 bytes
- Lines
- 49
- 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.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf_experimental.h
Detected Declarations
function trigger_all_contextsfunction BPF_PROGfunction BPF_PROG
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2026 Valve Corporation.
* Author: Changwoo Min <changwoo@igalia.com>
*/
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include "bpf_experimental.h"
char _license[] SEC("license") = "GPL";
extern void bpf_kfunc_trigger_ctx_check(void) __ksym;
int count_hardirq;
int count_softirq;
int count_task;
/* Triggered via bpf_prog_test_run from user-space */
SEC("syscall")
int trigger_all_contexts(void *ctx)
{
if (bpf_in_task())
__sync_fetch_and_add(&count_task, 1);
/* Trigger the firing of a hardirq and softirq for test. */
bpf_kfunc_trigger_ctx_check();
return 0;
}
/* Observer for HardIRQ */
SEC("fentry/bpf_testmod_test_hardirq_fn")
int BPF_PROG(on_hardirq)
{
if (bpf_in_hardirq())
__sync_fetch_and_add(&count_hardirq, 1);
return 0;
}
/* Observer for SoftIRQ */
SEC("fentry/bpf_testmod_test_softirq_fn")
int BPF_PROG(on_softirq)
{
if (bpf_in_serving_softirq())
__sync_fetch_and_add(&count_softirq, 1);
return 0;
}
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf_experimental.h`.
- Detected declarations: `function trigger_all_contexts`, `function BPF_PROG`, `function BPF_PROG`.
- 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.