Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753813AbbG2UuY (ORCPT ); Wed, 29 Jul 2015 16:50:24 -0400 Received: from g2t2354.austin.hp.com ([15.217.128.53]:33435 "EHLO g2t2354.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752897AbbG2UuF (ORCPT ); Wed, 29 Jul 2015 16:50:05 -0400 Message-ID: <55B93C76.6030502@hp.com> Date: Wed, 29 Jul 2015 16:49:58 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: Davidlohr Bueso CC: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Scott J Norton , Douglas Hatch Subject: Re: [PATCH v3 2/7] locking/pvqspinlock: Add pending bit support References: <1437595962-21472-1-git-send-email-Waiman.Long@hp.com> <1437595962-21472-3-git-send-email-Waiman.Long@hp.com> <1437958584.25997.27.camel@stgolabs.net> <55B66ACB.6010702@hp.com> <1438025945.25997.46.camel@stgolabs.net> In-Reply-To: <1438025945.25997.46.camel@stgolabs.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1235 Lines: 42 On 07/27/2015 03:39 PM, Davidlohr Bueso wrote: > On Mon, 2015-07-27 at 13:30 -0400, Waiman Long wrote: >> The pending bit acts as a 1-slot waiting queue. So if the vCPU needs to >> fall back to regular queuing, it needs to clear the bit. > Right, that's what I thought. So you would also need to call > clear_pending() as soon as the trylock/pending loop hits zero. Or am I > missing something? > > /* > * trylock || pending > */ > for (;;) { > ... > if (loop--<= 0) { > clear_pending(lock); > goto queue; > } > } > > Also, no need to check for negative loop, zero should be enough to > breakout. The while loop below can potentially make the loop variable become negative: /* * wait for in-progress pending->locked hand-overs */ if (val == _Q_PENDING_VAL) { while (((val = atomic_read(&lock->val)) == _Q_PENDING_VAL) && loop--) cpu_relax(); } Cheers, Longman -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/