Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2210506imm; Thu, 20 Sep 2018 09:22:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbZGD/c9IZnKvGVvG6Zbg0Nb+uOS9MrZf+xUofBwLVxs5dTpRe1CeaiHsogvwq9s47o2SHs X-Received: by 2002:a62:9e07:: with SMTP id s7-v6mr3604081pfd.110.1537460570424; Thu, 20 Sep 2018 09:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537460570; cv=none; d=google.com; s=arc-20160816; b=N+pngJdVD9+Axk+wPwAI2AOohpvIh0A1Z02AD5mPto6H1b5h0EIlKmPgeAyW8/dZtA zrqwgQMkXA+FE+4V/NN8MGedpRuj2ac5Ra5vEhGr3WGq8cc5ZvNNzQz+JD4oxriqvCcw ebbHpcaxCvtA4bRYaxwDW0qPULg5YLzhe/SL/VB22cLYiTmLwW97dQBzhHkFMgasOy1E 4H9pArvluMMBdXYFcoQqNfF+HOnZ66N27CuyIyS481sj8sKxXihHDx8jnlyf0qJzyfvt 1yJGmDFNeC2s1EO6XMG78C++WXHfuDkqI3eSCbA9Gi5gNykR6eZaTvUc39AVuYJDJEBh Ah9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xJ3yBp77MqWtiwJKjICMtjEDV065Wj+aVcTDyX7S1Jw=; b=dRrGFn+Yduh/ZZ857jbsDM44dqPHtDcjj3IJZd0ZDYKCP20vhFh8rHEvflsoRSe/Di yGnp2JybnNZ1id0s4jHC93OtmAI45ML0tNnGz7UT7QyY5sKPIyZbfPf5TtN790K1DZnh zWf5oHdym3ZVN2V/sFBb9SRLJawNTX5mqH7SO/Z0ZLzIF6sqa8sKzEbHOb2M6tK/bhz2 NRV0AMLj6oZSBp6i7CXwZAYzx4T4SHGykk830IkEI0girRtReRJoBpogFkzRsb4w7dD5 MdZgXYoMoZO7QJ8rv0Jv/FyDtYnBwY5Jr9LjRQ/QRhcTDhwHfxlmXFv6C47Czg1vJs/M Uxyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oVISmaLe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5-v6si22051544pgc.607.2018.09.20.09.22.34; Thu, 20 Sep 2018 09:22:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oVISmaLe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727948AbeITWGj (ORCPT + 99 others); Thu, 20 Sep 2018 18:06:39 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49926 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbeITWGi (ORCPT ); Thu, 20 Sep 2018 18:06:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xJ3yBp77MqWtiwJKjICMtjEDV065Wj+aVcTDyX7S1Jw=; b=oVISmaLe+PC7Tx6igS7AEJIpQ EPZv249C2/S9XO2QI73yhkjLdzPylL6AfU/SaXTCm9+HtZSqQ9KZLNCj7VqmO726Mci3iFHi6hSxE L81aKJw/2vI9L0YrWo/WZL2TIsdeh53JIDhlWzs7zloJPl32iti/2Q2uJ9vGDAY9/L9hZaQrvSDXX GmNqMSlg9WoxU7SJ3ePZtej1oS1PRd23azyl6Fm6ADL4Bq+wI2xfwzGHY9lOLDsmDemP97kJv4Pny wxxnlDXdJVzedWcWIUiZbBsvmYmlN/3NAP2dHvNrDrQG9Ei/NamM9koO2rfhSluo1St+0ZoRT5JO4 KSS4TtdTA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g31ie-0008HS-Kz; Thu, 20 Sep 2018 16:22:20 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0D0902024E44B; Thu, 20 Sep 2018 18:22:17 +0200 (CEST) Date: Thu, 20 Sep 2018 18:22:16 +0200 From: Peter Zijlstra To: Will Deacon Cc: Waiman Long , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mingo@kernel.org, boqun.feng@gmail.com, paulmck@linux.vnet.ibm.com, catalin.marinas@arm.com Subject: Re: [PATCH 02/10] locking/qspinlock: Remove unbounded cmpxchg loop from locking slowpath Message-ID: <20180920162216.GR24142@hirez.programming.kicks-ass.net> References: <1522947547-24081-1-git-send-email-will.deacon@arm.com> <1522947547-24081-3-git-send-email-will.deacon@arm.com> <20180409105835.GC23134@arm.com> <20180409145409.GA9661@arm.com> <20180409155420.GB4082@hirez.programming.kicks-ass.net> <20180409171959.GB9661@arm.com> <20180920160832.GZ24124@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180920160832.GZ24124@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 20, 2018 at 06:08:32PM +0200, Peter Zijlstra wrote: > Another approach might be to use something like: > > val = xchg_relaxed(&lock->locked_pending, _Q_PENDING_VAL | _Q_LOCKED_VAL); > val |= atomic_read_acquire(&lock->val) & _Q_TAIL_MASK; > > combined with something like: > > /* 0,0,0 -> 0,1,1 - we won trylock */ > if (!(val & _Q_LOCKED_MASK)) { That one doesn't actually work... let me think about this more. > clear_pending(lock); > return; > } > > /* 0,0,1 -> 0,1,1 - we won pending */ > if (!(val & ~_Q_LOCKED_MASK)) { > ... > } > > /* *,0,1 -> *,1,1 - we won pending, but there's queueing */ > if (!(val & _Q_PENDING_VAL)) > clear_pending(lock); > > ... > > > Hmmm?