All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: maobibo <maobibo@loongson.cn>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>, Arnd Bergmann <arnd@arndb.de>,
	<virtualization@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	Juergen Gross <jgross@suse.com>,
	"Nikolay Borisov" <nik.borisov@suse.com>,
	Qiuxu Zhuo <qiuxu.zhuo@intel.com>,
	"Prem Nath Dey" <prem.nath.dey@intel.com>,
	Xiaoping Zhou <xiaoping.zhou@intel.com>,
	"Peter Zijlstra" <peterz@infradead.org>
Subject: Re: [PATCH v4] x86/paravirt: Disable virt spinlock on bare metal
Date: Tue, 30 Jul 2024 16:46:53 +0800	[thread overview]
Message-ID: <ZqiofczTqmn4bvhy@chenyu5-mobl2> (raw)
In-Reply-To: <08d75c12-215e-3781-ed89-b1ed5c1e39c8@loongson.cn>

Hi Bibo,

On 2024-07-30 at 09:21:45 +0800, maobibo wrote:
> Chenyu,
> 
> Sorry to bother you, I am porting pv spinlock to LoongArch platform, I do
> not know the history about function virt_spin_lock().
> 
> When CONFIG_PARAVIRT_SPINLOCKS is enabled, there is pv_enabled() before
> virt_spin_lock(), it seems that virt_spin_lock is never called in this
> condition.

Right, if CONFIG_PARAVIRT_SPINLOCKS is enabled, virt_spin_lock() will not be
checked at all and go directly to pv_queue lock section.

>         if (pv_enabled())
>                 goto pv_queue;
> 
>         if (virt_spin_lock(lock))
>                 return;
> 
> When CONFIG_PARAVIRT_SPINLOCKS is disabled, there is no pv qspinlock
> compiled, so what is the usage about function virt_spin_lock()? 
> Is it to switch spinlock method from test-set spinlock to qspinlock? 
> why is there such requirement for spinlock switching method?

Firstly, according to the commit 2aa79af64263 ("locking/qspinlock: Revert
to test-and-set on hypervisors"), virt_spin_lock() was originally introduced
to avoid the over-preemption of native qspinlock(when paravirt-spinlock is
disabled).

Secondly, there is user requirement to use native qspinlock over test-set lock
in the VM. For example, nopvspin parameter is parsed in xen_init_spinlocks().
commit 9043442b43b1 ("locking/paravirt: Use new static key for controlling call
of virt_spin_lock()") was introduced to adjust the key from user boot up commandline.
so the key switches between test-set and the native qspinlock. I've Cced
Juergen and Peter in case I misunderstood. 

thanks,
Chenyu

  reply	other threads:[~2024-07-30  8:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29  6:52 [PATCH v4] x86/paravirt: Disable virt spinlock on bare metal Chen Yu
2024-07-29 12:43 ` Thomas Gleixner
2024-07-29 18:47   ` Chen Yu
2024-07-30  1:21 ` maobibo
2024-07-30  8:46   ` Chen Yu [this message]
2024-07-30  9:39     ` maobibo
2024-08-01  8:00 ` maobibo
2024-08-01 14:40   ` Chen Yu
2024-08-02  1:27     ` maobibo
2024-08-02  7:56       ` Chen Yu
2024-08-02  8:13         ` maobibo
2024-08-02 13:52           ` Chen Yu

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=ZqiofczTqmn4bvhy@chenyu5-mobl2 \
    --to=yu.c.chen@intel.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maobibo@loongson.cn \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=prem.nath.dey@intel.com \
    --cc=qiuxu.zhuo@intel.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux.dev \
    --cc=xiaoping.zhou@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.