tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
Source file repositories/reference/linux-study-clean/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c- Extension
.c- Size
- 7125 bytes
- Lines
- 275
- 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
errno.hstring.h../kvm-stat.h../evsel.h../env.h../../../arch/x86/include/uapi/asm/svm.h../../../arch/x86/include/uapi/asm/vmx.h../../../arch/x86/include/uapi/asm/kvm.hsubcmd/parse-options.h
Detected Declarations
function mmio_event_get_keyfunction mmio_event_beginfunction evsel__intvalfunction mmio_event_endfunction evsel__intvalfunction mmio_event_decode_keyfunction ioport_event_get_keyfunction ioport_event_beginfunction ioport_event_endfunction ioport_event_decode_keyfunction msr_event_get_keyfunction msr_event_beginfunction msr_event_endfunction msr_event_decode_keyfunction __cpu_isa_init_x86function __kvm_add_default_arch_event_x86
Annotated Snippet
evsel__intval(evsel, sample, "type") == KVM_TRACE_MMIO_WRITE) {
mmio_event_get_key(evsel, sample, key);
return true;
}
return false;
}
static bool mmio_event_end(struct evsel *evsel, struct perf_sample *sample,
struct event_key *key)
{
/* MMIO write end event in kernel. */
if (kvm_entry_event(evsel))
return true;
/* MMIO read end event in kernel.*/
if (evsel__name_is(evsel, "kvm:kvm_mmio") &&
evsel__intval(evsel, sample, "type") == KVM_TRACE_MMIO_READ) {
mmio_event_get_key(evsel, sample, key);
return true;
}
return false;
}
static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
struct event_key *key,
char *decode)
{
scnprintf(decode, KVM_EVENT_NAME_LEN, "%#lx:%s",
(unsigned long)key->key,
key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
}
static const struct kvm_events_ops mmio_events = {
.is_begin_event = mmio_event_begin,
.is_end_event = mmio_event_end,
.decode_key = mmio_event_decode_key,
.name = "MMIO Access"
};
/* The time of emulation pio access is from kvm_pio to kvm_entry. */
static void ioport_event_get_key(struct evsel *evsel,
struct perf_sample *sample,
struct event_key *key)
{
key->key = evsel__intval(evsel, sample, "port");
key->info = evsel__intval(evsel, sample, "rw");
}
static bool ioport_event_begin(struct evsel *evsel,
struct perf_sample *sample,
struct event_key *key)
{
if (evsel__name_is(evsel, "kvm:kvm_pio")) {
ioport_event_get_key(evsel, sample, key);
return true;
}
return false;
}
static bool ioport_event_end(struct evsel *evsel,
struct perf_sample *sample __maybe_unused,
struct event_key *key __maybe_unused)
{
return kvm_entry_event(evsel);
}
static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
struct event_key *key,
char *decode)
{
scnprintf(decode, KVM_EVENT_NAME_LEN, "%#llx:%s",
(unsigned long long)key->key,
key->info ? "POUT" : "PIN");
}
static const struct kvm_events_ops ioport_events = {
.is_begin_event = ioport_event_begin,
.is_end_event = ioport_event_end,
.decode_key = ioport_event_decode_key,
.name = "IO Port Access"
};
/* The time of emulation msr is from kvm_msr to kvm_entry. */
static void msr_event_get_key(struct evsel *evsel,
struct perf_sample *sample,
struct event_key *key)
{
Annotation
- Immediate include surface: `errno.h`, `string.h`, `../kvm-stat.h`, `../evsel.h`, `../env.h`, `../../../arch/x86/include/uapi/asm/svm.h`, `../../../arch/x86/include/uapi/asm/vmx.h`, `../../../arch/x86/include/uapi/asm/kvm.h`.
- Detected declarations: `function mmio_event_get_key`, `function mmio_event_begin`, `function evsel__intval`, `function mmio_event_end`, `function evsel__intval`, `function mmio_event_decode_key`, `function ioport_event_get_key`, `function ioport_event_begin`, `function ioport_event_end`, `function ioport_event_decode_key`.
- 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.