From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752452AbbJMT4f (ORCPT ); Tue, 13 Oct 2015 15:56:35 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:42590 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156AbbJMT4e (ORCPT ); Tue, 13 Oct 2015 15:56:34 -0400 Date: Tue, 13 Oct 2015 21:56:27 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Scott J Norton , Douglas Hatch , Davidlohr Bueso Subject: Re: [PATCH v7 4/5] locking/pvqspinlock: Allow 1 lock stealing attempt Message-ID: <20151013195627.GY3816@twins.programming.kicks-ass.net> References: <1442955044-43895-1-git-send-email-Waiman.Long@hpe.com> <1442955044-43895-5-git-send-email-Waiman.Long@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442955044-43895-5-git-send-email-Waiman.Long@hpe.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 22, 2015 at 04:50:43PM -0400, Waiman Long wrote: > +gotlock: > /* > + * We now have the lock. We need to either clear the tail code or > + * notify the next one in queue as the new queue head. > */ > + old = atomic_read(&lock->val); > + while ((old & _Q_TAIL_MASK) == tail) { > + int val; > + int new = old & ~_Q_TAIL_MASK; > + > + /* > + * We are the only one in the queue, so clear the tail code > + * and return. > + */ > + val = atomic_cmpxchg(&lock->val, old, new); > + if (old == val) > + goto done; > + old = val; > + } > + This i need to think about a wee bit; its almost the same... So the below is exactly duplicated from the normal slowpath, so why don't you keep that there? It would get you something like: if (pv_wait_head_or_steal(..)) goto stolen; stolen: > + /* > + * contended path; wait for next, release. > + */ > + while (!(next = READ_ONCE(node->next))) > + cpu_relax(); > + > + arch_mcs_spin_unlock_contended(&next->locked); > + pv_kick_node(lock, next); release: ...