tools/perf/util/sideband_evlist.c
Source file repositories/reference/linux-study-clean/tools/perf/util/sideband_evlist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/sideband_evlist.c- Extension
.c- Size
- 3505 bytes
- Lines
- 150
- 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
util/debug.hutil/evlist.hutil/evsel.hutil/mmap.hutil/perf_api_probe.hperf/mmap.hlinux/perf_event.hlimits.hpthread.hsched.hstdbool.h
Detected Declarations
function evlist__add_sb_eventfunction evlist__set_cbfunction evlist__for_each_entryfunction evlist__start_sb_threadfunction evlist__for_each_entryfunction evlist__for_each_entryfunction evlist__stop_sb_thread
Annotated Snippet
while ((event = perf_mmap__read_event(&map->core)) != NULL) {
struct evsel *evsel = evlist__event2evsel(evlist, event);
if (evsel && evsel->side_band.cb)
evsel->side_band.cb(event, evsel->side_band.data);
else
pr_warning("cannot locate proper evsel for the side band event\n");
perf_mmap__consume(&map->core);
got_data = true;
}
perf_mmap__read_done(&map->core);
}
if (draining && !got_data)
break;
}
return NULL;
}
void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel) {
evsel->core.attr.sample_id_all = 1;
evsel->core.attr.watermark = 1;
evsel->core.attr.wakeup_watermark = 1;
evsel->side_band.cb = cb;
evsel->side_band.data = data;
}
}
int evlist__start_sb_thread(struct evlist *evlist, struct target *target)
{
struct evsel *counter;
if (!evlist)
return 0;
if (evlist__create_maps(evlist, target))
goto out_delete_evlist;
if (evlist->core.nr_entries > 1) {
bool can_sample_identifier = perf_can_sample_identifier();
evlist__for_each_entry(evlist, counter)
evsel__set_sample_id(counter, can_sample_identifier);
evlist__set_id_pos(evlist);
}
evlist__for_each_entry(evlist, counter) {
if (evsel__open(counter, evlist->core.user_requested_cpus,
evlist->core.threads) < 0)
goto out_delete_evlist;
}
if (evlist__mmap(evlist, UINT_MAX))
goto out_delete_evlist;
evlist__for_each_entry(evlist, counter) {
if (evsel__enable(counter))
goto out_delete_evlist;
}
evlist->thread.done = 0;
if (pthread_create(&evlist->thread.th, NULL, perf_evlist__poll_thread, evlist))
goto out_delete_evlist;
return 0;
out_delete_evlist:
evlist__delete(evlist);
evlist = NULL;
return -1;
}
void evlist__stop_sb_thread(struct evlist *evlist)
{
if (!evlist)
return;
evlist->thread.done = 1;
pthread_join(evlist->thread.th, NULL);
evlist__delete(evlist);
}
Annotation
- Immediate include surface: `util/debug.h`, `util/evlist.h`, `util/evsel.h`, `util/mmap.h`, `util/perf_api_probe.h`, `perf/mmap.h`, `linux/perf_event.h`, `limits.h`.
- Detected declarations: `function evlist__add_sb_event`, `function evlist__set_cb`, `function evlist__for_each_entry`, `function evlist__start_sb_thread`, `function evlist__for_each_entry`, `function evlist__for_each_entry`, `function evlist__stop_sb_thread`.
- 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.