Re: [PATCH RFC] x86: enforce inlining for atomics

From: Ingo Molnar
Date: Tue Apr 21 2015 - 03:42:22 EST



* Hagen Paul Pfeifer <hagen@xxxxxxxx> wrote:

> On 20 April 2015 at 23:56, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> > Hmm, that must be config-specific as doing
> >
> > objdump -D vmlinux | grep -i "atomic_add"
> >
> > here gives me only "drm_atomic_add_affected_connectors" matches.
> >
> > It probably gets inlined here always...
>
> Probably, the config is allyesconfig minus trace/kernel adress
> sanitizer and gcov related options.

So the thing is that allyesconfig turns on -Os:

CONFIG_CC_OPTIMIZE_FOR_SIZE=y

which is known to make bad decisions in other areas as well ...

If -Os does such bad inlining decisions (and the inlining examples you
cited are horrible!) then I guess a lot of the other 'inline'
functions are handled by it badly as well.

I'm not sure we should start fighting the compiler: if a compiler does
not take 'inline' seriously then the solution is to use another
compiler, or at least to use different compiler flags.

If inlining decisions are bad even with saner compiler options then we
can use __always_inline, and we actually do that for locking
primitives and some other low level primitives: which are typically
larger than atomics, so even reasonable compilers might uninline them.

But I'm not against your patch either. Linus, what's your preference?

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/