tools/perf/util/block-info.c
Source file repositories/reference/linux-study-clean/tools/perf/util/block-info.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/block-info.c- Extension
.c- Size
- 13565 bytes
- Lines
- 533
- 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.hstring.hlinux/zalloc.hblock-info.hsort.hannotate.hsymbol.hdso.hmap.hsrcline.hevlist.hhist.hui/browsers/hists.h
Detected Declarations
function block_info__deletefunction __block_info__cmpfunction block_info__cmpfunction init_block_infofunction block_info__process_symfunction block_column_headerfunction block_column_widthfunction color_pctfunction block_total_cycles_pct_entryfunction block_total_cycles_pct_sortfunction cycles_stringfunction block_cycles_lbr_entryfunction block_cycles_pct_entryfunction block_avg_cycles_entryfunction block_range_entryfunction block_dso_entryfunction init_block_headerfunction block_branch_counter_entryfunction hpp_registerfunction register_block_columnsfunction init_block_histfunction process_block_reportfunction evlist__for_each_entryfunction block_info__free_reportfunction report__browse_block_histsfunction block_info__total_cycles_percent
Annotated Snippet
if (!bi->br_cntr) {
free(bi);
return NULL;
}
}
return bi;
}
void block_info__delete(struct block_info *bi)
{
if (bi)
free(bi->br_cntr);
free(bi);
}
int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right)
{
struct block_info *bi_l = left->block_info;
struct block_info *bi_r = right->block_info;
int cmp;
if (!bi_l->sym || !bi_r->sym) {
if (!bi_l->sym && !bi_r->sym)
return -1;
else if (!bi_l->sym)
return -1;
else
return 1;
}
cmp = strcmp(bi_l->sym->name, bi_r->sym->name);
if (cmp)
return cmp;
if (bi_l->start != bi_r->start)
return (int64_t)(bi_r->start - bi_l->start);
return (int64_t)(bi_r->end - bi_l->end);
}
int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
struct hist_entry *left, struct hist_entry *right)
{
return __block_info__cmp(left, right);
}
static void init_block_info(struct block_info *bi, struct symbol *sym,
struct cyc_hist *ch, int offset,
u64 total_cycles, unsigned int br_cntr_nr,
u64 *br_cntr, struct evsel *evsel)
{
bi->sym = sym;
bi->start = ch->start;
bi->end = offset;
bi->cycles = ch->cycles;
bi->cycles_aggr = ch->cycles_aggr;
bi->num = ch->num;
bi->num_aggr = ch->num_aggr;
bi->total_cycles = total_cycles;
memcpy(bi->cycles_spark, ch->cycles_spark,
NUM_SPARKS * sizeof(u64));
if (br_cntr && br_cntr_nr) {
bi->br_cntr_nr = br_cntr_nr;
memcpy(bi->br_cntr, &br_cntr[offset * br_cntr_nr],
br_cntr_nr * sizeof(u64));
}
bi->evsel = evsel;
}
int block_info__process_sym(struct hist_entry *he, struct block_hist *bh,
u64 *block_cycles_aggr, u64 total_cycles,
unsigned int br_cntr_nr)
{
struct annotation *notes;
struct cyc_hist *ch;
static struct addr_location al;
u64 cycles = 0;
if (!he->ms.map || !he->ms.sym)
return 0;
memset(&al, 0, sizeof(al));
al.map = he->ms.map;
al.sym = he->ms.sym;
notes = symbol__annotation(he->ms.sym);
if (!notes || !notes->branch || !notes->branch->cycles_hist)
Annotation
- Immediate include surface: `stdlib.h`, `string.h`, `linux/zalloc.h`, `block-info.h`, `sort.h`, `annotate.h`, `symbol.h`, `dso.h`.
- Detected declarations: `function block_info__delete`, `function __block_info__cmp`, `function block_info__cmp`, `function init_block_info`, `function block_info__process_sym`, `function block_column_header`, `function block_column_width`, `function color_pct`, `function block_total_cycles_pct_entry`, `function block_total_cycles_pct_sort`.
- 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.