tools/perf/perf.c
Source file repositories/reference/linux-study-clean/tools/perf/perf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/perf.c- Extension
.c- Size
- 13420 bytes
- Lines
- 581
- 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
builtin.hperf.hutil/build-id.hutil/cache.hutil/env.hinternal/lib.hsubcmd/exec-cmd.hutil/config.hsubcmd/run-command.hutil/parse-events.hsubcmd/parse-options.hsubcmd/help.hutil/debug.hutil/event.hutil/util.hui/ui.hperf-sys.hapi/fs/fs.hapi/fs/tracing_path.hperf/core.herrno.hpthread.hsignal.hstdlib.htime.hsys/types.hsys/stat.hunistd.hlinux/kernel.hlinux/string.hlinux/zalloc.h
Detected Declarations
struct cmd_structstruct pager_configfunction same_cmd_with_prefixfunction pager_command_configfunction check_pager_configfunction browser_command_configfunction check_browser_configfunction commit_pager_choicefunction set_debug_filefunction handle_optionsfunction run_builtinfunction handle_internal_commandfunction execv_dashed_externalfunction run_argvfunction libperf_printfunction main
Annotated Snippet
struct cmd_struct {
const char *cmd;
int (*fn)(int, const char **);
int option;
};
static const struct cmd_struct commands[] = {
{ "archive", NULL, 0 },
{ "buildid-cache", cmd_buildid_cache, 0 },
{ "buildid-list", cmd_buildid_list, 0 },
{ "check", cmd_check, 0 },
{ "config", cmd_config, 0 },
{ "c2c", cmd_c2c, 0 },
{ "diff", cmd_diff, 0 },
{ "evlist", cmd_evlist, 0 },
{ "help", cmd_help, 0 },
{ "iostat", NULL, 0 },
{ "kallsyms", cmd_kallsyms, 0 },
{ "list", cmd_list, 0 },
{ "record", cmd_record, 0 },
{ "report", cmd_report, 0 },
{ "bench", cmd_bench, 0 },
{ "stat", cmd_stat, 0 },
#ifdef HAVE_LIBTRACEEVENT
{ "timechart", cmd_timechart, 0 },
#endif
{ "top", cmd_top, 0 },
{ "annotate", cmd_annotate, 0 },
{ "version", cmd_version, 0 },
{ "script", cmd_script, 0 },
#ifdef HAVE_LIBTRACEEVENT
{ "sched", cmd_sched, 0 },
#endif
#ifdef HAVE_LIBELF_SUPPORT
{ "probe", cmd_probe, 0 },
#endif
#ifdef HAVE_LIBTRACEEVENT
{ "kmem", cmd_kmem, 0 },
{ "lock", cmd_lock, 0 },
#endif
{ "kvm", cmd_kvm, 0 },
{ "test", cmd_test, 0 },
#if defined(HAVE_LIBTRACEEVENT)
{ "trace", cmd_trace, 0 },
#endif
{ "inject", cmd_inject, 0 },
{ "mem", cmd_mem, 0 },
{ "data", cmd_data, 0 },
{ "ftrace", cmd_ftrace, 0 },
{ "daemon", cmd_daemon, 0 },
#ifdef HAVE_LIBTRACEEVENT
{ "kwork", cmd_kwork, 0 },
#endif
};
struct pager_config {
const char *cmd;
int val;
};
static bool same_cmd_with_prefix(const char *var, struct pager_config *c,
const char *header)
{
return (strstarts(var, header) && !strcmp(var + strlen(header), c->cmd));
}
static int pager_command_config(const char *var, const char *value, void *data)
{
struct pager_config *c = data;
if (same_cmd_with_prefix(var, c, "pager."))
c->val = perf_config_bool(var, value);
return 0;
}
/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */
static int check_pager_config(const char *cmd)
{
int err;
struct pager_config c;
c.cmd = cmd;
c.val = -1;
err = perf_config(pager_command_config, &c);
return err ?: c.val;
}
static int browser_command_config(const char *var, const char *value, void *data)
{
struct pager_config *c = data;
if (same_cmd_with_prefix(var, c, "tui."))
c->val = perf_config_bool(var, value);
Annotation
- Immediate include surface: `builtin.h`, `perf.h`, `util/build-id.h`, `util/cache.h`, `util/env.h`, `internal/lib.h`, `subcmd/exec-cmd.h`, `util/config.h`.
- Detected declarations: `struct cmd_struct`, `struct pager_config`, `function same_cmd_with_prefix`, `function pager_command_config`, `function check_pager_config`, `function browser_command_config`, `function check_browser_config`, `function commit_pager_choice`, `function set_debug_file`, `function handle_options`.
- 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.