From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754959AbcDTOiH (ORCPT ); Wed, 20 Apr 2016 10:38:07 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:33257 "EHLO e23smtp05.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752468AbcDTOiF (ORCPT ); Wed, 20 Apr 2016 10:38:05 -0400 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: xinhui@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Message-ID: <57179409.2010107@linux.vnet.ibm.com> Date: Wed, 20 Apr 2016 22:36:57 +0800 From: Pan Xinhui User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Peter Zijlstra 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() References: <1460659318-53312-1-git-send-email-Waiman.Long@hpe.com> <20160420120805.GB3408@twins.programming.kicks-ass.net> <57178EED.1060207@linux.vnet.ibm.com> <20160420141949.GE3430@twins.programming.kicks-ass.net> In-Reply-To: <20160420141949.GE3430@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16042014-0017-0000-0000-0000044644B3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016年04月20日 22:19, Peter Zijlstra wrote: > 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. > Okay, I will try to add the holder lookup code in arch/... But I just come up with one idea, in __pv_queued_spin_unlock_slowpath() we will kick the node->cpu, who will become the holder soon. I think we can somehow record the node->cpu and use it in pv_wait_node :) thanks xinhui