From patchwork Wed Apr 11 18:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 133157 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp895326ljb; Wed, 11 Apr 2018 11:01:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/6BovW9c9pOrWaMnMpg6tJbY+8m/+ITbbb9X0/Y3aVie/KKsEjfj4LrXKmToBln0zHzsPr X-Received: by 10.99.138.202 with SMTP id y193mr4171831pgd.224.1523469694052; Wed, 11 Apr 2018 11:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523469694; cv=none; d=google.com; s=arc-20160816; b=g6DmXDST+j3gosVErpgqmLWfsemlTndZ0sY4OpB5edPGO+qZKSS1xvRxnl7yJ2Gij6 Io9/uLU9iqhJyfzRvXs1wCUjvM4qSIcqhw+wOZo3XLTrUSld3IHkmoVkG17qQQtaWbAN x5fkjXW4bZJ9bBnpeMeLF1S14j9hz0bSbQvAZFyAUJz5EHaFhK5D9jMJSty/37tYjBbN ASi4r/UCj4NHsmv7gTptc2ycaWRKjIafctUzZzduuwQw/e3wtvFf6tYPLtXAgEu9KOVZ J3XYjVHcYEC3s4UMxWfSc99KFVRznRjCfOMpYUTi6EDmMDoQIFGbRZ4HT+62vnKlCRY3 avMw== 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=cDKKlZei8NAUemnDDyM83M5fTxXVCZkFOWVvrfMVSzY=; b=rVttk4mdUKJasq8r9nJwKlO/lfCzbb4GgOQlydTB02oCV9/RDF+OrUxYYXV23mxTda BMer0tYk9uECyTffnfQ3JZ5Ea882StBO10oVzQFmXh8qQHmjyNhRyfQopoRLQZ5IxHph oy+WLW3bCxqP5SSNj4L9gVM49sUhJbHtTsivUdkF4XANBHD4ooneSrnshch9KmKyU8Yb HFirBdyhmjL5T+aDEsmXMOK3V+EVzwNPciUprxJkEiR0hvr4fCsYXIb3t17wDcvHZYnU cnBZb7CddldJOz+UNDloBGcPVJzvIm5VmsSfzOWBdmSf633iheTIA/EpmmUvVHfNFTYT ffZw== 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 p20si1258214pfi.345.2018.04.11.11.01.33; Wed, 11 Apr 2018 11:01:34 -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 S1753697AbeDKSBR (ORCPT + 29 others); Wed, 11 Apr 2018 14:01:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52134 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752638AbeDKSBH (ORCPT ); Wed, 11 Apr 2018 14:01:07 -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 210541684; Wed, 11 Apr 2018 11:01:07 -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 E69BB3F77D; Wed, 11 Apr 2018 11:01:06 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id C5E191AE55C6; Wed, 11 Apr 2018 19:01:21 +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, longman@redhat.com, Will Deacon Subject: [PATCH v2 08/13] locking/qspinlock: Use smp_cond_load_relaxed to wait for next node Date: Wed, 11 Apr 2018 19:01:15 +0100 Message-Id: <1523469680-17699-9-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1523469680-17699-1-git-send-email-will.deacon@arm.com> References: <1523469680-17699-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(-) -- 2.1.4 diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 648a16a2cd23..c781ddbe59a6 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c @@ -523,10 +523,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);