Received: by 10.213.65.68 with SMTP id h4csp2171432imn; Thu, 5 Apr 2018 10:08:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx49XrvVeN0WpC93Ngx5x7peiTF0XutDigGHt/Wh4sotON4HNPFD5/GggVlVq3puf2LXpzeLk X-Received: by 2002:a17:902:a60d:: with SMTP id u13-v6mr24157423plq.161.1522948139505; Thu, 05 Apr 2018 10:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522948139; cv=none; d=google.com; s=arc-20160816; b=hVut5p25KFmtq3h8O3yuVJkWzeL3xDRr7oV/p74rl19LoZBQjt3DRXxvGdi9VRbA+y euT9AAi1qqIdXg2Tk83zwIQmLfb5IzQLeHEjLsnVIili2X1zKMihP+YYnVA3UNzLN2gB ipHMr7IGoGzzsgpLa6o+K8BMwm9BW8Roqco3+ZotQv1Kmy9cyUw7lHgifHiVH1l2xBfl QSstw1tb2+fRQc0D/VQ44HREAflKZONySZHq22GJMf2GayZ/Y6P777crOnNUToDikGQf 0wM9yS99JkTY+z4HUrmWiccNadkg+4JpRExnQnNkqujZOrGJDVSxwmGApEzuoB3sTpq1 lQ8g== 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=jaEVBElUVmfjtmhj1sK/yL72cPCHbbjrLAKQE07lWeU=; b=nmNU3bRsiIuoMDoMnWJrGk8V1+DT/KLolybHCg13/dyGQWgoqHqVH2B1A/Ww2ebxDa ecDqfQ6ZJ70vXqzt3Dhv5hhDgRcXBzjqNi0ohvOPB2CHO64lvZ2acqCofNCx5O3lnDk4 qbjrXd5U7cpZ2WFJRCvv41GI5rY/uKtANKnVvWU2Hm2Yw6Qf4baOUPDeCLQePjXXDq9b lwtQI5hX5Xf+6CLN7MxyCBr0w+T5CE7ddosFoB+39BygetnueRLxn8mmLbz1ATONnen4 Im5If1jNHZmicHfxuXmYHTJEIp70/s8c1+q1FctfXPGeyHedscgcAd14KD9xXVeMiCYj qwlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=z/xiY2q+; 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 71-v6si6063887plb.511.2018.04.05.10.08.44; Thu, 05 Apr 2018 10:08:59 -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=merlin.20170209 header.b=z/xiY2q+; 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 S1751482AbeDERHR (ORCPT + 99 others); Thu, 5 Apr 2018 13:07:17 -0400 Received: from merlin.infradead.org ([205.233.59.134]:58982 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbeDERHQ (ORCPT ); Thu, 5 Apr 2018 13:07:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=jaEVBElUVmfjtmhj1sK/yL72cPCHbbjrLAKQE07lWeU=; b=z/xiY2q+2fR4g0J4v2KpZsezI Sve4qddNg8wTtGnRJxbMkJA9fiHEJNili34pLAMfJC9dB3a4/lpsBV5d3GTb6gtQKfRTU8+5WXszY kFI6Zxnqp4V2Bsh80EF+27ufO2vj4gwyPXMVMGO5LxzNmfV2o+Oy/q+TahZWnCrmKDTWbhPLVcYys aypfBO9fSuh04G21p872WeIlJAm02J6hzaO6RK+j1mDGL+lsYX0osOb3J1koRJPIc+6F0kOJDNoXp JKbfM0S12O1NDfnxNZOcxMtLf7gxGqDpnRlaqarD3ss4smtdrw7ByZPnb9JMZnMDPXFzfb4MBQAdv vgJcssR/Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f48Lr-0002EU-Iz; Thu, 05 Apr 2018 17:07:07 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 47B9320298CFA; Thu, 5 Apr 2018 19:07:06 +0200 (CEST) Date: Thu, 5 Apr 2018 19:07:06 +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: <20180405170706.GC4082@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: > The qspinlock locking slowpath utilises a "pending" bit as a simple form > of an embedded test-and-set lock that can avoid the overhead of explicit > queuing in cases where the lock is held but uncontended. This bit is > managed using a cmpxchg loop which tries to transition the uncontended > lock word from (0,0,0) -> (0,0,1) or (0,0,1) -> (0,1,1). > > Unfortunately, the cmpxchg loop is unbounded and lockers can be starved > indefinitely if the lock word is seen to oscillate between unlocked > (0,0,0) and locked (0,0,1). This could happen if concurrent lockers are > able to take the lock in the cmpxchg loop without queuing and pass it > around amongst themselves. > > This patch fixes the problem by unconditionally setting _Q_PENDING_VAL > using atomic_fetch_or, Of course, LL/SC or cmpxchg implementations of fetch_or do not in fact get anything from this ;-)