mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Li,Rongqing" <lirongqing@baidu.com>
Cc: "Guo, Wangyang" <wangyang.guo@intel.com>,
	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: Thu, 14 Aug 2025 12:41:56 +0200	[thread overview]
Message-ID: <20250814104156.GV4067720@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <bb474c693d77428eb0336566150a1ea3@baidu.com>

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:
> > >> When multiple threads waiting for lock at the same time, once lock
> > >> owner releases the lock, waiters will see lock available and all try
> > >> to lock, which may cause an expensive CAS storm.
> > >>
> > >> 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.

> Furthermore, I think the virt_spin_lock needs to be optimized.

Why would virt_spin_lock() need to be optimized? It is the fallback
case; but it is terrible in all possible ways.

  reply	other threads:[~2025-08-14 10:42 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 [this message]
2025-08-15  2:47         ` Guo, Wangyang
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=20250814104156.GV4067720@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --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=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=tianyou.li@intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wangyang.guo@intel.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®