Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp779607ybl; Thu, 23 Jan 2020 07:36:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzr5RXqHyQfI/uhWgygltJMUT6q1Tk2Mtp2E6HkWkFRF6Ta+7R7R75tvu4zZ3aZ73jMo37U X-Received: by 2002:a05:6808:3d9:: with SMTP id o25mr11235994oie.126.1579793796072; Thu, 23 Jan 2020 07:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579793796; cv=none; d=google.com; s=arc-20160816; b=Q/sdThSm2exTkbEtLPnjPrJBDV04gbtgfurg+oZMFJ3iWFw0GkAM5q4rUlFsEXj6W/ /gFBNyzwJNVmDcR4Ums/sVem14PJGsvKhm93+avKtNok+aC3wD9KBTL3EpgbQ5YGpFnv pVK9PLgcNsCjT9QAtpE12b7gkYXHM58cDLk1TLHmni54YOyJSPCMF/ASDACQvmA9BlDH 9UVvg6jgeOdNaXmAGofPlfEvrCetH4+CHTxz5EFaihoD7gKjuw8Wx2bBHyYnr2om00L2 rtvGRzboHuI6SJt7rPDlAyiaRWOIfRk012Tk6VeBA09BnMeMF9YyzTtkry6EOdVnPcrO 1zDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=naZKlDznuXCv2H1fKcaww0wTdm05IpMqjqe0iU99XTg=; b=BmjM2CfxibKsDfjtXWPiCQeGpwYJuycN6d7lZiyN4JYkdqX9c3WX9gJq5qOkv7/vFF PQYyPWsHLp3G3RhFlUwpkqbPC2rYfSbk083iveea3ZM4iOUQ8TkA3r7xJV+w4DxIVR9W ijhl7zB3cQk4y9O23ExitpUYATB9QXxTV+VY+C1Gchoria6MSSLHELK8xuwF2vc9Eaa1 z2jPS6pDAE1Y8NtFlN09Sg8TvHP/OZ2h/UbZexE5ZRGYj0mLxbAglkgfVc23zsw9esHp Up86oS5E73CGGKKRL/TkHQ/IMAnNiyuIsuvS7n/Qwip8hOMD5tZ7DBlZj/uyXMnu5fb8 65+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="L//ee4fa"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si927295oin.93.2020.01.23.07.36.24; Thu, 23 Jan 2020 07:36:36 -0800 (PST) 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=@kernel.org header.s=default header.b="L//ee4fa"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729182AbgAWPeN (ORCPT + 99 others); Thu, 23 Jan 2020 10:34:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:51904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729159AbgAWPeL (ORCPT ); Thu, 23 Jan 2020 10:34:11 -0500 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB7F721D7D; Thu, 23 Jan 2020 15:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579793651; bh=EO//m1a5/W3ayPB+jVjN2R3Nvy9PLK/PkD+2e3tSVsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L//ee4fa7iSJOyltW23ThNXNer+l9jfq1sDnIRdPDwvW6qtuMc7TcN0QbwnJYw6M7 uZcQXMhQiFjyfk9DrrVJzQMFGbZYPoa9rvoJQBId+RlgL+8OM5gXwlfBiq4NqvB9KH Rt3oXdJVoECuS81cfkSNb8d52iznzKUMyLNTQDq0= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, kernel-team@android.com, Will Deacon , Michael Ellerman , Peter Zijlstra , Linus Torvalds , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann , Peter Oberparleiter , Masahiro Yamada , Nick Desaulniers Subject: [PATCH v2 07/10] locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros Date: Thu, 23 Jan 2020 15:33:38 +0000 Message-Id: <20200123153341.19947-8-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123153341.19947-1-will@kernel.org> References: <20200123153341.19947-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Passing volatile-qualified pointers to the asm-generic implementations of the load-acquire macros results in a re-load from the stack due to the temporary result variable inheriting the volatile semantics thanks to the use of 'typeof()'. Define these temporary variables using 'unqual_scalar_typeof' to drop the volatile qualifier in the case that they are scalar types. Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Arnd Bergmann Signed-off-by: Will Deacon --- include/asm-generic/barrier.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h index 85b28eb80b11..2eacaf7d62f6 100644 --- a/include/asm-generic/barrier.h +++ b/include/asm-generic/barrier.h @@ -128,10 +128,10 @@ do { \ #ifndef __smp_load_acquire #define __smp_load_acquire(p) \ ({ \ - typeof(*p) ___p1 = READ_ONCE(*p); \ + __unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \ compiletime_assert_atomic_type(*p); \ __smp_mb(); \ - ___p1; \ + (typeof(*p))___p1; \ }) #endif @@ -183,10 +183,10 @@ do { \ #ifndef smp_load_acquire #define smp_load_acquire(p) \ ({ \ - typeof(*p) ___p1 = READ_ONCE(*p); \ + __unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \ compiletime_assert_atomic_type(*p); \ barrier(); \ - ___p1; \ + (typeof(*p))___p1; \ }) #endif @@ -229,14 +229,14 @@ do { \ #ifndef smp_cond_load_relaxed #define smp_cond_load_relaxed(ptr, cond_expr) ({ \ typeof(ptr) __PTR = (ptr); \ - typeof(*ptr) VAL; \ + __unqual_scalar_typeof(*ptr) VAL; \ for (;;) { \ VAL = READ_ONCE(*__PTR); \ if (cond_expr) \ break; \ cpu_relax(); \ } \ - VAL; \ + (typeof(*ptr))VAL; \ }) #endif @@ -250,10 +250,10 @@ do { \ */ #ifndef smp_cond_load_acquire #define smp_cond_load_acquire(ptr, cond_expr) ({ \ - typeof(*ptr) _val; \ + __unqual_scalar_typeof(*ptr) _val; \ _val = smp_cond_load_relaxed(ptr, cond_expr); \ smp_acquire__after_ctrl_dep(); \ - _val; \ + (typeof(*ptr))_val; \ }) #endif -- 2.25.0.341.g760bfbb309-goog