Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp922030ybl; Fri, 10 Jan 2020 08:58:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzbfhhoaBrwIikzExg2cLrTX1krUwIlLhbZfBZvQFUNlkbBaWSDz+Bfwt4aTJni2M2E499i X-Received: by 2002:a05:6830:1607:: with SMTP id g7mr3396658otr.320.1578675508438; Fri, 10 Jan 2020 08:58:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578675508; cv=none; d=google.com; s=arc-20160816; b=Suu0iaEjsmsBFq3NKPOpt3NAdsBKQvRE/dSujElAMZd2UcfCdzvRM4g57hRSgT0vrq LrXgyLG0mnvToUdCcjf1FVy9CjStXOlWHNyHl8X3Jva/15bfua5ml7ZjvKNbS9VcG4Ig FEdi5E2dr0uUe55RJFOZblG7lLjHPwzR55fnUycNRQvPAOnqiHHXU+UnnQQMSRwg4thn 2vaM4YWgKXbJ7NHmAbj/lCxxYr/KnVYVQ8C9+9EoFQOdIPy4C5TxerbMSKql9d3UJoTd 2Uw3X7IJ1WkrmF0uVpB/gp0OSaTIAXPUtu/TIKzXpiLP2QSB8gLCcoo7g8m8mVVG8kCP 5r3w== 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=YpywuHldwX9RwlhU5SXggbKkyRBcoUxy+8ENrJjRSbo=; b=F7ZUg0DxjtlQnMgN/f/PTcsd5ijkj3IF3D/Qoup64T8Fmjwcc+tpEzT8avbtmrXyzD m8Oj5LLRaxhaJonfMorhzaEP57JuGmw3R9aQTPg63il9yxfSYMvbaXW9Fbblnpd2HGGc zfHVL6j458IXT7YjZoFOWjFjepGkpDqfwzf/ocT0dggwUl4tlPmg5LnKjTSLr1TQ1LYO 6iRwwx7nTom34fFJtZbkffaUNq92Uf2jwJbH5Gb6OjkSBAU31uU1ffP5cWeuO3ekVd3s ElFCqNqJ5Wk2aP7QbFrmWEEBSovXGVFUVweBY+lqRv5uLzw6IQ1NiFKu7t2ErdISZioY yREw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FDp2xJYL; 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 e26si1754809otj.113.2020.01.10.08.58.17; Fri, 10 Jan 2020 08:58:28 -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=FDp2xJYL; 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 S1728799AbgAJQ5B (ORCPT + 99 others); Fri, 10 Jan 2020 11:57:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:60558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728529AbgAJQ47 (ORCPT ); Fri, 10 Jan 2020 11:56:59 -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 55C372072E; Fri, 10 Jan 2020 16:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578675419; bh=8RNntL5Iu5ZUes7z75c9T3QdnVK56lW30UwxHXgl1go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDp2xJYL9EAyF4Ypx8mjx6f8rHYamsChnhIYbf1QrjJ4jD0GhIsWOua0SH032qVCs ASg4Mw1BaE//N7aJ3M2WNkgf1LyCoDFje1EhNmALu2dsXiqu/V18ezwZlS6o4k5laP PsYxPMuG1jy5U5za1BJBAtrLxb89qCXgUasogSw4= 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 Subject: [RFC PATCH 7/8] locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros Date: Fri, 10 Jan 2020 16:56:35 +0000 Message-Id: <20200110165636.28035-8-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200110165636.28035-1-will@kernel.org> References: <20200110165636.28035-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.rc1.283.g88dfdc4193-goog