Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp778245ybz; Wed, 15 Apr 2020 18:51:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKL8Ub9YGNU+7SEKh0chShXI64rS++2qjFa58sLbHaO3jRvc/sM6q2l873gpmJm/C4Gw0il X-Received: by 2002:a17:906:d291:: with SMTP id ay17mr7668091ejb.183.1587001865694; Wed, 15 Apr 2020 18:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587001865; cv=none; d=google.com; s=arc-20160816; b=IIf4as+0gViOL1lC3dNgevvT2hgEc2VJLKwFIVHV5tNLJi/mteryfvtW+d/UeyOiDj f8j4VUb6G9fgS1PCyT4bjdKjDdasbm2sDXCugrdn5grmqA14yb4JcqpBVsjZvOdPHR5Z FRcC1Ysusnl91cl+EgirVnH143JdBnqSKaa1gm7IZsQW05QRwjB8LA4w5bCq/GgQJ3b8 Irw+KmSWwsb5pqf9yT5FJQYjlLYMYhYbK/AP//+okO8Rx+CV9ZWs3Plq96K/0/RGMN33 pCsLVBOsSiaYQyyFnLpoBijyKRJE90dRsCkrQq6x+1ZF7E4gQpvbb1LpO5UGe3MmBy/3 0c5A== 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=Y1UZz/HSuR7lr5+FzJGD1Yuf0lek2gCHFvLny4pYlJY=; b=yBsTP3derHVp/1ZAa0jCRSveZmexiTG5ol7P5DFx26/v6fMSFHueclePyHnRPCIhbR cpb7ldZByk52MkIeAWeG6k5FR07DAvkNaMLPsFtzSw0Vn+J/K0mTRkVinsTcVAMQ7Jre 7tqtLAc/8UNPB9Mv0F3IVLaEI97bVRUmFhEpDl9lQNnkMgAQqfxQe8L2/TKfVvnVqHmu Ji8TNpGxzYpm/PNC0J8sc4OS0wYZELuN23Eo1sXZ7Hpck+PZScolc3A/y9OzkvO40Eja RFqmA9Xvqj81tUfJJNqqjIgVheCnslEVqIYTjJYrulrH4EVqInSaxT6sKKMdcAp716vE cHzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w4oWkOi0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n26si10414393ejy.188.2020.04.15.18.50.42; Wed, 15 Apr 2020 18:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w4oWkOi0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2410568AbgDOQxg (ORCPT + 99 others); Wed, 15 Apr 2020 12:53:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:55230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410521AbgDOQxO (ORCPT ); Wed, 15 Apr 2020 12:53:14 -0400 Received: from localhost.localdomain (unknown [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 151F2208FE; Wed, 15 Apr 2020 16:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586969594; bh=B8R3GsZsbA6fc0Q2WUcNbOSuFs4/13y9+Ju2qwpXvr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w4oWkOi0kLClBEHQjHG3WajKCp8buLF0JLbgbwOxCILRvVrP4mJTrGzh6oUVlyOmV LprQLMHKIa81ksAogvRLv7h+6y/lp2N9EH3pTD1jYdBLCKAy2KhaH1c3hEL2ETCDrK Spb/O20lLc2Ts+49sOtQH4FMI/ijBVAbqdCM7Tiw= 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 v3 09/12] locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros Date: Wed, 15 Apr 2020 17:52:15 +0100 Message-Id: <20200415165218.20251-10-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200415165218.20251-1-will@kernel.org> References: <20200415165218.20251-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.26.0.110.g2183baf09c-goog