Re: [PATCH v9 04/10] x86: refcount: prevent gcc distortions
From: Ingo Molnar
Date: Thu Oct 04 2018 - 05:45:25 EST
* Nadav Amit <namit@xxxxxxxxxx> wrote:
> > Another, separate question I wanted to ask: how do we ensure that the kernel stays fixed?
> > I.e. is there some tooling we can use to actually measure whether there's bad inlining decisions
> > done, to detect all these bad patterns that cause bad GCC code generation?
>
> Good question. First, Iâll indicate that this patch-set does not handle all
> the issues. There is still the issue of conditional use of
> __builtin_constant_p().
>
> One indication for bad inlining decisions is the inlined functions have
> multiple (non-inlined) instances in the binary and are short. I donât
> have an automatic solution, but you can try, for example to run:
>
> nm --print-size ./vmlinux | grep ' t ' | cut -d' ' -f2- | sort | uniq -c | \
> grep -v '^ 1' | sort -n -r | head -n 5
>
> There are however many false positives. After these patches, for example, I
> get:
>
> 11 000000000000012f t jhash
> 7 0000000000000017 t dst_output
> 6 0000000000000011 t kzalloc
> 5 000000000000002f t acpi_os_allocate_zeroed
> 5 0000000000000029 t acpi_os_allocate
>
>
> jhash() should not have been inlined in my mind, and should have a
> non-inlined implementation. dst_output() is used as a function pointer.
> kzalloc() and the next two suffer from the __builtin_constant_p() problem I
> described in the past.
Ok, that's useful info.
The histogram suggests that with all your patches applied the kernel is now in a pretty good
state in terms of inlining decisions, right?
Are you using defconfig or a reasonable distro-config for your tests?
Thanks,
Ingo