tools/testing/selftests/kvm/x86/aperfmperf_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/aperfmperf_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/aperfmperf_test.c- Extension
.c- Size
- 5378 bytes
- Lines
- 214
- 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
fcntl.hlimits.hstdbool.hstdio.hstdint.hunistd.hasm/msr-index.hkvm_util.hprocessor.hsvm_util.htest_util.hvmx.h
Detected Declarations
function Copyrightfunction read_dev_msrfunction guest_read_aperf_mperffunction l2_guest_codefunction l1_svm_codefunction l1_vmx_codefunction guest_codefunction guest_no_aperfmperffunction main
Annotated Snippet
switch (get_ucall(vcpu, &uc)) {
case UCALL_DONE:
goto done;
case UCALL_ABORT:
REPORT_GUEST_ASSERT(uc);
case UCALL_SYNC:
guest_aperf = uc.args[0];
guest_mperf = uc.args[1];
host_aperf_after = read_dev_msr(msr_fd, MSR_IA32_APERF);
host_mperf_after = read_dev_msr(msr_fd, MSR_IA32_MPERF);
TEST_ASSERT(host_aperf_before < guest_aperf,
"APERF: host_before (0x%" PRIx64 ") >= guest (0x%" PRIx64 ")",
host_aperf_before, guest_aperf);
TEST_ASSERT(guest_aperf < host_aperf_after,
"APERF: guest (0x%" PRIx64 ") >= host_after (0x%" PRIx64 ")",
guest_aperf, host_aperf_after);
TEST_ASSERT(host_mperf_before < guest_mperf,
"MPERF: host_before (0x%" PRIx64 ") >= guest (0x%" PRIx64 ")",
host_mperf_before, guest_mperf);
TEST_ASSERT(guest_mperf < host_mperf_after,
"MPERF: guest (0x%" PRIx64 ") >= host_after (0x%" PRIx64 ")",
guest_mperf, host_mperf_after);
host_aperf_before = host_aperf_after;
host_mperf_before = host_mperf_after;
break;
}
}
TEST_FAIL("Didn't receive UCALL_DONE\n");
done:
kvm_vm_free(vm);
close(msr_fd);
return 0;
}
Annotation
- Immediate include surface: `fcntl.h`, `limits.h`, `stdbool.h`, `stdio.h`, `stdint.h`, `unistd.h`, `asm/msr-index.h`, `kvm_util.h`.
- Detected declarations: `function Copyright`, `function read_dev_msr`, `function guest_read_aperf_mperf`, `function l2_guest_code`, `function l1_svm_code`, `function l1_vmx_code`, `function guest_code`, `function guest_no_aperfmperf`, `function main`.
- 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.