Re: [PATCH] perf/x86/intel: Mark expected switch fall-throughs

Nathan Chancellor
2019-06-25T20:27:53Z

Hi Thomas,

On Tue, Jun 25, 2019 at 09:53:09PM +0200, Thomas Gleixner wrote:
> On Tue, 25 Jun 2019, Nathan Chancellor wrote:
> > On Tue, Jun 25, 2019 at 10:12:42AM -0700, Kees Cook wrote:
> > > On Tue, Jun 25, 2019 at 09:18:46AM +0200, Peter Zijlstra wrote:
> > > > Can it build a kernel without patches yet? That is, why should I care
> > > > what LLVM does?
> > >
> > > Yes. LLVM trunk builds and boots x86 now. As for distro availability,
> > > AIUI, the asm-goto feature missed the 9.0 LLVM branch point, so it'll
> > > appear in the following release.
> > >
> > > --
> > > Kees Cook
> >
> > I don't think that's right. LLVM 9 hasn't been branched yet so it should
> > make it in.
> >
> > http://lists.llvm.org/pipermail/llvm-dev/2019-June/133155.html
> >
> > If anyone wants to play around with it before then, we wrote a
> > self-contained script that will build an LLVM toolchain suitable for
> > kernel development:
> >
> > https://github.com/ClangBuiltLinux/tc-build
>
> Useful!
>
> But can the script please check for a minimal clang version required to
> build that thing.
>
> The default clang-3.8 which is installed on Debian stretch explodes. The
> 6.0 variant from backports works as advertised.
>

Hmmm interesting, I test a lot of different distros using Docker
containers to make sure the script works universally and that includes
Debian stretch, which is the stress tester because all of the packages
are older. I install the following packages then run the following
command and it works fine for me (just tested):

$ apt update && apt install -y --no-install-recommends ca-certificates \
ccache clang cmake curl file gcc g++ git make ninja-build python3 \
texinfo zlib1g-dev
$ ./build-llvm.py

If you could give me a build log, I'd be happy to look into it and see
what I can do.

> Kernel builds with the new shiny compiler. Jump labels seem to be enabled.
>
> It complains about a few type conversions:
>
> arch/x86/kvm/mmu.c:4596:39: warning: implicit conversion from 'int' to 'u8' (aka 'unsigned char') changes value from -205 to 51 [-Wconstant-conversion]
> u8 wf = (pfec & PFERR_WRITE_MASK) ? ~w : 0;
> ~~ ^~
>

Yes, there was a patch sent to try and fix this but it was rejected by
the maintainers:

https://github.com/ClangBuiltLinux/linux/issues/95

https://lore.kernel.org/lkml/20180619192504.180479-1-mka@chromium.org/

> but it also makes objtool unhappy:
>
> arch/x86/events/intel/core.o: warning: objtool: intel_pmu_nhm_workaround()+0xb3: unreachable instruction
> kernel/fork.o: warning: objtool: free_thread_stack()+0x126: unreachable instruction
> mm/workingset.o: warning: objtool: count_shadow_nodes()+0x11f: unreachable instruction
> arch/x86/kernel/cpu/mtrr/generic.o: warning: objtool: get_fixed_ranges()+0x9b: unreachable instruction
> arch/x86/kernel/platform-quirks.o: warning: objtool: x86_early_init_platform_quirks()+0x84: unreachable instruction
> drivers/iommu/irq_remapping.o: warning: objtool: irq_remap_enable_fault_handling()+0x1d: unreachable instruction
>

Unfortunately, we have quite a few of those outstanding, it's probably
time to start really taking a look at them:

https://github.com/ClangBuiltLinux/linux/labels/objtool

> Kernel boots. As I'm currently benchmarking VDSO performance, this was
> obviosly my first test. Compared to the same kernel built with gcc6.3 the
> performance of the VDSO drops slightly.
>
> It's below 1%. Though I need to run the same tests on 4 other uarchs to get
> the full picture. This stuff is randomly changing behaviour accross uarchs
> depending on how the c source is arranged. So nothing to worry about (yet).
>

Thanks for trying it out and letting us know. Please keep us in the loop
if you happen to find anything amiss.

Cheers,
Nathan

> Thanks,
>
> tglx
>