On Fri, Nov 22, 2019 at 04:42:20PM +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. >From looking at the link below, the problem is tat objtool isn't happy about non-whiteliested calls within UACCESS regions. Is that a problem here? are the kasan/kcsan calls whitelisted? > By using __always_inline, we let the real implementation and not the > wrapper determine the final inlining preference. That sounds reasonable to me, assuming that doesn't end up significantly bloating the kernel text. What impact does this have on code size? > 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@xxxxxxxxxxxxx > > Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx> > Signed-off-by: Marco Elver <elver@xxxxxxxxxx> > --- > include/asm-generic/atomic-instrumented.h | 334 +++++++++++----------- > include/asm-generic/atomic-long.h | 330 ++++++++++----------- > scripts/atomic/gen-atomic-instrumented.sh | 6 +- > scripts/atomic/gen-atomic-long.sh | 2 +- > 4 files changed, 336 insertions(+), 336 deletions(-) Do we need to do similar for gen-atomic-fallback.sh and the fallbacks defined in scripts/atomic/fallbacks/ ? [...] > diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh > index 8b8b2a6f8d68..68532d4f36ca 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} We should add an include of <linux/compiler.h> to the preamble if we're explicitly using __always_inline. > diff --git a/scripts/atomic/gen-atomic-long.sh b/scripts/atomic/gen-atomic-long.sh > index c240a7231b2e..4036d2dd22e9 100755 > --- a/scripts/atomic/gen-atomic-long.sh > +++ b/scripts/atomic/gen-atomic-long.sh > @@ -46,7 +46,7 @@ gen_proto_order_variant() > local retstmt="$(gen_ret_stmt "${meta}")" > > cat <<EOF > -static inline ${ret} > +static __always_inline ${ret} Likewise here Thanks, Mark.