Received: by 10.213.65.68 with SMTP id h4csp2177132imn; Thu, 5 Apr 2018 10:14:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx49KfEIr6NXmz71C8KvOajXIDMfO575lbQI2tut33CxuT0I6UqVQfyjKODwK2R1/jDP3Y71t X-Received: by 2002:a17:902:96a:: with SMTP id 97-v6mr14527922plm.266.1522948480661; Thu, 05 Apr 2018 10:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522948480; cv=none; d=google.com; s=arc-20160816; b=NV2nKH3i9vre/JmMOy8Sh51H53d3dYQX1qA3twmNlQhJI/MbSLBA4fGJt7XP2aSZ4e X7XBLeAXWcf7uHyn3hs718QNhAPdDzxdVj+tkrgkGOruXJhz7I64PGtTIj3XcMmN3SoG DVTlin2Oo5hYnIQ8AStcZO1Mxi8bO97Ic/4Pt8F+TGItzg7z3Ne4w3dHcEseuG8fzIIt 5Tb38bbj7MzRqt2JE/Xb0KE79veDIKsno/JhtcJLNyxmGpL8NL+LgxD3TeKPov/gqPXt ZL2sgSeaCKbIsSFqGAEg3lMrJsEEy6+nlhYfOf91qe+07tj+zm753h4IVYsZHgRuX7qP qotw== 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:arc-authentication-results; bh=quyzQmNDARETMvoZlYGo4DkZBO4/O2QdGWV5ru6Cp0U=; b=UNUxu5IS6Ia8ch6hBYyrkIT5Vn6D3OCajNL2R5ZCzdHNtTSF/6tO1zCIPrdjZ1boLN 5rfBrDCv32q/N2WrJQmDKn/XatrIOkpNMsP/04BOyXOFwZnkni+2FARezvSquFZlTEUC XTYWdW640Gk3WjyZF94EqM9PdD0RA7GdPWsHkpBSNL3YzxxJYoo+NuOYwKARKSxpxXXA 00kLQzpYfHOF+Wlpo46nkmg4qHVMbZI70CCSw8vOvldk1jmrWK/3cK9oLIGLYXirCBCV vH5RJ+ixp8bPX9oVNrztnDkcWwdyqCQQIpd2+wfFjwHTf6/mzpScV4o59NKRLEQoRO8v uVcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gKmYali3; 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 r4si5707038pgs.685.2018.04.05.10.14.25; Thu, 05 Apr 2018 10:14:40 -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=gKmYali3; 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 S1751417AbeDERNP (ORCPT + 99 others); Thu, 5 Apr 2018 13:13:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48996 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbeDERNO (ORCPT ); Thu, 5 Apr 2018 13:13:14 -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=quyzQmNDARETMvoZlYGo4DkZBO4/O2QdGWV5ru6Cp0U=; b=gKmYali3rQZIh07v1GfpSheU0 cvA5pk7FCvaKmwEQM99mn4G3ul60qczpKpvXvVNwvOWBhrug1rh2oBgwrVEhgOEEE/+v5InVi2pMB ArYpdJL4S6ajBUnYPpStC7lrNSRyEusUBm4J3UtqDUM8WsS9pKuAhZ06Z+e/azhnxPTCI+8/wqF+f Aur2NWsUxqmtd4fRzocmfAcEcauk3ix6I5aG1eJYEwyh1jsHW68dfYRforJ9ryPolMUPHWKa2AF00 sp/+/9mJoS2EwDhe1PPeLJc1OflNO6r0mA560dTIB3EBkh6rwoS5M72cWogAHY/hdINQzKxELF8/g 95siIR8OA==; 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 1f48Ri-0004fk-9H; Thu, 05 Apr 2018 17:13:10 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BFCC620298CFA; Thu, 5 Apr 2018 19:13:08 +0200 (CEST) Date: Thu, 5 Apr 2018 19:13:08 +0200 From: Peter Zijlstra To: Will Deacon Cc: 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, Waiman Long Subject: Re: [PATCH 02/10] locking/qspinlock: Remove unbounded cmpxchg loop from locking slowpath Message-ID: <20180405171308.GD4082@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522947547-24081-3-git-send-email-will.deacon@arm.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 05:58:59PM +0100, Will Deacon wrote: > @@ -306,58 +306,48 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) > return; > > /* > + * If we observe any contention; queue. > + */ > + if (val & ~_Q_LOCKED_MASK) > + goto queue; > + > + /* > * trylock || pending > * > * 0,0,0 -> 0,0,1 ; trylock > * 0,0,1 -> 0,1,1 ; pending > */ > + val = atomic_fetch_or_acquire(_Q_PENDING_VAL, &lock->val); > + if (!(val & ~_Q_LOCKED_MASK)) { > /* > + * we're pending, wait for the owner to go away. > + * > + * *,1,1 -> *,1,0 > + * > + * this wait loop must be a load-acquire such that we match the > + * store-release that clears the locked bit and create lock > + * sequentiality; this is because not all > + * clear_pending_set_locked() implementations imply full > + * barriers. > */ > + if (val & _Q_LOCKED_MASK) > + smp_cond_load_acquire(&lock->val.counter, > + !(VAL & _Q_LOCKED_MASK)); I much prefer { } for multi-line statements like this. > /* > + * take ownership and clear the pending bit. > + * > + * *,1,0 -> *,0,1 > */ > + clear_pending_set_locked(lock); > return; > + }