tools/perf/builtin-kvm.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-kvm.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-kvm.c- Extension
.c- Size
- 52465 bytes
- Lines
- 2193
- 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
builtin.hperf.hdwarf-regs.hutil/build-id.hutil/evsel.hutil/evlist.hutil/mmap.hutil/term.hutil/symbol.hutil/thread.hutil/header.hutil/session.hutil/intlist.hsubcmd/pager.hsubcmd/parse-options.hutil/trace-event.hutil/debug.hutil/tool.hutil/stat.hutil/synthetic-events.hutil/top.hutil/data.hutil/ordered-events.hutil/kvm-stat.hutil/util.hui/browsers/hists.hui/progress.hui/ui.hutil/string2.hsys/prctl.hsys/timerfd.hsys/time.h
Detected Declarations
struct kvm_histsstruct kvm_dimensionstruct kvm_fmtstruct vcpu_event_recordfunction ev_name_cmpfunction ev_name_entryfunction ev_entry_meanfunction percentfunction ev_entry_time_precentfunction ev_cmp_time_precentfunction ev_entry_count_precentfunction ev_cmp_count_precentfunction fmt_widthfunction fmt_headerfunction fmt_equalfunction fmt_freefunction kvm_hists__init_outputfunction kvm_hists__init_sortfunction kvm_hpp_list__initfunction kvm_hpp_list__parsefunction kvm_hists__initfunction kvm_hists__reinitfunction kvm_browser__update_nr_entriesfunction kvm_browser__titlefunction perf_kvm_browser__newfunction kvm__hists_browsefunction kvm_displayfunction kvm_displayfunction register_kvm_events_opsfunction clear_events_cache_statsfunction kvm_event_expandfunction kvm_he_freefunction handle_begin_eventfunction kvm_update_event_statsfunction kvm_event_rel_stddevfunction update_kvm_eventfunction is_child_eventfunction handle_child_eventfunction skip_eventfunction handle_end_eventfunction handle_kvm_eventfunction is_valid_keyfunction event_is_validfunction filter_cbfunction sort_resultfunction print_vcpu_infofunction show_timeofdayfunction print_result
Annotated Snippet
struct kvm_hists {
struct hists hists;
struct perf_hpp_list list;
};
struct kvm_dimension {
const char *name;
const char *header;
int width;
int64_t (*cmp)(struct perf_hpp_fmt *fmt, struct hist_entry *left,
struct hist_entry *right);
int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
struct hist_entry *he);
};
struct kvm_fmt {
struct perf_hpp_fmt fmt;
struct kvm_dimension *dim;
};
static struct kvm_hists kvm_hists;
static int64_t ev_name_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
struct hist_entry *left,
struct hist_entry *right)
{
/* Return opposite number for sorting in alphabetical order */
return -strcmp(left->kvm_info->name, right->kvm_info->name);
}
static int fmt_width(struct perf_hpp_fmt *fmt,
struct perf_hpp *hpp __maybe_unused,
struct hists *hists __maybe_unused);
static int ev_name_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
struct hist_entry *he)
{
int width = fmt_width(fmt, hpp, he->hists);
return scnprintf(hpp->buf, hpp->size, "%*s", width, he->kvm_info->name);
}
static struct kvm_dimension dim_event = {
.header = "Event name",
.name = "ev_name",
.cmp = ev_name_cmp,
.entry = ev_name_entry,
.width = 40,
};
#define EV_METRIC_CMP(metric) \
static int64_t ev_cmp_##metric(struct perf_hpp_fmt *fmt __maybe_unused, \
struct hist_entry *left, \
struct hist_entry *right) \
{ \
struct kvm_event *event_left; \
struct kvm_event *event_right; \
struct perf_kvm_stat *perf_kvm; \
\
event_left = container_of(left, struct kvm_event, he); \
event_right = container_of(right, struct kvm_event, he); \
\
perf_kvm = event_left->perf_kvm; \
return cmp_event_##metric(event_left, event_right, \
perf_kvm->trace_vcpu); \
}
EV_METRIC_CMP(time)
EV_METRIC_CMP(count)
EV_METRIC_CMP(max)
EV_METRIC_CMP(min)
EV_METRIC_CMP(mean)
#define EV_METRIC_ENTRY(metric) \
static int ev_entry_##metric(struct perf_hpp_fmt *fmt, \
struct perf_hpp *hpp, \
struct hist_entry *he) \
{ \
struct kvm_event *event; \
int width = fmt_width(fmt, hpp, he->hists); \
struct perf_kvm_stat *perf_kvm; \
\
event = container_of(he, struct kvm_event, he); \
perf_kvm = event->perf_kvm; \
return scnprintf(hpp->buf, hpp->size, "%*lu", width, \
get_event_##metric(event, perf_kvm->trace_vcpu)); \
}
EV_METRIC_ENTRY(time)
EV_METRIC_ENTRY(count)
Annotation
- Immediate include surface: `builtin.h`, `perf.h`, `dwarf-regs.h`, `util/build-id.h`, `util/evsel.h`, `util/evlist.h`, `util/mmap.h`, `util/term.h`.
- Detected declarations: `struct kvm_hists`, `struct kvm_dimension`, `struct kvm_fmt`, `struct vcpu_event_record`, `function ev_name_cmp`, `function ev_name_entry`, `function ev_entry_mean`, `function percent`, `function ev_entry_time_precent`, `function ev_cmp_time_precent`.
- 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.