tools/perf/ui/browsers/annotate-data.c
Source file repositories/reference/linux-study-clean/tools/perf/ui/browsers/annotate-data.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/ui/browsers/annotate-data.c- Extension
.c- Size
- 15322 bytes
- Lines
- 615
- 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
inttypes.hstring.hlinux/zalloc.hsys/ttydefaults.hui/browser.hui/helpline.hui/keysyms.hui/ui.hutil/annotate.hutil/annotate-data.hutil/evsel.hutil/evlist.hutil/sort.h
Detected Declarations
struct browser_entrystruct annotated_data_browserfunction update_hist_entryfunction get_member_overheadfunction for_each_group_evselfunction add_child_entriesfunction list_for_each_entryfunction count_visible_entriesfunction annotated_data_browser__collect_entriesfunction annotated_data_browser__delete_entriesfunction list_for_each_entry_safefunction is_first_childfunction is_last_childfunction browser__seekfunction browser__refreshfunction browser__showfunction browser__write_overheadfunction browser__writefunction annotated_data_browser__foldfunction annotated_data_browser__unfoldfunction annotated_data_browser__toggle_foldfunction annotated_data_browser__runfunction hist_entry__annotate_data_tuifunction for_each_group_evsel
Annotated Snippet
struct browser_entry {
struct list_head node;
struct annotated_member *data;
struct type_hist_entry *hists;
struct browser_entry *parent;
struct list_head children;
int indent; /*indentation level, starts from 0 */
int nr_entries; /* # of visible entries: self + descendents */
bool folded; /* only can be false when it has children */
};
struct annotated_data_browser {
struct ui_browser b;
struct list_head entries;
struct browser_entry *curr;
int nr_events;
};
static struct annotated_data_browser *get_browser(struct ui_browser *uib)
{
return container_of(uib, struct annotated_data_browser, b);
}
static void update_hist_entry(struct type_hist_entry *dst,
struct type_hist_entry *src)
{
dst->nr_samples += src->nr_samples;
dst->period += src->period;
}
static int get_member_overhead(struct annotated_data_type *adt,
struct browser_entry *entry,
struct evsel *leader)
{
struct annotated_member *member = entry->data;
int i, k;
for (i = 0; i < member->size; i++) {
struct type_hist *h;
struct evsel *evsel;
int offset = member->offset + i;
k = 0;
for_each_group_evsel(evsel, leader) {
if (symbol_conf.skip_empty &&
evsel__hists(evsel)->stats.nr_samples == 0)
continue;
h = adt->histograms[evsel->core.idx];
update_hist_entry(&entry->hists[k++], &h->addr[offset]);
}
}
return 0;
}
static int add_child_entries(struct annotated_data_browser *browser,
struct browser_entry *parent,
struct annotated_data_type *adt,
struct annotated_member *member,
struct evsel *evsel, int indent)
{
struct annotated_member *pos;
struct browser_entry *entry;
struct list_head *parent_list;
entry = zalloc(sizeof(*entry));
if (entry == NULL)
return -1;
entry->hists = calloc(browser->nr_events, sizeof(*entry->hists));
if (entry->hists == NULL) {
free(entry);
return -1;
}
entry->data = member;
entry->parent = parent;
entry->indent = indent;
if (get_member_overhead(adt, entry, evsel) < 0) {
free(entry);
return -1;
}
INIT_LIST_HEAD(&entry->children);
if (parent)
parent_list = &parent->children;
else
parent_list = &browser->entries;
list_add_tail(&entry->node, parent_list);
Annotation
- Immediate include surface: `inttypes.h`, `string.h`, `linux/zalloc.h`, `sys/ttydefaults.h`, `ui/browser.h`, `ui/helpline.h`, `ui/keysyms.h`, `ui/ui.h`.
- Detected declarations: `struct browser_entry`, `struct annotated_data_browser`, `function update_hist_entry`, `function get_member_overhead`, `function for_each_group_evsel`, `function add_child_entries`, `function list_for_each_entry`, `function count_visible_entries`, `function annotated_data_browser__collect_entries`, `function annotated_data_browser__delete_entries`.
- 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.