tools/perf/tests/openat-syscall-all-cpus.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/openat-syscall-all-cpus.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/openat-syscall-all-cpus.c- Extension
.c- Size
- 3550 bytes
- Lines
- 140
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: syscall or user/kernel boundary
- Status
- core 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 participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hinttypes.hsched.hsys/types.hsys/stat.hfcntl.hapi/fs/fs.hlinux/err.hlinux/string.hapi/fs/tracing_path.hevsel.htests.hthread_map.hperf/cpumap.hdebug.hstat.hutil/counts.h
Detected Declarations
function test__openat_syscall_event_on_all_cpusfunction perf_cpu_map__for_each_cpufunction perf_cpu_map__for_each_cpu
Annotated Snippet
if (cpu.cpu >= CPU_SETSIZE) {
pr_debug("Ignoring CPU %d\n", cpu.cpu);
continue;
}
CPU_SET(cpu.cpu, &cpu_set);
if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) {
pr_debug("sched_setaffinity() failed on CPU %d: %s ",
cpu.cpu,
str_error_r(errno, sbuf, sizeof(sbuf)));
goto out_close_fd;
}
for (i = 0; i < ncalls; ++i) {
fd = openat(0, "/etc/passwd", O_RDONLY);
close(fd);
}
CPU_CLR(cpu.cpu, &cpu_set);
}
evsel->core.cpus = perf_cpu_map__get(cpus);
err = TEST_OK;
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
unsigned int expected;
if (cpu.cpu >= CPU_SETSIZE)
continue;
if (evsel__read_on_cpu(evsel, idx, 0) < 0) {
pr_debug("evsel__read_on_cpu\n");
err = TEST_FAIL;
break;
}
expected = nr_openat_calls + idx;
if (perf_counts(evsel->counts, idx, 0)->val != expected) {
pr_debug("evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n",
expected, cpu.cpu, perf_counts(evsel->counts, idx, 0)->val);
err = TEST_FAIL;
}
}
evsel__free_counts(evsel);
out_close_fd:
perf_evsel__close_fd(&evsel->core);
out_evsel_delete:
evsel__delete(evsel);
out_cpu_map_delete:
perf_cpu_map__put(cpus);
out_thread_map_delete:
perf_thread_map__put(threads);
return err;
}
static struct test_case tests__openat_syscall_event_on_all_cpus[] = {
TEST_CASE_REASON("Detect openat syscall event on all cpus",
openat_syscall_event_on_all_cpus,
"permissions"),
{ .name = NULL, }
};
struct test_suite suite__openat_syscall_event_on_all_cpus = {
.desc = "Detect openat syscall event on all cpus",
.test_cases = tests__openat_syscall_event_on_all_cpus,
};
Annotation
- Immediate include surface: `errno.h`, `inttypes.h`, `sched.h`, `sys/types.h`, `sys/stat.h`, `fcntl.h`, `api/fs/fs.h`, `linux/err.h`.
- Detected declarations: `function test__openat_syscall_event_on_all_cpus`, `function perf_cpu_map__for_each_cpu`, `function perf_cpu_map__for_each_cpu`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: core 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.