tools/perf/builtin-diff.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-diff.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-diff.c- Extension
.c- Size
- 47309 bytes
- Lines
- 2012
- 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/debug.hutil/event.hutil/hist.hutil/evsel.hutil/evlist.hutil/session.hutil/tool.hutil/sort.hutil/srcline.hutil/symbol.hutil/data.hutil/config.hutil/time-utils.hutil/annotate.hutil/map.hutil/spark.hutil/block-info.hutil/stream.hutil/util.hlinux/err.hlinux/zalloc.hsubcmd/pager.hsubcmd/parse-options.herrno.hinttypes.hstdlib.hmath.h
Detected Declarations
struct perf_diffstruct diff_hpp_fmtstruct data__filefunction setup_compute_opt_wdifffunction setup_compute_optfunction setup_computefunction period_percentfunction compute_deltafunction compute_ratiofunction compute_wdifffunction formula_deltafunction formula_ratiofunction formula_wdifffunction formula_fprintffunction block_hist_freefunction diff__process_sample_eventfunction evlist__for_each_entryfunction evlist__collapse_resortfunction evlist__for_each_entryfunction get_pair_datafunction get_pair_fmtfunction hists__baseline_onlyfunction block_cycles_diff_cmpfunction block_sortfunction init_block_histfunction init_spark_valuesfunction update_spark_valuefunction compute_cycles_difffunction block_hists_matchfunction hists__precomputefunction data__for_each_file_newfunction cmp_doublesfunction __hist_entry__cmp_computefunction hist_entry__cmp_computefunction hist_entry__cmp_compute_idxfunction hist_entry__cmp_nopfunction hist_entry__cmp_baselinefunction hist_entry__cmp_deltafunction hist_entry__cmp_delta_absfunction hist_entry__cmp_ratiofunction hist_entry__cmp_wdifffunction hist_entry__cmp_delta_idxfunction hist_entry__cmp_delta_abs_idxfunction hist_entry__cmp_ratio_idxfunction hist_entry__cmp_wdiff_idxfunction hists__processfunction data__fprintffunction data_process
Annotated Snippet
struct perf_diff {
struct perf_tool tool;
const char *time_str;
struct perf_time_interval *ptime_range;
int range_size;
int range_num;
bool has_br_stack;
bool stream;
};
/* Diff command specific HPP columns. */
enum {
PERF_HPP_DIFF__BASELINE,
PERF_HPP_DIFF__PERIOD,
PERF_HPP_DIFF__PERIOD_BASELINE,
PERF_HPP_DIFF__DELTA,
PERF_HPP_DIFF__RATIO,
PERF_HPP_DIFF__WEIGHTED_DIFF,
PERF_HPP_DIFF__FORMULA,
PERF_HPP_DIFF__DELTA_ABS,
PERF_HPP_DIFF__CYCLES,
PERF_HPP_DIFF__CYCLES_HIST,
PERF_HPP_DIFF__MAX_INDEX
};
struct diff_hpp_fmt {
struct perf_hpp_fmt fmt;
int idx;
char *header;
int header_width;
};
struct data__file {
struct perf_session *session;
struct perf_data data;
int idx;
struct hists *hists;
struct evlist_streams *evlist_streams;
struct diff_hpp_fmt fmt[PERF_HPP_DIFF__MAX_INDEX];
};
static struct data__file *data__files;
static int data__files_cnt;
#define data__for_each_file_start(i, d, s) \
for (i = s, d = &data__files[s]; \
i < data__files_cnt; \
i++, d = &data__files[i])
#define data__for_each_file(i, d) data__for_each_file_start(i, d, 0)
#define data__for_each_file_new(i, d) data__for_each_file_start(i, d, 1)
static bool force;
static bool show_period;
static bool show_formula;
static bool show_baseline_only;
static bool cycles_hist;
static unsigned int sort_compute = 1;
static s64 compute_wdiff_w1;
static s64 compute_wdiff_w2;
static const char *cpu_list;
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
enum {
COMPUTE_DELTA,
COMPUTE_RATIO,
COMPUTE_WEIGHTED_DIFF,
COMPUTE_DELTA_ABS,
COMPUTE_CYCLES,
COMPUTE_MAX,
COMPUTE_STREAM, /* After COMPUTE_MAX to avoid use current compute arrays */
};
static const char *compute_names[COMPUTE_MAX] = {
[COMPUTE_DELTA] = "delta",
[COMPUTE_DELTA_ABS] = "delta-abs",
[COMPUTE_RATIO] = "ratio",
[COMPUTE_WEIGHTED_DIFF] = "wdiff",
[COMPUTE_CYCLES] = "cycles",
};
static int compute = COMPUTE_DELTA_ABS;
static int compute_2_hpp[COMPUTE_MAX] = {
[COMPUTE_DELTA] = PERF_HPP_DIFF__DELTA,
[COMPUTE_DELTA_ABS] = PERF_HPP_DIFF__DELTA_ABS,
[COMPUTE_RATIO] = PERF_HPP_DIFF__RATIO,
Annotation
- Immediate include surface: `builtin.h`, `perf.h`, `util/debug.h`, `util/event.h`, `util/hist.h`, `util/evsel.h`, `util/evlist.h`, `util/session.h`.
- Detected declarations: `struct perf_diff`, `struct diff_hpp_fmt`, `struct data__file`, `function setup_compute_opt_wdiff`, `function setup_compute_opt`, `function setup_compute`, `function period_percent`, `function compute_delta`, `function compute_ratio`, `function compute_wdiff`.
- 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.