tools/testing/selftests/powerpc/benchmarks/null_syscall.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/benchmarks/null_syscall.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/benchmarks/null_syscall.c- Extension
.c- Size
- 3018 bytes
- Lines
- 155
- 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
string.hstdio.hstdlib.hunistd.htime.hsys/types.hsys/time.hsys/syscall.hsignal.h
Detected Declarations
function mftbfunction sigalrm_handlerfunction clock_gettimefunction get_proc_frequencyfunction do_null_syscallfunction main
Annotated Snippet
if (strncmp(line, "timebase", 8) == 0) {
p = strchr(line, ':');
if (p != NULL) {
v = strtoull(p + 1, &end, 0);
if (end != p + 1)
timebase_frequency = v;
}
}
if (((strncmp(line, "clock", 5) == 0) ||
(strncmp(line, "cpu MHz", 7) == 0))) {
p = strchr(line, ':');
if (p != NULL) {
d = strtod(p + 1, &end);
if (end != p + 1) {
/* Find fastest clock frequency */
if ((d * 1000000ULL) > clock_frequency)
clock_frequency = d * 1000000ULL;
}
}
}
}
fclose(f);
override = getenv("FREQUENCY");
if (override)
clock_frequency = strtoull(override, NULL, 10);
if (timebase_frequency)
timebase_multiplier = (double)clock_frequency
/ timebase_frequency;
else
timebase_multiplier = 1;
}
static void do_null_syscall(unsigned long nr)
{
unsigned long i;
for (i = 0; i < nr; i++)
syscall(__NR_gettid);
}
#define TIME(A, STR) \
int main(void)
{
unsigned long tb_start, tb_now;
struct timespec tv_start, tv_now;
unsigned long long elapsed_ns, elapsed_tb;
get_proc_frequency();
clock_gettime(CLOCK_MONOTONIC, &tv_start);
tb_start = mftb();
do_null_syscall(NR_LOOPS);
clock_gettime(CLOCK_MONOTONIC, &tv_now);
tb_now = mftb();
elapsed_ns = (tv_now.tv_sec - tv_start.tv_sec) * 1000000000ULL +
(tv_now.tv_nsec - tv_start.tv_nsec);
elapsed_tb = tb_now - tb_start;
printf("%10.2f ns %10.2f cycles\n", (float)elapsed_ns / NR_LOOPS,
(float)elapsed_tb * timebase_multiplier / NR_LOOPS);
return 0;
}
Annotation
- Immediate include surface: `string.h`, `stdio.h`, `stdlib.h`, `unistd.h`, `time.h`, `sys/types.h`, `sys/time.h`, `sys/syscall.h`.
- Detected declarations: `function mftb`, `function sigalrm_handler`, `function clock_gettime`, `function get_proc_frequency`, `function do_null_syscall`, `function main`.
- 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.