tools/perf/util/stream.c
Source file repositories/reference/linux-study-clean/tools/perf/util/stream.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/stream.c- Extension
.c- Size
- 8219 bytes
- Lines
- 342
- 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.hstdlib.hlinux/zalloc.hdebug.hhist.hsort.hstream.hevlist.h
Detected Declarations
function Copyrightfunction evlist_streams__deletefunction evsel_streams__set_hot_cnodefunction update_hot_callchainfunction init_hot_callchainfunction evlist__init_callchain_streamsfunction evlist__for_each_entryfunction stream__linkfunction evsel_streams__matchfunction print_callchain_pairfunction list_for_each_entryfunction print_stream_callchainfunction list_for_each_entryfunction callchain_streams_reportfunction evsel_streams__report
Annotated Snippet
if ((es->streams[i].cnode)->hit < hit) {
hit = (es->streams[i].cnode)->hit;
idx = i;
}
}
if (cnode->hit > hit)
es->streams[idx].cnode = cnode;
}
static void update_hot_callchain(struct hist_entry *he,
struct evsel_streams *es)
{
struct rb_root *root = &he->sorted_chain;
struct rb_node *rb_node = rb_first(root);
struct callchain_node *cnode;
while (rb_node) {
cnode = rb_entry(rb_node, struct callchain_node, rb_node);
evsel_streams__set_hot_cnode(es, cnode);
rb_node = rb_next(rb_node);
}
}
static void init_hot_callchain(struct hists *hists, struct evsel_streams *es)
{
struct rb_node *next = rb_first_cached(&hists->entries);
while (next) {
struct hist_entry *he;
he = rb_entry(next, struct hist_entry, rb_node);
update_hot_callchain(he, es);
next = rb_next(&he->rb_node);
}
es->streams_hits = callchain_total_hits(hists);
}
static int evlist__init_callchain_streams(struct evlist *evlist,
struct evlist_streams *els)
{
struct evsel_streams *es = els->ev_streams;
struct evsel *pos;
int i = 0;
BUG_ON(els->nr_evsel < evlist->core.nr_entries);
evlist__for_each_entry(evlist, pos) {
struct hists *hists = evsel__hists(pos);
hists__output_resort(hists, NULL);
init_hot_callchain(hists, &es[i]);
es[i].evsel = pos;
i++;
}
return 0;
}
struct evlist_streams *evlist__create_streams(struct evlist *evlist,
int nr_streams_max)
{
int nr_evsel = evlist->core.nr_entries, ret = -1;
struct evlist_streams *els = evlist_streams__new(nr_evsel,
nr_streams_max);
if (!els)
return NULL;
ret = evlist__init_callchain_streams(evlist, els);
if (ret) {
evlist_streams__delete(els);
return NULL;
}
return els;
}
struct evsel_streams *evsel_streams__entry(struct evlist_streams *els,
const struct evsel *evsel)
{
struct evsel_streams *es = els->ev_streams;
for (int i = 0; i < els->nr_evsel; i++) {
if (es[i].evsel == evsel)
return &es[i];
}
return NULL;
Annotation
- Immediate include surface: `inttypes.h`, `stdlib.h`, `linux/zalloc.h`, `debug.h`, `hist.h`, `sort.h`, `stream.h`, `evlist.h`.
- Detected declarations: `function Copyright`, `function evlist_streams__delete`, `function evsel_streams__set_hot_cnode`, `function update_hot_callchain`, `function init_hot_callchain`, `function evlist__init_callchain_streams`, `function evlist__for_each_entry`, `function stream__link`, `function evsel_streams__match`, `function print_callchain_pair`.
- 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.