From patchwork Mon Apr 10 21:35:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 97218 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1540777qgd; Mon, 10 Apr 2017 14:36:22 -0700 (PDT) X-Received: by 10.99.105.133 with SMTP id e127mr56637169pgc.104.1491860182247; Mon, 10 Apr 2017 14:36:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19si14667296pgj.156.2017.04.10.14.36.21; Mon, 10 Apr 2017 14:36:22 -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=pass header.i=@CAVIUMNETWORKS.onmicrosoft.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 S1753487AbdDJVgB (ORCPT + 24 others); Mon, 10 Apr 2017 17:36:01 -0400 Received: from mail-cys01nam02on0071.outbound.protection.outlook.com ([104.47.37.71]:52224 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752940AbdDJVf5 (ORCPT ); Mon, 10 Apr 2017 17:35:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=unwuclnte+/hVNS6EddXmqQpHiXXR0iNIvuRIkzhBto=; b=NXAKuiY+PrfuSIREb2Wh4rRl4ym+1/lDgqDwTr5lDZCwmSkQ8cf9DnF7ycZ9vwzaR+StH2F1hp39bcvpudQBPDbnfWqcKqG7Lng0sVTH7TgH1Hajf0qe4WjqpDwuR0dxHffGICBbQSFnQPWqDwod8epwL23gehTCOxc5ehi+Mcw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (217.118.90.188) by BY1PR0701MB1271.namprd07.prod.outlook.com (10.160.108.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Mon, 10 Apr 2017 21:35:43 +0000 From: Yury Norov To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Yury Norov , Peter Zijlstra , Ingo Molnar , Arnd Bergmann , Catalin Marinas , Will Deacon , Jan Glauber Subject: [PATCH 3/3] arm64/locking: qspinlocks and qrwlocks support Date: Tue, 11 Apr 2017 01:35:04 +0400 Message-Id: <1491860104-4103-4-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491860104-4103-1-git-send-email-ynorov@caviumnetworks.com> References: <1491860104-4103-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [217.118.90.188] X-ClientProxiedBy: HE1PR0802CA0021.eurprd08.prod.outlook.com (10.172.123.159) To BY1PR0701MB1271.namprd07.prod.outlook.com (10.160.108.17) X-MS-Office365-Filtering-Correlation-Id: 03f8ed3c-55f9-46d7-0343-08d480598b04 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:BY1PR0701MB1271; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1271; 3:9dQe+DFCmu2JVKcpSnhvMHTE8m+LhGS3TGuznvICvGCE8LgMhewVEGIMC1SMpjzwGO6IU96cuZlR2Tk3kjLHx8QaguMi3IOoAXTbWH30bW55Kisth0JFyUszhi1lDaH7gAV4bnVplfI143g6s11XmYotNB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g6dBoOSGYmrAgZUNxSx0R/0Q2r2RP7L4Xo5YYliCvrFSS1YFMb8uzhzrF8xZwNzE6PFqNd0aYv7Uxd7pAsl8BO2RdIRn3aiL+ln9Uyg+6Rya8TsdE3/yBF9o4ffvfcC3TUTEalOLiiVofiMZxIM2LZoBkzm6s8uwXGNImc7Ntwu5Jlza7Erte5ZfSlwT1XC26y24FV204HqrpGUQbEfRQVnWnykcHZXsodM2yY3sIwI3KFZpmuaH0r7ipTUk+YYJslvoJGX5+xgHV9l+WDBglRFMVBOxLcrm75OqEhwF0X0TyfQTHcdtqkCvWnEtboI75NgBjYXgRUDaxSkHgsJHw7ENoVKh5wGg7WkFxMUVuWcGSxCEUFZnJbsnnu3fWSN5uzk7ELhvYBOMYk1CQBKYiWYo7eCcHrqzsLtO0v1op/Sgmv99R8pMFklCJF/S+LONNsxbFrHJdftbzX08BnLULaeSkV4K/WftmMtNdfU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(6072148); SRVR:BY1PR0701MB1271; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1271; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1271; 4:raq1txSqji9JugibedRIz63xzfpsw9X8PO19M1laWbvuI3ymzY+j2rz35R5TwdmPxOQH5l6XITomneLGxuWOpuBYalYvlBwhvKYNqK31Fo3KfpHPt8gl6fa0pfCOJhXxQZczTbGydMpZ1X1M93xlPDY2XWl0vtT4XhF9RP9KlEW7ArlgkO+9ubUvYiU+CGhUu86KP+bfIsFzDAl+kIBnehjWbrEwKUnPlOx8OB+rSwq9/IpFZEXUI0yJl97+1qNVSqti5uVB5G3YqBYc5TA9pELuHheXTAEZ3902GPrvYGUByoib1tDZMMDh+AaNDrnWLOAfpM75qRUOsr2AYEst9U0UU7zys1vDpQfkdOvV6ZJ07vw/I53zodT7hbfItFr2WxtRx473Z1u81Nbyn1bgkyzgdxv/FF7GQcX1N09tn+SCcPB7TRmzoJ1Gf7mdx/WbfLUATIPMWXH17OltCXF8j6oiXPrFG44T+BsHiIwudS0M1sGv+/+pU4CQC5YP4BfSCAxzmDxqvmEq2Vt58PassTlnfv+yfIOqqqxyf5Eb32dC3QOMfQsVRFjtCTkZ+0pI3dX5SI/rYFRSDEHTQQpCcy53YkhUhBNRnM3bFES4kT5xqLyry1OqzESfaDSXB75vYt6vxAk4kiR5A+oJZ5pGR0xOzbPXz7Np46mLBH2cjFBsSM8G5wjuV/wIKPHaxTuc5CPgkGqUv7FyX3qj827Dkg== X-Forefront-PRVS: 027367F73D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(39450400003)(39410400002)(39850400002)(39840400002)(39400400002)(36756003)(5003940100001)(7736002)(50986999)(305945005)(76176999)(575784001)(189998001)(53936002)(107886003)(38730400002)(110136004)(5660300001)(42186005)(66066001)(4326008)(47776003)(25786009)(6496005)(33646002)(6486002)(76506005)(54906002)(2950100002)(6116002)(3846002)(48376002)(50466002)(81166006)(6666003)(8676002)(50226002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1271; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1271; 23:FaaDMgGNJkW5qtOJwhepRhqGxinX/A5N+L1ZhJv2vOzfqff9yePg0E43DeOmOMukdcZoN5fJ5P32thjduUeiNo8L6TSPNreFpFdoPfwTRnL9GKA+1vnp3VEXWvZtEmeVOfHvdYD3auKUII5S0pkvWDjl/PiZUA9PwL1sS6KxeYwHrXToQgLLIoARuqgWuWr2EmFIOqE8ugwDIAs34QFT5r4OllIT87gtOnBKNL9VbTJCitUKHX1aSv1MHzWVhuESPEs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QIMujfjYPMFLzW20HxPn/hadbHuV1jO0fhN7CbbsY+9389lSGqHBn550mmek/ZkYZcquptsysW/GnEdeE8yhAC5UKOOXv81ICVJIrGJbioHWvo3XOWHjFeRopIeSIGtSiTFmRrKLwdVpO4tSqKmXdyXgpQGNh5ZvLDe03jGY0HC7rex0Fu9ezQo4ZDDcuRnFX7Z8nEDxb0rM//BYK9zaNj20XvYsV8QGA==; 5:zLCuUs8ACegcoKmKZjOJnubIjGWtGPa/+VDXFqChp9whxCDXPV1bYaQUwOSVeDpQPItRflzUE7fJN+mIjexwAgwBdWXIjXxHob7hjHcb4cueAbDliV2W0dSx3YbP2YjwIZkLGg7FVksa230vQN29qg==; 24:NHilHcUD6NYVVYETUEYhV5MvGAMsYtBKK0ewaBMpmrsv1CahZMcFI4vpv8S9KAeS2a3wb675/ryuhtOxrOmnn1U8sxcAXbryTV7cCfUw40s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1271; 7:o5saQSHE2hPCNyXJikfaxeM4G1ytyXW/gfqcx2hDu6+DyYt7fgzEBuvtGPABDbsMqrhbEuIOAJNhqMKxbhYG1y2COwHqzC6t1rX3r3V34Rej+31HDzh/pU2QIEgUXy7kSwjDeCUCrDziJF8OKXLFWeXb8pdouw2gn3gibanF+d78ZjABPfyNC/WzDTPjtMy0VgeAGboH6Mgb2eBI1aC4j7h6n0J9imZkT2hcWatH4vpAnw3RBSBfgTV6a83aBAvA0h7qp6UEpIHXAP1bsyXMQk7+mt7WG6GTVxOVLNOH+uFWB4STnwSnk/b6ueQX5mU7u/KE0MnpPXW6SrAr1Ylnvg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2017 21:35:43.3388 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1271 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Glauber Ported from x86_64 with paravirtualization support removed. Signed-off-by: Jan Glauber Note. This patch removes protection from direct inclusion of arch/arm64/include/asm/spinlock_types.h. It's done because kernel/locking/qrwlock.c file does it thru the header include/asm-generic/qrwlock_types.h. Until now the only user of qrwlock.c was x86, and there's no such protection too. I'm not happy to remove the protection, but if it's OK for x86, it should be also OK for arm64. If not, I think we'd fix it for x86, and add the protection there too. Yury Signed-off-by: Yury Norov --- arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/qrwlock.h | 7 +++++++ arch/arm64/include/asm/qspinlock.h | 20 ++++++++++++++++++++ arch/arm64/include/asm/spinlock.h | 12 ++++++++++++ arch/arm64/include/asm/spinlock_types.h | 14 +++++++++++--- 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 arch/arm64/include/asm/qrwlock.h create mode 100644 arch/arm64/include/asm/qspinlock.h -- 2.7.4 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index f2b0b52..ac1c170 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -24,6 +24,8 @@ config ARM64 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION select ARCH_WANT_FRAME_POINTERS select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_USE_QUEUED_SPINLOCKS + select ARCH_USE_QUEUED_RWLOCKS select ARM_AMBA select ARM_ARCH_TIMER select ARM_GIC diff --git a/arch/arm64/include/asm/qrwlock.h b/arch/arm64/include/asm/qrwlock.h new file mode 100644 index 0000000..626f6eb --- /dev/null +++ b/arch/arm64/include/asm/qrwlock.h @@ -0,0 +1,7 @@ +#ifndef _ASM_ARM64_QRWLOCK_H +#define _ASM_ARM64_QRWLOCK_H + +#include +#include + +#endif /* _ASM_ARM64_QRWLOCK_H */ diff --git a/arch/arm64/include/asm/qspinlock.h b/arch/arm64/include/asm/qspinlock.h new file mode 100644 index 0000000..98f50fc --- /dev/null +++ b/arch/arm64/include/asm/qspinlock.h @@ -0,0 +1,20 @@ +#ifndef _ASM_ARM64_QSPINLOCK_H +#define _ASM_ARM64_QSPINLOCK_H + +#include + +#define queued_spin_unlock queued_spin_unlock +/** + * queued_spin_unlock - release a queued spinlock + * @lock : Pointer to queued spinlock structure + * + * A smp_store_release() on the least-significant byte. + */ +static inline void queued_spin_unlock(struct qspinlock *lock) +{ + smp_store_release((u8 *)lock, 0); +} + +#include + +#endif /* _ASM_ARM64_QSPINLOCK_H */ diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h index cae331d..3771339 100644 --- a/arch/arm64/include/asm/spinlock.h +++ b/arch/arm64/include/asm/spinlock.h @@ -20,6 +20,10 @@ #include #include +#ifdef CONFIG_QUEUED_SPINLOCKS +#include +#else + /* * Spinlock implementation. * @@ -187,6 +191,12 @@ static inline int arch_spin_is_contended(arch_spinlock_t *lock) } #define arch_spin_is_contended arch_spin_is_contended +#endif /* CONFIG_QUEUED_SPINLOCKS */ + +#ifdef CONFIG_QUEUED_RWLOCKS +#include +#else + /* * Write lock implementation. * @@ -351,6 +361,8 @@ static inline int arch_read_trylock(arch_rwlock_t *rw) /* read_can_lock - would read_trylock() succeed? */ #define arch_read_can_lock(x) ((x)->lock < 0x80000000) +#endif /* CONFIG_QUEUED_RWLOCKS */ + #define arch_read_lock_flags(lock, flags) arch_read_lock(lock) #define arch_write_lock_flags(lock, flags) arch_write_lock(lock) diff --git a/arch/arm64/include/asm/spinlock_types.h b/arch/arm64/include/asm/spinlock_types.h index 55be59a..0f0f156 100644 --- a/arch/arm64/include/asm/spinlock_types.h +++ b/arch/arm64/include/asm/spinlock_types.h @@ -16,9 +16,9 @@ #ifndef __ASM_SPINLOCK_TYPES_H #define __ASM_SPINLOCK_TYPES_H -#if !defined(__LINUX_SPINLOCK_TYPES_H) && !defined(__ASM_SPINLOCK_H) -# error "please don't include this file directly" -#endif +#ifdef CONFIG_QUEUED_SPINLOCKS +#include +#else #include @@ -36,10 +36,18 @@ typedef struct { #define __ARCH_SPIN_LOCK_UNLOCKED { 0 , 0 } +#endif /* CONFIG_QUEUED_SPINLOCKS */ + +#ifdef CONFIG_QUEUED_RWLOCKS +#include +#else + typedef struct { volatile unsigned int lock; } arch_rwlock_t; #define __ARCH_RW_LOCK_UNLOCKED { 0 } +#endif /* CONFIG_QUEUED_RWLOCKS */ + #endif