From patchwork Sun Jun 1 11:30:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 31241 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 589EE20AE6 for ; Sun, 1 Jun 2014 11:32:31 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id uy17sf8727598igb.11 for ; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=kDprBoQ1G5ox3bkYrwNkxv4h42vEIke9h2rd3UjyXaU=; b=JdvbQnjmHW0FPDFuREtGBm1fGBXZXOecEpvLdJ+GyIE1/17hn+hZu5G27CI0F7ZJNm YF1pHlCblKPS9EtyWmWTqCWoWwz2NfbJvoFm/9T3/IxERqaU3vm2ZPEFv+1opJMsoy/C /K/U/beBc67U94UJNhlpoMJAJlxwW2vwZav9oGg2Il4thC/Azh6JoqEnwlhPJ0CsHPwm C4qVH3cZVUvJiGVccd+kpSDJFgAEKNNpKjksYlhJ5Fz2BcZIhtnfitXLN4JzJuni8/jg Y5AcDXkZvtZo/m80sFI/L8MvLMzFkPS0043opZ2aV8xXJX2AQQgwIrbhShn7svCldLhj mCxA== X-Gm-Message-State: ALoCoQlhBgiAOGp6AkoxkVZrEDMCGbMiycvKSKQNCWa16ftEtCBbFETi/wUzoS8lNdiuBFI4mTFv X-Received: by 10.42.26.77 with SMTP id e13mr9742460icc.7.1401622350753; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.4 with SMTP id a4ls1615218qga.45.gmail; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) X-Received: by 10.52.141.74 with SMTP id rm10mr20817301vdb.6.1401622350639; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id 7si6618252vcu.41.2014.06.01.04.32.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Jun 2014 04:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id oz11so4044525veb.30 for ; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) X-Received: by 10.221.5.1 with SMTP id oe1mr24983811vcb.10.1401622350567; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp28779vcb; Sun, 1 Jun 2014 04:32:30 -0700 (PDT) X-Received: by 10.140.83.209 with SMTP id j75mr36859469qgd.42.1401622350064; Sun, 01 Jun 2014 04:32:30 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id a100si13389601qge.17.2014.06.01.04.32.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jun 2014 04:32:30 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wr3yX-000483-7h; Sun, 01 Jun 2014 11:30:53 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wr3yV-00045Q-0s for linux-arm-kernel@lists.infradead.org; Sun, 01 Jun 2014 11:30:51 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.25]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s51BURwo023495; Sun, 1 Jun 2014 12:30:27 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 8C03B1AE3351; Sun, 1 Jun 2014 12:30:33 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] ARM: mcs lock: implement wfe-based polling for MCS locking Date: Sun, 1 Jun 2014 12:30:32 +0100 Message-Id: <1401622232-9918-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.9.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140601_043051_479730_6CDF3655 X-CRM114-Status: GOOD ( 10.82 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: Will Deacon X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This patch introduces a wfe-based polling loop for spinning on contended MCS locks and waking up corresponding waiters when the lock is released. Signed-off-by: Will Deacon --- v1 => v2: Use SMP guards and dsb_sev() macro to ensure this compiles and runs only on CPUs that can support v6k. arch/arm/include/asm/mcs_spinlock.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 arch/arm/include/asm/mcs_spinlock.h diff --git a/arch/arm/include/asm/mcs_spinlock.h b/arch/arm/include/asm/mcs_spinlock.h new file mode 100644 index 000000000000..f652ad65840a --- /dev/null +++ b/arch/arm/include/asm/mcs_spinlock.h @@ -0,0 +1,23 @@ +#ifndef __ASM_MCS_LOCK_H +#define __ASM_MCS_LOCK_H + +#ifdef CONFIG_SMP +#include + +/* MCS spin-locking. */ +#define arch_mcs_spin_lock_contended(lock) \ +do { \ + /* Ensure prior stores are observed before we enter wfe. */ \ + smp_mb(); \ + while (!(smp_load_acquire(lock))) \ + wfe(); \ +} while (0) \ + +#define arch_mcs_spin_unlock_contended(lock) \ +do { \ + smp_store_release(lock, 1); \ + dsb_sev(); \ +} while (0) + +#endif /* CONFIG_SMP */ +#endif /* __ASM_MCS_LOCK_H */