samples/bpf/tracex6_user.c
Source file repositories/reference/linux-study-clean/samples/bpf/tracex6_user.c
File Facts
- System
- Linux kernel
- Corpus path
samples/bpf/tracex6_user.c- Extension
.c- Size
- 5629 bytes
- Lines
- 223
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- 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
assert.hfcntl.hlinux/perf_event.hsched.hstdio.hstdlib.hsys/ioctl.hsys/time.hsys/types.hsys/wait.hunistd.hbpf/bpf.hbpf/libbpf.hperf-sys.h
Detected Declarations
function check_on_cpufunction test_perf_event_arrayfunction test_bpf_perf_eventfunction mainfunction bpf_object__for_each_program
Annotated Snippet
if (pid[i] == 0) {
check_on_cpu(i, attr);
exit(1);
}
}
for (i = 0; i < nr_cpus; i++) {
assert(waitpid(pid[i], &status, 0) == pid[i]);
err |= status;
}
if (err)
printf("Test: %s FAILED\n", name);
}
static void test_bpf_perf_event(void)
{
struct perf_event_attr attr_cycles = {
.freq = 0,
.sample_period = SAMPLE_PERIOD,
.inherit = 0,
.type = PERF_TYPE_HARDWARE,
.read_format = 0,
.sample_type = 0,
.config = PERF_COUNT_HW_CPU_CYCLES,
};
struct perf_event_attr attr_clock = {
.freq = 0,
.sample_period = SAMPLE_PERIOD,
.inherit = 0,
.type = PERF_TYPE_SOFTWARE,
.read_format = 0,
.sample_type = 0,
.config = PERF_COUNT_SW_CPU_CLOCK,
};
struct perf_event_attr attr_raw = {
.freq = 0,
.sample_period = SAMPLE_PERIOD,
.inherit = 0,
.type = PERF_TYPE_RAW,
.read_format = 0,
.sample_type = 0,
/* Intel Instruction Retired */
.config = 0xc0,
};
struct perf_event_attr attr_l1d_load = {
.freq = 0,
.sample_period = SAMPLE_PERIOD,
.inherit = 0,
.type = PERF_TYPE_HW_CACHE,
.read_format = 0,
.sample_type = 0,
.config =
PERF_COUNT_HW_CACHE_L1D |
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16),
};
struct perf_event_attr attr_llc_miss = {
.freq = 0,
.sample_period = SAMPLE_PERIOD,
.inherit = 0,
.type = PERF_TYPE_HW_CACHE,
.read_format = 0,
.sample_type = 0,
.config =
PERF_COUNT_HW_CACHE_LL |
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16),
};
struct perf_event_attr attr_msr_tsc = {
.freq = 0,
.sample_period = 0,
.inherit = 0,
/* From /sys/bus/event_source/devices/msr/ */
.type = 7,
.read_format = 0,
.sample_type = 0,
.config = 0,
};
test_perf_event_array(&attr_cycles, "HARDWARE-cycles");
test_perf_event_array(&attr_clock, "SOFTWARE-clock");
test_perf_event_array(&attr_raw, "RAW-instruction-retired");
test_perf_event_array(&attr_l1d_load, "HW_CACHE-L1D-load");
/* below tests may fail in qemu */
test_perf_event_array(&attr_llc_miss, "HW_CACHE-LLC-miss");
test_perf_event_array(&attr_msr_tsc, "Dynamic-msr-tsc");
}
Annotation
- Immediate include surface: `assert.h`, `fcntl.h`, `linux/perf_event.h`, `sched.h`, `stdio.h`, `stdlib.h`, `sys/ioctl.h`, `sys/time.h`.
- Detected declarations: `function check_on_cpu`, `function test_perf_event_array`, `function test_bpf_perf_event`, `function main`, `function bpf_object__for_each_program`.
- Atlas domain: Support Tooling And Documentation / samples.
- 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.