From: Juergen Gross <jgross@suse.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Oscar Salvador <osalvador@suse.de>,
Ingo Molnar <mingo@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
"H . Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-doc@vger.kernel.org, Waiman Long <longman@redhat.com>
Subject: Re: [PATCH resend] x86,kvm: Add a kernel parameter to disable PV spinlock
Date: Tue, 5 Sep 2017 11:11:10 +0200 [thread overview]
Message-ID: <aa31b426-5716-da6f-9fc5-e321c94ae0ec@suse.com> (raw)
In-Reply-To: <20170905090306.gz52hlo7s2ybogoy@hirez.programming.kicks-ass.net>
On 05/09/17 11:03, Peter Zijlstra wrote:
> On Tue, Sep 05, 2017 at 10:52:06AM +0200, Juergen Gross wrote:
>>> Hmm, that might work. Could we somehow nop that call when
>>> !X86_FEATURE_HYPERVISOR?, that saves native from having to do the call
>>> and would be a win for everyone.
>>
>> So in fact we want a "always false" shortcut for bare metal and for any
>> virtualization environment selecting bare metal behavior.
>>
>> I'll have a try.
>
> Right, so for native I think you can do this:
>
>
> diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
> index 11aaf1eaa0e4..4e9839001291 100644
> --- a/arch/x86/kernel/paravirt_patch_64.c
> +++ b/arch/x86/kernel/paravirt_patch_64.c
> @@ -21,6 +21,7 @@ DEF_NATIVE(, mov64, "mov %rdi, %rax");
> #if defined(CONFIG_PARAVIRT_SPINLOCKS)
> DEF_NATIVE(pv_lock_ops, queued_spin_unlock, "movb $0, (%rdi)");
> DEF_NATIVE(pv_lock_ops, vcpu_is_preempted, "xor %rax, %rax");
> +DEF_NATIVE(pv_lock_ops, virt_spin_lock, "xor %rax, %rax");
> #endif
>
> unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len)
> @@ -77,6 +78,13 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
> goto patch_site;
> }
> goto patch_default;
> + case PARAVIRT_PATCH(pv_lock_ops.virt_spin_lock):
> + if (!this_cpu_has(X86_FEATURE_HYPERVISOR)) {
> + start = start_pv_lock_ops_virt_spin_lock;
> + end = end_pv_lock_ops_virt_spin_lock;
> + goto patch_side;
> + }
> + goto patch_default;
I'd rather add a test to paravirt_patch_default() similar to the
_paravirt_ident_* cases for catching the Xen (and possibly KVM) cases,
too.
I just need to add _paravirt_zero_[32|64] functions I can use for bare
metal and the nopvspin cases.
Juergen
prev parent reply other threads:[~2017-09-05 9:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 14:28 [PATCH resend] x86,kvm: Add a kernel parameter to disable PV spinlock Oscar Salvador
2017-09-04 14:40 ` Peter Zijlstra
2017-09-04 19:32 ` Waiman Long
2017-09-04 22:21 ` Davidlohr Bueso
2017-09-05 6:28 ` Juergen Gross
2017-09-05 6:57 ` Oscar Salvador
2017-09-05 8:07 ` Peter Zijlstra
2017-09-05 6:58 ` Peter Zijlstra
2017-09-05 7:35 ` Juergen Gross
2017-09-05 8:10 ` Peter Zijlstra
2017-09-05 8:14 ` Juergen Gross
2017-09-05 8:28 ` Peter Zijlstra
2017-09-05 8:52 ` Juergen Gross
2017-09-05 9:03 ` Peter Zijlstra
2017-09-05 9:11 ` Juergen Gross [this message]
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=aa31b426-5716-da6f-9fc5-e321c94ae0ec@suse.com \
--to=jgross@suse.com \
--cc=dave@stgolabs.net \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@kernel.org \
--cc=osalvador@suse.de \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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