tools/perf/util/hist.c
Source file repositories/reference/linux-study-clean/tools/perf/util/hist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/hist.c- Extension
.c- Size
- 77358 bytes
- Lines
- 3099
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
callchain.hdebug.hdso.hbuild-id.hhist.hkvm-stat.hmap.hmap_symbol.hbranch.hmem-events.hmem-info.hsession.hnamespaces.hcgroup.hsort.hunits.hevlist.hevsel.hannotate.hsrcline.hsymbol.hthread.hblock-info.hui/progress.herrno.hmath.hinttypes.hsys/param.hlinux/rbtree.hlinux/string.hlinux/time64.hlinux/zalloc.h
Detected Declarations
function hists__col_lenfunction hists__set_col_lenfunction hists__new_col_lenfunction hists__reset_col_lenfunction hists__set_unres_dso_col_lenfunction hists__calc_col_lenfunction hists__output_recalc_col_lenfunction he_stat__add_cpumode_periodfunction hist_timefunction he_stat__add_periodfunction he_stat__add_statfunction he_stat__decayfunction hists__update_mem_statfunction hists__add_mem_statfunction hists__clone_mem_statfunction hists__decay_mem_statfunction hists__decay_entryfunction hists__delete_entryfunction hists__decay_entriesfunction hists__delete_entriesfunction hist_entry__initfunction hist_entry__freefunction symbol__parent_filterfunction hist_entry__add_callchain_periodfunction random_maxfunction hists__res_samplefunction __hists__add_entryfunction iter_next_nop_entryfunction iter_add_next_nop_entryfunction iter_prepare_mem_entryfunction iter_add_single_mem_entryfunction iter_finish_mem_entryfunction iter_prepare_branch_entryfunction iter_add_single_branch_entryfunction iter_next_branch_entryfunction iter_add_next_branch_entryfunction branch_info__exitfunction iter_finish_branch_entryfunction iter_prepare_normal_entryfunction iter_add_single_normal_entryfunction iter_finish_normal_entryfunction iter_prepare_cumulative_entryfunction iter_add_single_cumulative_entryfunction iter_next_cumulative_entryfunction hist_entry__fast__sym_difffunction iter_add_next_cumulative_entryfunction iter_finish_cumulative_entryfunction hist_entry_iter__add
Annotated Snippet
if (h->branch_info->from.ms.sym) {
symlen = (int)h->branch_info->from.ms.sym->namelen + 4;
if (verbose > 0)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
symlen = dso__name_len(map__dso(h->branch_info->from.ms.map));
hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
hists__new_col_len(hists, HISTC_ADDR_FROM, symlen);
hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
}
if (h->branch_info->to.ms.sym) {
symlen = (int)h->branch_info->to.ms.sym->namelen + 4;
if (verbose > 0)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
symlen = dso__name_len(map__dso(h->branch_info->to.ms.map));
hists__new_col_len(hists, HISTC_DSO_TO, symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
hists__new_col_len(hists, HISTC_ADDR_TO, symlen);
hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
}
if (h->branch_info->srcline_from)
hists__new_col_len(hists, HISTC_SRCLINE_FROM,
strlen(h->branch_info->srcline_from));
if (h->branch_info->srcline_to)
hists__new_col_len(hists, HISTC_SRCLINE_TO,
strlen(h->branch_info->srcline_to));
}
if (h->mem_info) {
if (mem_info__daddr(h->mem_info)->ms.sym) {
symlen = (int)mem_info__daddr(h->mem_info)->ms.sym->namelen + 4
+ unresolved_col_width + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
symlen);
hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
symlen + 1);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
symlen);
hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
symlen);
}
if (mem_info__iaddr(h->mem_info)->ms.sym) {
symlen = (int)mem_info__iaddr(h->mem_info)->ms.sym->namelen + 4
+ unresolved_col_width + 2;
hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
symlen);
}
if (mem_info__daddr(h->mem_info)->ms.map) {
symlen = dso__name_len(map__dso(mem_info__daddr(h->mem_info)->ms.map));
hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
}
hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR,
unresolved_col_width + 4 + 2);
hists__new_col_len(hists, HISTC_MEM_DATA_PAGE_SIZE,
unresolved_col_width + 4 + 2);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL, symlen);
hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
}
hists__new_col_len(hists, HISTC_CGROUP, 6);
hists__new_col_len(hists, HISTC_CGROUP_ID, 20);
hists__new_col_len(hists, HISTC_PARALLELISM, 11);
Annotation
- Immediate include surface: `callchain.h`, `debug.h`, `dso.h`, `build-id.h`, `hist.h`, `kvm-stat.h`, `map.h`, `map_symbol.h`.
- Detected declarations: `function hists__col_len`, `function hists__set_col_len`, `function hists__new_col_len`, `function hists__reset_col_len`, `function hists__set_unres_dso_col_len`, `function hists__calc_col_len`, `function hists__output_recalc_col_len`, `function he_stat__add_cpumode_period`, `function hist_time`, `function he_stat__add_period`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.