xemu/accel
Maciej S. Szmigiero 2dc652961d target/i386: Reset TSCs of parked vCPUs too on VM reset
Since commit 5286c36622 ("target/i386: properly reset TSC on reset")
QEMU writes the special value of "1" to each online vCPU TSC on VM reset
to reset it.

However parked vCPUs don't get that handling and due to that their TSCs
get desynchronized when the VM gets reset.
This in turn causes KVM to turn off PVCLOCK_TSC_STABLE_BIT in its exported
PV clock.
Note that KVM has no understanding of vCPU being currently parked.

Without PVCLOCK_TSC_STABLE_BIT the sched clock is marked unstable in
the guest's kvm_sched_clock_init().
This causes a performance regressions to show in some tests.

Fix this issue by writing the special value of "1" also to TSCs of parked
vCPUs on VM reset.

Reproducing the issue:
1) Boot a VM with "-smp 2,maxcpus=3" or similar

2) device_add host-x86_64-cpu,id=vcpu,node-id=0,socket-id=0,core-id=2,thread-id=0

3) Wait a few seconds

4) device_del vcpu

5) Inside the VM run:
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
Observe the sched_clock_stable() value is 1.

6) Reboot the VM

7) Once the VM boots once again run inside it:
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
Observe the sched_clock_stable() value is now 0.

Fixes: 5286c36622 ("target/i386: properly reset TSC on reset")
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Link: https://lore.kernel.org/r/5a605a88e9a231386dc803c60f5fed9b48108139.1734014926.git.maciej.szmigiero@oracle.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 3f2a05b31ee9ce2ddb6c75a9bc3f5e7f7af9a76f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2024-12-22 11:18:15 +03:00
..
hvf hvf: arm: Implement and use hvf_get_physical_address_range 2024-09-13 15:31:47 +01:00
kvm target/i386: Reset TSCs of parked vCPUs too on VM reset 2024-12-22 11:18:15 +03:00
qtest qtest: move qtest_{get, set}_virtual_clock to accel/qtest/qtest.c 2024-06-24 10:14:56 +01:00
stubs accel: Restrict probe_access*() functions to TCG 2024-07-23 18:08:44 +02:00
tcg tcg: Reset free_temps before tcg_optimize 2024-12-13 15:51:03 +03:00
xen hw/xen: Extract 'xen_igd.h' from 'xen_pt.h' 2024-03-09 18:51:45 +01:00
Kconfig i386: xen: fix compilation --without-default-devices 2024-02-16 13:56:09 +01:00
accel-blocker.c include: Move QemuLockCnt APIs to their own header 2024-10-15 15:16:17 +01:00
accel-system.c accel: remove dead statement and useless assertion 2024-10-31 18:28:32 +01:00
accel-system.h accel: Rename accel_init_ops_interfaces() to include 'system' 2024-01-19 12:28:59 +01:00
accel-target.c accel: Rename accel_init_ops_interfaces() to include 'system' 2024-01-19 12:28:59 +01:00
accel-user.c accel: extend AccelState and AccelClass to user-mode 2021-02-05 10:24:15 -10:00
dummy-cpus.c cpu: move Qemu[Thread|Cond] setup into common code 2024-06-04 10:02:39 +02:00
meson.build accel: Rename accel_softmmu* -> accel_system* 2023-10-07 19:02:57 +02:00