From: Waiman Long <waiman.long@hp.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arch@vger.kernel.org, Rik van Riel <riel@redhat.com>,
Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
Oleg Nesterov <oleg@redhat.com>,
kvm@vger.kernel.org,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Scott J Norton <scott.norton@hp.com>,
x86@kernel.org, Paolo Bonzini <paolo.bonzini@gmail.com>,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Ingo Molnar <mingo@redhat.com>,
David Vrabel <david.vrabel@citrix.com>,
"H. Peter Anvin" <hpa@zytor.com>,
xen-devel@lists.xenproject.org,
Thomas Gleixner <tglx@linutronix.de>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Douglas Hatch <doug.hatch@hp.com>
Subject: Re: [PATCH v12 09/11] pvqspinlock, x86: Add para-virtualization support
Date: Wed, 29 Oct 2014 15:05:52 -0400 [thread overview]
Message-ID: <54513A90.3080108@hp.com> (raw)
In-Reply-To: <544EB79E.6020200@hp.com>
On 10/27/2014 05:22 PM, Waiman Long wrote:
> On 10/27/2014 02:04 PM, Peter Zijlstra wrote:
>> On Mon, Oct 27, 2014 at 01:38:20PM -0400, Waiman Long wrote:
>>> On 10/24/2014 04:54 AM, Peter Zijlstra wrote:
>>>> On Thu, Oct 16, 2014 at 02:10:38PM -0400, Waiman Long wrote:
>>>>
>>>>> Since enabling paravirt spinlock will disable unlock function
>>>>> inlining,
>>>>> a jump label can be added to the unlock function without adding patch
>>>>> sites all over the kernel.
>>>> But you don't have to. My patches allowed for the inline to remain,
>>>> again reducing the overhead of enabling PV spinlocks while running
>>>> on a
>>>> real machine.
>>>>
>>>> Look at:
>>>>
>>>> http://lkml.kernel.org/r/20140615130154.213923590@chello.nl
>>>>
>>>> In particular this hunk:
>>>>
>>>> Index: linux-2.6/arch/x86/kernel/paravirt_patch_64.c
>>>> ===================================================================
>>>> --- linux-2.6.orig/arch/x86/kernel/paravirt_patch_64.c
>>>> +++ linux-2.6/arch/x86/kernel/paravirt_patch_64.c
>>>> @@ -22,6 +22,10 @@ DEF_NATIVE(pv_cpu_ops, swapgs, "swapgs")
>>>> DEF_NATIVE(, mov32, "mov %edi, %eax");
>>>> DEF_NATIVE(, mov64, "mov %rdi, %rax");
>>>>
>>>> +#if defined(CONFIG_PARAVIRT_SPINLOCKS)&&
>>>> defined(CONFIG_QUEUE_SPINLOCK)
>>>> +DEF_NATIVE(pv_lock_ops, queue_unlock, "movb $0, (%rdi)");
>>>> +#endif
>>>> +
>>>> unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len)
>>>> {
>>>> return paravirt_patch_insns(insnbuf, len,
>>>> @@ -61,6 +65,9 @@ unsigned native_patch(u8 type, u16 clobb
>>>> PATCH_SITE(pv_cpu_ops, clts);
>>>> PATCH_SITE(pv_mmu_ops, flush_tlb_single);
>>>> PATCH_SITE(pv_cpu_ops, wbinvd);
>>>> +#if defined(CONFIG_PARAVIRT_SPINLOCKS)&&
>>>> defined(CONFIG_QUEUE_SPINLOCK)
>>>> + PATCH_SITE(pv_lock_ops, queue_unlock);
>>>> +#endif
>>>>
>>>> patch_site:
>>>> ret = paravirt_patch_insns(ibuf, len, start, end);
>>>>
>>>>
>>>> That makes sure to overwrite the callee-saved call to the
>>>> pv_lock_ops::queue_unlock with the immediate asm "movb $0, (%rdi)".
>>>>
>>>>
>>>> Therefore you can retain the inlined unlock with hardly (there
>>>> might be
>>>> some NOP padding) any overhead at all. On PV it reverts to a callee
>>>> saved function call.
>>> My concern is that spin_unlock() can be called in many places,
>>> including
>>> loadable kernel modules. Can the paravirt_patch_ident_32() function
>>> able to
>>> patch all of them in reasonable time? How about a kernel module
>>> loaded later
>>> at run time?
>> modules should be fine, see arch/x86/kernel/module.c:module_finalize()
>> -> apply_paravirt().
>>
>> Also note that the 'default' text is an indirect call into the paravirt
>> ops table which routes to the 'right' function, so even if the text
>> patching would be 'late' calls would 'work' as expected, just slower.
>
> Thanks for letting me know about that. I have this concern because
> your patch didn't change the current configuration of disabling unlock
> inlining when paravirt_spinlock is enabled. With that, I think it is
> worthwhile to reduce the performance delta between the PV and non-PV
> kernel on bare metal.
I am sorry that the unlock call sites patching code doesn't work in a
virtual guest. Your pvqspinlock patch did an unconditional patching even
in a virtual guest. I added check for the paravirt_spinlocks_enabled,
but it turned out that some spin_unlock() seemed to be called before
paravirt_spinlocks_enabled is set. As a result, some call sites were
still patched resulting in missed wake up's and system hang.
At this point, I am going to leave out that change from my patch set
until we can figure out a better way of doing that.
-Longman
next prev parent reply other threads:[~2014-10-29 19:05 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 18:10 [PATCH v12 00/11] qspinlock: a 4-byte queue spinlock with PV support Waiman Long
2014-10-16 18:10 ` [PATCH v12 01/11] qspinlock: A simple generic 4-byte queue spinlock Waiman Long
2014-10-16 18:10 ` [PATCH v12 02/11] qspinlock, x86: Enable x86-64 to use " Waiman Long
2014-10-16 18:10 ` [PATCH v12 03/11] qspinlock: Add pending bit Waiman Long
2014-10-16 18:10 ` [PATCH v12 04/11] qspinlock: Extract out code snippets for the next patch Waiman Long
2014-10-16 18:10 ` [PATCH v12 05/11] qspinlock: Optimize for smaller NR_CPUS Waiman Long
2014-10-16 18:10 ` [PATCH v12 06/11] qspinlock: Use a simple write to grab the lock Waiman Long
2014-10-16 18:10 ` [PATCH v12 07/11] qspinlock: Revert to test-and-set on hypervisors Waiman Long
2014-10-16 18:10 ` [PATCH v12 08/11] qspinlock, x86: Rename paravirt_ticketlocks_enabled Waiman Long
2014-10-16 18:10 ` [PATCH v12 09/11] pvqspinlock, x86: Add para-virtualization support Waiman Long
2014-10-16 18:10 ` [PATCH v12 10/11] pvqspinlock, x86: Enable PV qspinlock for KVM Waiman Long
2014-10-16 18:10 ` [PATCH v12 11/11] pvqspinlock, x86: Enable PV qspinlock for XEN Waiman Long
[not found] ` <1413483040-58399-10-git-send-email-Waiman.Long@hp.com>
2014-10-24 8:47 ` [PATCH v12 09/11] pvqspinlock, x86: Add para-virtualization support Peter Zijlstra
2014-10-24 8:54 ` Peter Zijlstra
2014-10-27 17:38 ` Waiman Long
2014-10-27 18:02 ` Konrad Rzeszutek Wilk
2014-10-27 20:55 ` Waiman Long
2014-11-26 0:33 ` Waiman Long
[not found] ` <54751FF6.5050808@hp.com>
2014-12-01 16:51 ` Konrad Rzeszutek Wilk
2014-10-27 18:04 ` Peter Zijlstra
[not found] ` <20141027180439.GL3337@twins.programming.kicks-ass.net>
2014-10-27 21:22 ` Waiman Long
[not found] ` <544EB79E.6020200@hp.com>
2014-10-29 19:05 ` Waiman Long [this message]
2014-10-29 20:25 ` Waiman Long
[not found] ` <20141024084738.GU21513@worktop.programming.kicks-ass.net>
2014-10-24 20:53 ` Waiman Long
2014-10-24 22:04 ` Peter Zijlstra
2014-10-25 4:30 ` Mike Galbraith
2014-10-27 17:15 ` Waiman Long
2014-10-27 17:27 ` Peter Zijlstra
[not found] ` <20141027172719.GK3337@twins.programming.kicks-ass.net>
2014-10-27 20:50 ` Waiman Long
2014-10-24 8:57 ` [PATCH v12 00/11] qspinlock: a 4-byte queue spinlock with PV support Peter Zijlstra
2014-10-27 18:00 ` Waiman Long
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=54513A90.3080108@hp.com \
--to=waiman.long@hp.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=doug.hatch@hp.com \
--cc=hpa@zytor.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=paolo.bonzini@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=raghavendra.kt@linux.vnet.ibm.com \
--cc=riel@redhat.com \
--cc=scott.norton@hp.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).