tools/testing/selftests/kvm/x86/tsc_scaling_sync.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/tsc_scaling_sync.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/tsc_scaling_sync.c- Extension
.c- Size
- 2451 bytes
- Lines
- 111
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
test_util.hkvm_util.hprocessor.hstdint.htime.hsched.hsignal.hpthread.h
Detected Declarations
function guest_codefunction main
Annotated Snippet
switch (get_ucall(vcpu, &uc)) {
case UCALL_DONE:
goto out;
case UCALL_SYNC:
printf("Guest %d sync %lx %lx %ld\n", vcpu->id,
uc.args[2], uc.args[3], uc.args[2] - uc.args[3]);
failures++;
break;
default:
TEST_FAIL("Unknown ucall %lu", uc.cmd);
}
}
out:
return (void *)failures;
}
int main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_has_cap(KVM_CAP_VM_TSC_CONTROL));
vm = vm_create(NR_TEST_VCPUS);
vm_ioctl(vm, KVM_SET_TSC_KHZ, (void *) TEST_TSC_KHZ);
pthread_spin_init(&create_lock, PTHREAD_PROCESS_PRIVATE);
pthread_t cpu_threads[NR_TEST_VCPUS];
unsigned long cpu;
for (cpu = 0; cpu < NR_TEST_VCPUS; cpu++)
pthread_create(&cpu_threads[cpu], NULL, run_vcpu, (void *)cpu);
unsigned long failures = 0;
for (cpu = 0; cpu < NR_TEST_VCPUS; cpu++) {
void *this_cpu_failures;
pthread_join(cpu_threads[cpu], &this_cpu_failures);
failures += (unsigned long)this_cpu_failures;
}
TEST_ASSERT(!failures, "TSC sync failed");
pthread_spin_destroy(&create_lock);
kvm_vm_free(vm);
return 0;
}
Annotation
- Immediate include surface: `test_util.h`, `kvm_util.h`, `processor.h`, `stdint.h`, `time.h`, `sched.h`, `signal.h`, `pthread.h`.
- Detected declarations: `function guest_code`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.