Received: by 10.213.65.68 with SMTP id h4csp2163701imn; Thu, 5 Apr 2018 10:02:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+zm1/c/zgM2JGLDi0hwNH/njAqUoooxzBBvjZb55s0A4EjdL4Mfjq87HZIPIdnbOjE07fi X-Received: by 10.101.102.3 with SMTP id w3mr14946034pgv.200.1522947722047; Thu, 05 Apr 2018 10:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522947721; cv=none; d=google.com; s=arc-20160816; b=seGm4gtuwbBZW4i0uHAypnQzk+DUmnhOku14MSu4jxBeSuOpfMvj9+WPR3ykRJctG5 SKjLrY301oJZ2DBRTHqFFGnZjN3XuEScTR7wbiilSBr2IzIs5ptVFcGw+JiN86Ie5Dfx ZPWnzIIEUerSvx4piCQFMzs7oiY48oRKWmRczkhaJXx6OZ8khts2iiJDPV3/538g9oZO bm9PDyLI4NK9Ve+irCbeqiDXbwoa97J6ctIrqFJwRNCiEBvbw7ySyVr8CA59/VRqdXxE HDA+kfv9l5qBgESE8M7QrQSBWqj96hPI/6Rq4NasfuZ8MdtyuMhEDJe800J2xo/5L2Rb CeVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WsiWjn4m3F5hpl1lY0xSgbFVq1KRUeIlMsuWixvPx8o=; b=ZTf0Q18K9c5BX2Ialog9YXdGpaocaTr6EqydRMFI9BohXJX1/PNh61X8gW3LGHyS+L ozjRZF+94j+iC7VLBFG0m4Cyn6T6Ojrn/RlePPwNjgwIDIZDkbMq9Y+ljQafBXCwBp21 /qKkX3SWFYZC0eS5tLeZjxTpLMY9xC5HlhY3HPnahfTmUNTDCNKLsxtyIBXo2eNLlRrV 1zZqT5hbHAjEYAyfrgHmkW4Se18eNizeQwGoXAjxHAj9U+f73sUjUhOrQ1QYZO0DVarr 74VBgrEUH60Wk1Fe4xeexLQGFDEHjcguvwgpGYOicnarO+iiLwleipOnLcaC+6sBCyap cNZQ== ARC-Authentication-Results: i=1; mx.google.com; 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 x12-v6si6201402plw.169.2018.04.05.10.01.47; Thu, 05 Apr 2018 10:02:01 -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; 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 S1751968AbeDERAE (ORCPT + 99 others); Thu, 5 Apr 2018 13:00:04 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57378 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751401AbeDEQ64 (ORCPT ); Thu, 5 Apr 2018 12:58:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14F2E1688; Thu, 5 Apr 2018 09:58:56 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DAB163F5C1; Thu, 5 Apr 2018 09:58:55 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 02CD81AE55A8; Thu, 5 Apr 2018 17:59:08 +0100 (BST) From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, peterz@infradead.org, mingo@kernel.org, boqun.feng@gmail.com, paulmck@linux.vnet.ibm.com, catalin.marinas@arm.com, Will Deacon Subject: [PATCH 07/10] locking/qspinlock: Use smp_cond_load_relaxed to wait for next node Date: Thu, 5 Apr 2018 17:59:04 +0100 Message-Id: <1522947547-24081-8-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1522947547-24081-1-git-send-email-will.deacon@arm.com> References: <1522947547-24081-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a locker reaches the head of the queue and takes the lock, a concurrent locker may enqueue and force the lock holder to spin whilst its node->next field is initialised. Rather than open-code a READ_ONCE/cpu_relax() loop, this can be implemented using smp_cond_load_relaxed instead. Cc: Peter Zijlstra Cc: Ingo Molnar Signed-off-by: Will Deacon --- kernel/locking/qspinlock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 291e1526d27b..c8b57d375b49 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c @@ -475,10 +475,8 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) /* * contended path; wait for next if not observed yet, release. */ - if (!next) { - while (!(next = READ_ONCE(node->next))) - cpu_relax(); - } + if (!next) + next = smp_cond_load_relaxed(&node->next, (VAL)); arch_mcs_spin_unlock_contended(&next->locked); pv_kick_node(lock, next); -- 2.1.4