From: "Guo, Wangyang" <wangyang.guo@intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
"Li,Rongqing" <lirongqing@baidu.com>
Cc: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"Li, Tianyou" <tianyou.li@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>
Subject: Re: [????] RE: [PATCH RESEND^2] x86/paravirt: add backoff mechanism to virt_spin_lock
Date: Fri, 15 Aug 2025 10:47:27 +0800 [thread overview]
Message-ID: <066780ea-95f0-49c4-938a-3405975ebf60@intel.com> (raw)
In-Reply-To: <20250814104156.GV4067720@noisy.programming.kicks-ass.net>
On 8/14/2025 6:41 PM, Peter Zijlstra wrote:
> On Thu, Aug 14, 2025 at 03:10:46AM +0000, Li,Rongqing wrote:
>>> On 8/13/2025 10:33 PM, Peter Zijlstra wrote:
>>>> On Wed, Aug 13, 2025 at 08:50:43AM +0800, Wangyang Guo wrote:
>>>>> Binary exponential backoff is introduced. As try-lock attempt
>>>>> increases, there is more likely that a larger number threads compete
>>>>> for the same lock, so increase wait time in exponential.
>>>>
>>>> You shouldn't be using virt_spin_lock() to begin with. That means
>>>> you've misconfigured your guest.
>>>>
>>>> We have paravirt spinlocks for a reason.
>>>
>>> We have tried PARAVIRT_SPINLOCKS, it can help to reduce the contention cycles,
>>> but the throughput is not good. I think there are two factors:
>>>
>>> 1. the VM is not overcommit, each thread has its CPU resources to doing spin
>>> wait.
>>
>> If vm is not overcommit, guest should have KVM_HINTS_REALTIME, I think native qspinlock should be better
>> Could you try test this patch
>> https://patchwork.kernel.org/project/kvm/patch/20250722110005.4988-1-lirongqing@baidu.com/
>
> Right, that's the knob.
Yes, that works.
By providing qemu-kvm with `-cpu host,kvm-hint-dedicated` option, it can
use mcs qspinlock and have better performance compared to virt_spin_lock().
But for non-overcommit VM, we may add `-overcommit cpu-pm=on` to let
guest to handle idle by itself and reduce the guest latency. Current
kernel will fallback to virt_spin_lock, even kvm-hint-dedicated is
provided. With Rongqing's patch, it can fix this problem.
BR
Wangyang
next prev parent reply other threads:[~2025-08-15 2:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 0:50 Wangyang Guo
2025-08-13 14:23 ` Dave Hansen
2025-08-14 1:14 ` Guo, Wangyang
2025-08-13 14:33 ` Peter Zijlstra
2025-08-14 1:26 ` Guo, Wangyang
2025-08-14 3:10 ` [????] " Li,Rongqing
2025-08-14 10:41 ` Peter Zijlstra
2025-08-15 2:47 ` Guo, Wangyang [this message]
2025-08-14 10:39 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=066780ea-95f0-49c4-938a-3405975ebf60@intel.com \
--to=wangyang.guo@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=tianyou.li@intel.com \
--cc=tim.c.chen@linux.intel.com \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®