Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932830AbcDTOTx (ORCPT ); Wed, 20 Apr 2016 10:19:53 -0400 Received: from merlin.infradead.org ([205.233.59.134]:38106 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932107AbcDTOTw (ORCPT ); Wed, 20 Apr 2016 10:19:52 -0400 Date: Wed, 20 Apr 2016 16:19:49 +0200 From: Peter Zijlstra To: Pan Xinhui Cc: Waiman Long , Ingo Molnar , linux-kernel@vger.kernel.org, Scott J Norton , Douglas Hatch Subject: Re: [PATCH v2] locking/pvqspinlock: Add lock holder CPU argument to pv_wait() Message-ID: <20160420141949.GE3430@twins.programming.kicks-ass.net> References: <1460659318-53312-1-git-send-email-Waiman.Long@hpe.com> <20160420120805.GB3408@twins.programming.kicks-ass.net> <57178EED.1060207@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57178EED.1060207@linux.vnet.ibm.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 Content-Length: 1085 Lines: 25 On Wed, Apr 20, 2016 at 10:15:09PM +0800, Pan Xinhui wrote: > So there is such case that we search the whole hashtable and the lock is not found. :( > Waiman assume that if l = null, the lock is not stored. however the lock might be there actually. > But to avoid the worst case I just mentioned above, it can quickly finish the lookup. > >> + > >> + /* > >> + * We try to locate the queue head pv_node by looking > >> + * up the hash table. If it is not found, use the > >> + * CPU in the previous node instead. > >> + */ > >> + hn = pv_lookup_hash(lock); > >> + if (!hn) > >> + hn = pn; > > > > This is potentially expensive... it does not explain why this lookup can > > fail etc.. nor mentioned that lock stealing caveat. > > > Yes, it's expensive. Normally, PPC phyp don't always need the correct > holder. That means current vcpu can just give up its slice. There is > one lpar hvcall H_CONFER. I paste some spec below. Ok, so if we can indeed scan the _entire_ hashtable, then we really should not have that in common code. That's seriously expensive.