tools/perf/bench/kallsyms-parse.c
Source file repositories/reference/linux-study-clean/tools/perf/bench/kallsyms-parse.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/bench/kallsyms-parse.c- Extension
.c- Size
- 1727 bytes
- Lines
- 76
- 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
stdlib.hbench.h../util/stat.hlinux/time64.hsubcmd/parse-options.hsymbol/kallsyms.h
Detected Declarations
function bench_process_symbolfunction do_kallsyms_parsefunction bench_kallsyms_parse
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Benchmark of /proc/kallsyms parsing.
*
* Copyright 2020 Google LLC.
*/
#include <stdlib.h>
#include "bench.h"
#include "../util/stat.h"
#include <linux/time64.h>
#include <subcmd/parse-options.h>
#include <symbol/kallsyms.h>
static unsigned int iterations = 100;
static const struct option options[] = {
OPT_UINTEGER('i', "iterations", &iterations,
"Number of iterations used to compute average"),
OPT_END()
};
static const char *const bench_usage[] = {
"perf bench internals kallsyms-parse <options>",
NULL
};
static int bench_process_symbol(void *arg __maybe_unused,
const char *name __maybe_unused,
char type __maybe_unused,
u64 start __maybe_unused)
{
return 0;
}
static int do_kallsyms_parse(void)
{
struct timeval start, end, diff;
u64 runtime_us;
unsigned int i;
double time_average, time_stddev;
int err;
struct stats time_stats;
init_stats(&time_stats);
for (i = 0; i < iterations; i++) {
gettimeofday(&start, NULL);
err = kallsyms__parse("/proc/kallsyms", NULL,
bench_process_symbol);
if (err)
return err;
gettimeofday(&end, NULL);
timersub(&end, &start, &diff);
runtime_us = diff.tv_sec * USEC_PER_SEC + diff.tv_usec;
update_stats(&time_stats, runtime_us);
}
time_average = avg_stats(&time_stats) / USEC_PER_MSEC;
time_stddev = stddev_stats(&time_stats) / USEC_PER_MSEC;
printf(" Average kallsyms__parse took: %.3f ms (+- %.3f ms)\n",
time_average, time_stddev);
return 0;
}
int bench_kallsyms_parse(int argc, const char **argv)
{
argc = parse_options(argc, argv, options, bench_usage, 0);
if (argc) {
usage_with_options(bench_usage, options);
exit(EXIT_FAILURE);
}
return do_kallsyms_parse();
}
Annotation
- Immediate include surface: `stdlib.h`, `bench.h`, `../util/stat.h`, `linux/time64.h`, `subcmd/parse-options.h`, `symbol/kallsyms.h`.
- Detected declarations: `function bench_process_symbol`, `function do_kallsyms_parse`, `function bench_kallsyms_parse`.
- 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.