tools/perf/ui/stdio/hist.c
Source file repositories/reference/linux-study-clean/tools/perf/ui/stdio/hist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/ui/stdio/hist.c- Extension
.c- Size
- 22491 bytes
- Lines
- 944
- 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
limits.hstdio.hstdlib.hlinux/string.h../../util/callchain.h../../util/debug.h../../util/event.h../../util/hist.h../../util/map.h../../util/maps.h../../util/symbol.h../../util/sort.h../../util/evsel.h../../util/srcline.h../../util/string2.h../../util/thread.h../../util/block-info.hlinux/ctype.hlinux/zalloc.h
Detected Declarations
function callchain__fprintf_left_marginfunction ipchain__fprintf_graph_linefunction ipchain__fprintf_graphfunction init_rem_hitsfunction __callchain__fprintf_graphfunction list_for_each_entryfunction percentagefunction callchain__fprintf_graphfunction list_for_each_entryfunction __callchain__fprintf_flatfunction list_for_each_entryfunction callchain__fprintf_flatfunction __callchain__fprintf_foldedfunction callchain__fprintf_foldedfunction hist_entry_callchain__fprintffunction __hist_entry__snprintffunction perf_hpp_list__for_each_formatfunction hist_entry__snprintffunction hist_entry__hierarchy_fprintffunction perf_hpp_list__for_each_formatfunction hist_entry__block_fprintffunction hist_entry__individual_block_fprintffunction hist_entry__fprintffunction print_hierarchy_indentfunction hists__fprintf_hierarchy_headersfunction perf_hpp_list__for_each_formatfunction list_for_each_entry_continuefunction perf_hpp_list__for_each_formatfunction perf_hpp_list__for_each_formatfunction fprintf_linefunction hists__for_each_formatfunction hists__fprintf_standard_headersfunction hists__for_each_formatfunction hists__fprintf_headersfunction hists__fprintffunction events_stats__fprintf
Annotated Snippet
if (!period && i == depth - 1) {
ret += fprintf(fp, "--");
ret += callchain_node__fprintf_value(node, fp, total_samples);
ret += fprintf(fp, "--");
} else
ret += fprintf(fp, "%s", " ");
}
str = callchain_list__sym_name(chain, bf, sizeof(bf), false);
if (symbol_conf.show_branchflag_count) {
callchain_list_counts__printf_value(chain, NULL,
buf, sizeof(buf));
if (asprintf(&alloc_str, "%s%s", str, buf) < 0)
str = "Not enough memory!";
else
str = alloc_str;
}
fputs(str, fp);
fputc('\n', fp);
free(alloc_str);
return ret;
}
static struct symbol *rem_sq_bracket;
static struct callchain_list rem_hits;
static void init_rem_hits(void)
{
rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
if (!rem_sq_bracket) {
fprintf(stderr, "Not enough memory to display remaining hits\n");
return;
}
strcpy(rem_sq_bracket->name, "[...]");
rem_hits.ms.sym = rem_sq_bracket;
}
static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,
u64 total_samples, int depth,
int depth_mask, int left_margin)
{
struct rb_node *node, *next;
struct callchain_node *child = NULL;
struct callchain_list *chain;
int new_depth_mask = depth_mask;
u64 remaining;
size_t ret = 0;
int i;
uint entries_printed = 0;
int cumul_count = 0;
remaining = total_samples;
node = rb_first(root);
while (node) {
u64 new_total;
u64 cumul;
child = rb_entry(node, struct callchain_node, rb_node);
cumul = callchain_cumul_hits(child);
remaining -= cumul;
cumul_count += callchain_cumul_counts(child);
/*
* The depth mask manages the output of pipes that show
* the depth. We don't want to keep the pipes of the current
* level for the last child of this depth.
* Except if we have remaining filtered hits. They will
* supersede the last child
*/
next = rb_next(node);
if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
new_depth_mask &= ~(1 << (depth - 1));
/*
* But we keep the older depth mask for the line separator
* to keep the level link until we reach the last child
*/
ret += ipchain__fprintf_graph_line(fp, depth, depth_mask,
left_margin);
i = 0;
list_for_each_entry(chain, &child->val, list) {
ret += ipchain__fprintf_graph(fp, child, chain, depth,
new_depth_mask, i++,
total_samples,
Annotation
- Immediate include surface: `limits.h`, `stdio.h`, `stdlib.h`, `linux/string.h`, `../../util/callchain.h`, `../../util/debug.h`, `../../util/event.h`, `../../util/hist.h`.
- Detected declarations: `function callchain__fprintf_left_margin`, `function ipchain__fprintf_graph_line`, `function ipchain__fprintf_graph`, `function init_rem_hits`, `function __callchain__fprintf_graph`, `function list_for_each_entry`, `function percentage`, `function callchain__fprintf_graph`, `function list_for_each_entry`, `function __callchain__fprintf_flat`.
- 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.