From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCH RFC v6 09/11] pvqspinlock, x86: Add qspinlock para-virtualization support Date: Thu, 13 Mar 2014 11:21:03 +0000 Message-ID: <5321949F.1010103__44420.4296720729$1394709778$gmane$org@citrix.com> References: <1394650498-30118-1-git-send-email-Waiman.Long@hp.com> <1394650498-30118-10-git-send-email-Waiman.Long@hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WO3hI-0006Uv-2T for xen-devel@lists.xenproject.org; Thu, 13 Mar 2014 11:21:12 +0000 In-Reply-To: <1394650498-30118-10-git-send-email-Waiman.Long@hp.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Waiman Long Cc: Jeremy Fitzhardinge , Raghavendra K T , kvm@vger.kernel.org, Peter Zijlstra , virtualization@lists.linux-foundation.org, Andi Kleen , "H. Peter Anvin" , Michel Lespinasse , Thomas Gleixner , linux-arch@vger.kernel.org, Gleb Natapov , x86@kernel.org, Ingo Molnar , xen-devel@lists.xenproject.org, "Paul E. McKenney" , Arnd Bergmann , Scott J Norton , Rusty Russell , Steven Rostedt , Chris Wright , Oleg Nesterov , Alok Kataria , Aswin Chandramouleeswaran , Chegu Vinod , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 12/03/14 18:54, Waiman Long wrote: > This patch adds para-virtualization support to the queue spinlock in > the same way as was done in the PV ticket lock code. In essence, the > lock waiters will spin for a specified number of times (QSPIN_THRESHOLD > = 2^14) and then halted itself. The queue head waiter will spins > 2*QSPIN_THRESHOLD times before halting itself. When it has spinned > QSPIN_THRESHOLD times, the queue head will assume that the lock > holder may be scheduled out and attempt to kick the lock holder CPU > if it has the CPU number on hand. I don't really understand the reasoning for kicking the lock holder. It will either be: running, runnable, or halted because it's in a slow path wait for another lock. In any of these states I do not see how a kick is useful. > Enabling the PV code does have a performance impact on spinlock > acquisitions and releases. The following table shows the execution > time (in ms) of a spinlock micro-benchmark that does lock/unlock > operations 5M times for each task versus the number of contending > tasks on a Westmere-EX system. > > # of Ticket lock Queue lock > tasks PV off/PV on/%Change PV off/PV on/%Change > ------ -------------------- --------------------- > 1 135/ 179/+33% 137/ 169/+23% > 2 1045/ 1103/ +6% 1120/ 1536/+37% > 3 1827/ 2683/+47% 2313/ 2425/ +5% > 4 2689/ 4191/+56% 2914/ 3128/ +7% > 5 3736/ 5830/+56% 3715/ 3762/ +1% > 6 4942/ 7609/+54% 4504/ 4558/ +2% > 7 6304/ 9570/+52% 5292/ 5351/ +1% > 8 7736/11323/+46% 6037/ 6097/ +1% Do you have measurements from tests when VCPUs are overcommitted? > +#ifdef CONFIG_PARAVIRT_SPINLOCKS > +/** > + * queue_spin_unlock_slowpath - kick up the CPU of the queue head > + * @lock : Pointer to queue spinlock structure > + * > + * The lock is released after finding the queue head to avoid racing > + * condition between the queue head and the lock holder. > + */ > +void queue_spin_unlock_slowpath(struct qspinlock *lock) > +{ > + struct qnode *node, *prev; > + u32 qcode = (u32)queue_get_qcode(lock); > + > + /* > + * Get the queue tail node > + */ > + node = xlate_qcode(qcode); > + > + /* > + * Locate the queue head node by following the prev pointer from > + * tail to head. > + * It is assumed that the PV guests won't have that many CPUs so > + * that it won't take a long time to follow the pointers. This isn't a valid assumption, but this isn't that different from the search done in the ticket slow unlock path so I guess it's ok. David