mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Marco Elver <elver@google.com>
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 <rdunlap@infradead.org>
Subject: Re: [PATCH v2 1/3] asm-generic/atomic: Use __always_inline for pure wrappers
Date: Tue, 26 Nov 2019 12:29:18 +0000	[thread overview]
Message-ID: <20191126122917.GA37833@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20191126114121.85552-1-elver@google.com>

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 <rdunlap@infradead.org>
> Signed-off-by: Marco Elver <elver@google.com>
> ---
> v2:
> * Add missing '#include <linux/compiler.h>'
> * 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 <<EOF
> -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 <linux/compiler.h>
>  #include <linux/build_bug.h>

Sorry for the (super) trivial nit, but could you please re-order these
two alphabetically, i.e.

#include <linux/build_bug.h>
#include <linux/compiler.h>

With that:

Acked-by: Mark Rutland <mark.rutland@arm.com>

[...]

> @@ -64,6 +64,7 @@ cat << EOF
>  #ifndef _ASM_GENERIC_ATOMIC_LONG_H
>  #define _ASM_GENERIC_ATOMIC_LONG_H
>  
> +#include <linux/compiler.h>
>  #include <asm/types.h>

Unlike the above, this doesn't need to be re-ordered; for whatever
reason, linux/* includes typically come before asm/* includes.

Thanks,
Mark.

  parent reply	other threads:[~2019-11-26 12:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 11:41 Marco Elver
2019-11-26 11:41 ` [PATCH v2 2/3] asm-generic/atomic: Use __always_inline for fallback wrappers Marco Elver
2019-11-26 12:40   ` Mark Rutland
2019-11-26 11:41 ` [PATCH v2 3/3] kcsan: Prefer __always_inline for fast-path Marco Elver
2019-11-26 12:29 ` Mark Rutland [this message]
2019-11-26 14:06   ` [PATCH v2 1/3] asm-generic/atomic: Use __always_inline for pure wrappers Marco Elver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191126122917.GA37833@lakrids.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=arnd@arndb.de \
    --cc=boqun.feng@gmail.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®