linux/arch
Li RongQing b16a010338 x86/kvm: Prefer native qspinlock for dedicated vCPUs irrespective of PV_UNHALT
[ Upstream commit 9605505039 ]

The commit b2798ba0b8 ("KVM: X86: Choose qspinlock when dedicated
physical CPUs are available") states that when PV_DEDICATED=1
(vCPU has dedicated pCPU), qspinlock should be preferred regardless of
PV_UNHALT.  However, the current implementation doesn't reflect this: when
PV_UNHALT=0, we still use virt_spin_lock() even with dedicated pCPUs.

This is suboptimal because:
1. Native qspinlocks should outperform virt_spin_lock() for dedicated
   vCPUs irrespective of HALT exiting
2. virt_spin_lock() should only be preferred when vCPUs may be preempted
   (non-dedicated case)

So reorder the PV spinlock checks to:
1. First handle dedicated pCPU case (disable virt_spin_lock_key)
2. Second check single CPU, and nopvspin configuration
3. Only then check PV_UNHALT support

This ensures we always use native qspinlock for dedicated vCPUs, delivering
pretty performance gains at high contention levels.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Tested-by: Wangyang Guo <wangyang.guo@intel.com>
Link: https://lore.kernel.org/r/20250722110005.4988-1-lirongqing@baidu.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-12-07 06:09:21 +09:00
..
alpha sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
arc arc: Fix __fls() const-foldability via __builtin_clzl() 2025-12-07 06:09:16 +09:00
arm ARM: OMAP2+: pm33xx-core: ix device node reference leaks in amx3_idle_init 2025-10-19 16:21:43 +02:00
arm64 arm64: errata: Apply workarounds for Neoverse-V3AE 2025-10-29 14:03:13 +01:00
csky sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
h8300 sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
hexagon sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
ia64 sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
m68k m68k: bitops: Fix find_*_bit() signatures 2025-10-29 14:03:10 +01:00
microblaze sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
mips mips: lantiq: xway: sysctrl: rename stp clock 2025-12-07 06:09:20 +09:00
nds32 sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
nios2 nios2: ensure that memblock.current_limit is set when setting pfn limits 2025-10-29 14:03:10 +01:00
openrisc sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
parisc arch: back to -std=gnu89 in < v5.18 2025-12-07 06:09:15 +09:00
powerpc powerpc/eeh: Use result of error_detected() in uevent 2025-12-07 06:09:19 +09:00
riscv riscv: kprobes: Fix probe address validation 2025-10-29 14:03:09 +01:00
s390 arch: back to -std=gnu89 in < v5.18 2025-12-07 06:09:15 +09:00
sh sh: Do not use hyphen in exported variable name 2025-08-28 16:24:11 +02:00
sparc sparc: fix error handling in scan_one_device() 2025-10-19 16:21:47 +02:00
um minmax: make generic MIN() and MAX() macros available everywhere 2025-10-19 16:21:52 +02:00
x86 x86/kvm: Prefer native qspinlock for dedicated vCPUs irrespective of PV_UNHALT 2025-12-07 06:09:21 +09:00
xtensa sched: Add wrapper for get_wchan() to keep task blocked 2025-08-28 16:24:03 +02:00
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-05-02 16:24:48 +02:00