All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hp.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	linux-arch@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	xen-devel@lists.xenproject.org, kvm@vger.kernel.org,
	Paolo Bonzini <paolo.bonzini@gmail.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Rik van Riel <riel@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
	David Vrabel <david.vrabel@citrix.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Scott J Norton <scott.norton@hp.com>,
	Douglas Hatch <doug.hatch@hp.com>
Subject: Re: [PATCH v12 09/11] pvqspinlock, x86: Add para-virtualization support
Date: Mon, 27 Oct 2014 16:50:42 -0400	[thread overview]
Message-ID: <544EB022.4070801@hp.com> (raw)
In-Reply-To: <20141027172719.GK3337@twins.programming.kicks-ass.net>

On 10/27/2014 01:27 PM, Peter Zijlstra wrote:
> On Mon, Oct 27, 2014 at 01:15:53PM -0400, Waiman Long wrote:
>> On 10/24/2014 06:04 PM, Peter Zijlstra wrote:
>>> On Fri, Oct 24, 2014 at 04:53:27PM -0400, Waiman Long wrote:
>>>> The additional register pressure may just cause a few more register moves
>>>> which should be negligible in the overall performance . The additional
>>>> icache pressure, however, may have some impact on performance. I was trying
>>>> to balance the performance of the pv and non-pv versions so that we won't
>>>> penalize the pv code too much for a bit more performance in the non-pv code.
>>>> Doing it your way will add a lot of function call and register
>>>> saving/restoring to the pv code.
>>> If people care about performance they should not be using virt crap :-)
>>>
>>> I only really care about bare metal.
>> Yes, I am aware of that. However, the whole point of doing PV spinlock is to
>> improve performance in a virtual guest.
> Anything that avoids the lock holder preemption nonsense is a _massive_
> win for them, a few function calls should not even register on that
> scale.

I would say all the PV stuffs are mostly useful for a over-committed 
guest where a single CPU is shared in more than one guest. When the 
guests are not overcommitted, the PV code seldom get triggered. In those 
cases, the overhead of the extra function call and register 
saving/restoring will show up.

>> +#ifdef _GEN_PV_LOCK_SLOWPATH
>> +static void pv_queue_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>> +#else
>>   void queue_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>> +#endif
> If you have two functions you might as well use the PV stuff to patch in
> the right function call at the usage sites and avoid:
>
>> +       if (pv_enabled()) {
>> +               pv_queue_spin_lock_slowpath(lock, val);
>> +               return;
>> +       }
> this alltogether.

Good point! I will do some investigation on how to do this kind of 
function address patching and eliminate the extra function call overhead.

>>          this_cpu_dec(mcs_nodes[0].count);
>>   }
>>   EXPORT_SYMBOL(queue_spin_lock_slowpath);
>> +
>> +#if !defined(_GEN_PV_LOCK_SLOWPATH)&&  defined(CONFIG_PARAVIRT_SPINLOCKS)
>> +/*
>> + * Generate the PV version of the queue_spin_lock_slowpath function
>> + */
>> +#undef pv_init_node
>> +#undef pv_wait_check
>> +#undef pv_link_and_wait_node
>> +#undef pv_wait_head
>> +#undef EXPORT_SYMBOL
>> +#undef in_pv_code
>> +
>> +#define _GEN_PV_LOCK_SLOWPATH
>> +#define EXPORT_SYMBOL(x)
>> +#define in_pv_code     return_true
>> +#define pv_enabled     return_false
>> +
>> +#include "qspinlock.c"
>> +
>> +#endif
> That's properly disgusting :-) But a lot better than actually
> duplicating everything I suppose.

I know you don't like this kind of preprocessor trick, but this is the 
easiest way that I can think of to generate two separate functions from 
the same source code.

-Longman

WARNING: multiple messages have this Message-ID (diff)
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: Mon, 27 Oct 2014 16:50:42 -0400	[thread overview]
Message-ID: <544EB022.4070801@hp.com> (raw)
In-Reply-To: <20141027172719.GK3337@twins.programming.kicks-ass.net>

On 10/27/2014 01:27 PM, Peter Zijlstra wrote:
> On Mon, Oct 27, 2014 at 01:15:53PM -0400, Waiman Long wrote:
>> On 10/24/2014 06:04 PM, Peter Zijlstra wrote:
>>> On Fri, Oct 24, 2014 at 04:53:27PM -0400, Waiman Long wrote:
>>>> The additional register pressure may just cause a few more register moves
>>>> which should be negligible in the overall performance . The additional
>>>> icache pressure, however, may have some impact on performance. I was trying
>>>> to balance the performance of the pv and non-pv versions so that we won't
>>>> penalize the pv code too much for a bit more performance in the non-pv code.
>>>> Doing it your way will add a lot of function call and register
>>>> saving/restoring to the pv code.
>>> If people care about performance they should not be using virt crap :-)
>>>
>>> I only really care about bare metal.
>> Yes, I am aware of that. However, the whole point of doing PV spinlock is to
>> improve performance in a virtual guest.
> Anything that avoids the lock holder preemption nonsense is a _massive_
> win for them, a few function calls should not even register on that
> scale.

I would say all the PV stuffs are mostly useful for a over-committed 
guest where a single CPU is shared in more than one guest. When the 
guests are not overcommitted, the PV code seldom get triggered. In those 
cases, the overhead of the extra function call and register 
saving/restoring will show up.

>> +#ifdef _GEN_PV_LOCK_SLOWPATH
>> +static void pv_queue_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>> +#else
>>   void queue_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>> +#endif
> If you have two functions you might as well use the PV stuff to patch in
> the right function call at the usage sites and avoid:
>
>> +       if (pv_enabled()) {
>> +               pv_queue_spin_lock_slowpath(lock, val);
>> +               return;
>> +       }
> this alltogether.

Good point! I will do some investigation on how to do this kind of 
function address patching and eliminate the extra function call overhead.

>>          this_cpu_dec(mcs_nodes[0].count);
>>   }
>>   EXPORT_SYMBOL(queue_spin_lock_slowpath);
>> +
>> +#if !defined(_GEN_PV_LOCK_SLOWPATH)&&  defined(CONFIG_PARAVIRT_SPINLOCKS)
>> +/*
>> + * Generate the PV version of the queue_spin_lock_slowpath function
>> + */
>> +#undef pv_init_node
>> +#undef pv_wait_check
>> +#undef pv_link_and_wait_node
>> +#undef pv_wait_head
>> +#undef EXPORT_SYMBOL
>> +#undef in_pv_code
>> +
>> +#define _GEN_PV_LOCK_SLOWPATH
>> +#define EXPORT_SYMBOL(x)
>> +#define in_pv_code     return_true
>> +#define pv_enabled     return_false
>> +
>> +#include "qspinlock.c"
>> +
>> +#endif
> That's properly disgusting :-) But a lot better than actually
> duplicating everything I suppose.

I know you don't like this kind of preprocessor trick, but this is the 
easiest way that I can think of to generate two separate functions from 
the same source code.

-Longman

  parent reply	other threads:[~2014-10-27 20:50 UTC|newest]

Thread overview: 108+ 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 ` 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 ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` 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   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` [PATCH v12 03/11] qspinlock: Add pending bit Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10 ` 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   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` [PATCH v12 05/11] qspinlock: Optimize for smaller NR_CPUS Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10 ` 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 ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` 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 ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10 ` [PATCH v12 08/11] qspinlock, x86: Rename paravirt_ticketlocks_enabled Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10   ` Waiman Long
2014-10-16 18:10 ` [PATCH v12 09/11] pvqspinlock, x86: Add para-virtualization support Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-24  8:47   ` Peter Zijlstra
2014-10-24  8:47   ` Peter Zijlstra
2014-10-24  8:47   ` Peter Zijlstra
2014-10-24 20:53     ` Waiman Long
2014-10-24 20:53       ` Waiman Long
2014-10-24 22:04       ` Peter Zijlstra
2014-10-24 22:04         ` Peter Zijlstra
2014-10-25  4:30         ` Mike Galbraith
2014-10-25  4:30         ` Mike Galbraith
2014-10-25  4:30         ` Mike Galbraith
2014-10-27 17:15         ` Waiman Long
2014-10-27 17:15         ` Waiman Long
2014-10-27 17:15           ` Waiman Long
2014-10-27 17:27           ` Peter Zijlstra
2014-10-27 20:50             ` Waiman Long
2014-10-27 20:50             ` Waiman Long [this message]
2014-10-27 20:50               ` Waiman Long
2014-10-27 17:27           ` Peter Zijlstra
2014-10-27 17:27           ` Peter Zijlstra
2014-10-24 22:04       ` Peter Zijlstra
2014-10-24 20:53     ` Waiman Long
2014-10-24  8:54   ` Peter Zijlstra
2014-10-24  8:54     ` Peter Zijlstra
2014-10-27 17:38     ` Waiman Long
2014-10-27 17:38       ` Waiman Long
2014-10-27 18:02       ` Konrad Rzeszutek Wilk
2014-10-27 18:02         ` Konrad Rzeszutek Wilk
2014-10-27 20:55         ` Waiman Long
2014-10-27 20:55         ` Waiman Long
2014-10-27 20:55         ` Waiman Long
2014-11-26  0:33         ` Waiman Long
2014-11-26  0:33         ` Waiman Long
2014-11-26  0:33         ` Waiman Long
2014-12-01 16:51           ` Konrad Rzeszutek Wilk
2014-12-01 16:51           ` Konrad Rzeszutek Wilk
2014-12-01 16:51             ` Konrad Rzeszutek Wilk
2014-10-27 18:02       ` Konrad Rzeszutek Wilk
2014-10-27 18:04       ` Peter Zijlstra
2014-10-27 18:04       ` Peter Zijlstra
2014-10-27 18:04       ` Peter Zijlstra
2014-10-27 21:22         ` Waiman Long
2014-10-27 21:22         ` Waiman Long
2014-10-27 21:22         ` Waiman Long
2014-10-29 19:05           ` Waiman Long
2014-10-29 19:05           ` Waiman Long
2014-10-29 19:05             ` Waiman Long
2014-10-29 20:25             ` Waiman Long
2014-10-29 20:25             ` Waiman Long
2014-10-29 20:25             ` Waiman Long
2014-10-27 17:38     ` Waiman Long
2014-10-24  8:54   ` Peter Zijlstra
2014-10-16 18:10 ` [PATCH v12 10/11] pvqspinlock, x86: Enable PV qspinlock for KVM Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` [PATCH v12 11/11] pvqspinlock, x86: Enable PV qspinlock for XEN Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-16 18:10 ` Waiman Long
2014-10-24  8:57 ` [PATCH v12 00/11] qspinlock: a 4-byte queue spinlock with PV support Peter Zijlstra
2014-10-24  8:57 ` Peter Zijlstra
2014-10-24  8:57   ` Peter Zijlstra
2014-10-27 18:00   ` Waiman Long
2014-10-27 18:00   ` Waiman Long
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=544EB022.4070801@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 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.