Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4161864ybc; Tue, 26 Nov 2019 04:55:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyP7ordEiULwZI8jjDvgCiWKH5TPvM2LbwK/8tx3pgWEdKvqoX1mt7C/NuiiN9ha3abYSVZ X-Received: by 2002:a17:906:a989:: with SMTP id jr9mr41604765ejb.160.1574772950590; Tue, 26 Nov 2019 04:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574772950; cv=none; d=google.com; s=arc-20160816; b=yiMIZloGZXVl3SPjNfueDh96tDmC8brsT54dyxVkQecpq7lchoqSjbonxe2391J0P1 NUxeN9cwvmKF0c9Ytexi1em1BoCBua5YNHOxQP8tupjlUnBtdA5vQmbyc+RMbOVzuuJB pTXtdDVT9uTjcnMP7/pDi65EJBaS2YYGUqEj4zFF7i6XWq534bcqNO8FEspFPMhQXJFj TJ6kfrDyk40bvuRS/+wmDSkYsa/hhan0s9DlZOiSv6C1P+ozHpl7R+WbdSGjNDuTruWA mlN4wXJ9PDrzGbnKguKFx7ljTZxccdN7BLXq6iDpITIIZsB2KElYv2pxDI6FxeOI8Dx5 IPPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=lWwz/9kDrHPU7oL02b+cP8DiPcz80JUDFWe9OuDOHR8=; b=YvqtdPrNP26wJeI5TPA/qWee7sB9S1JOeU/+dbBagcyR1nyWVnBs7YhqQ8y4o2YPVn vo6DWTGUOkbqVH/G6nzXS+AITUL/JHr+uBG9GmObVWXVW3FaJZ95GhzAb9onu/2xkGxD 1xxBJWhQazaJ3GCbp/D/iU6vLIXa4gK5AGrbTrLN7lR8iesIRFaOZDhteJODT/XkSkcB mlhvj9UytnxRRi96Dm4z3jWX3rSj/zN+mGTNJsJcnJSGS88FOmayd+my+X7pfdRtiAq1 e3Ktp6EhQCkWCQBpVl4Uuil3Ck/l3AAtPn7z5LQeR9ShEXIFgPvjZmj7hEPFJ3LcKq53 JbNA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dt11si6867251ejb.126.2019.11.26.04.55.26; Tue, 26 Nov 2019 04:55:50 -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; 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 S1728372AbfKZM3Z (ORCPT + 99 others); Tue, 26 Nov 2019 07:29:25 -0500 Received: from foss.arm.com ([217.140.110.172]:33822 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727408AbfKZM3Z (ORCPT ); Tue, 26 Nov 2019 07:29:25 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 511831FB; Tue, 26 Nov 2019 04:29:24 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA5563F52E; Tue, 26 Nov 2019 04:29:22 -0800 (PST) Date: Tue, 26 Nov 2019 12:29:18 +0000 From: Mark Rutland To: Marco Elver Cc: will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, arnd@arndb.de, dvyukov@google.com, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kasan-dev@googlegroups.com, paulmck@kernel.org, Randy Dunlap Subject: Re: [PATCH v2 1/3] asm-generic/atomic: Use __always_inline for pure wrappers Message-ID: <20191126122917.GA37833@lakrids.cambridge.arm.com> References: <20191126114121.85552-1-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191126114121.85552-1-elver@google.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 26, 2019 at 12:41:19PM +0100, Marco Elver wrote: > Prefer __always_inline for atomic wrappers. When building for size > (CC_OPTIMIZE_FOR_SIZE), some compilers appear to be less inclined to > inline even relatively small static inline functions that are assumed to > be inlinable such as atomic ops. This can cause problems, for example in > UACCESS regions. > > By using __always_inline, we let the real implementation and not the > wrapper determine the final inlining preference. > > For x86 tinyconfig we observe: > - vmlinux baseline: 1316204 > - vmlinux with patch: 1315988 (-216 bytes) > > This came up when addressing UACCESS warnings with CC_OPTIMIZE_FOR_SIZE > in the KCSAN runtime: > http://lkml.kernel.org/r/58708908-84a0-0a81-a836-ad97e33dbb62@infradead.org > > Reported-by: Randy Dunlap > Signed-off-by: Marco Elver > --- > v2: > * Add missing '#include ' > * Add size diff to commit message. > > v1: http://lkml.kernel.org/r/20191122154221.247680-1-elver@google.com > --- > include/asm-generic/atomic-instrumented.h | 335 +++++++++++----------- > include/asm-generic/atomic-long.h | 331 ++++++++++----------- > scripts/atomic/gen-atomic-instrumented.sh | 7 +- > scripts/atomic/gen-atomic-long.sh | 3 +- > 4 files changed, 340 insertions(+), 336 deletions(-) > diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh > index 8b8b2a6f8d68..86d27252b988 100755 > --- a/scripts/atomic/gen-atomic-instrumented.sh > +++ b/scripts/atomic/gen-atomic-instrumented.sh > @@ -84,7 +84,7 @@ gen_proto_order_variant() > [ ! -z "${guard}" ] && printf "#if ${guard}\n" > > cat < -static inline ${ret} > +static __always_inline ${ret} > ${atomicname}(${params}) > { > ${checks} > @@ -146,17 +146,18 @@ cat << EOF > #ifndef _ASM_GENERIC_ATOMIC_INSTRUMENTED_H > #define _ASM_GENERIC_ATOMIC_INSTRUMENTED_H > > +#include > #include Sorry for the (super) trivial nit, but could you please re-order these two alphabetically, i.e. #include #include With that: Acked-by: Mark Rutland [...] > @@ -64,6 +64,7 @@ cat << EOF > #ifndef _ASM_GENERIC_ATOMIC_LONG_H > #define _ASM_GENERIC_ATOMIC_LONG_H > > +#include > #include Unlike the above, this doesn't need to be re-ordered; for whatever reason, linux/* includes typically come before asm/* includes. Thanks, Mark.