Franco Martelli <martelli...@gmail.com>, on 2019-09-13: > Hi, everybody > > in order to achieve Linux kernel optimized for my CPU AMD FX-8350 > Bulldozer2 I changed the line 121 of linux-source-4.19/arch/x86/Makefile > from: > > cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) > > to: > > cflags-$(CONFIG_MK8) += $(call cc-option,-march=bdver2) \ > $(call cc-option,-mtune=bdver2,$(call > cc-option,-mtune=generic)) > > compiling the kernel up to Debian 9.x stretch all worked fine but with > Debian 10 buster I get a lot of warning messages: [...snipped warnings...] > what does it means? Is there a way to get the kernel optimized for my > CPU as it happened in the previous Debian versions?
Hi Franco, I'm not fluent enough in GCC 8 for x86_64 to answer to all the various warnings you indicated. Some may be harmless, and some may eat your data. I would do a few tests with a virtual machine supporting bdver2 instructions before going live anyway, and backups stored far away from the machine once testing, and possibly without contact with that kernel. That is, if it happens to boot; these sort of things do not look very good for instance: > arch/x86/kernel/sys_x86_64.o: warning: objtool: get_align_mask()+0x1d: can't > find jump dest instruction at .text+0x2f I also recall having had to move from ORC to DWARF unwinder to get the build working, but that was on old OS levels, not on newer ones, due to the libelf being too old. Some of these seem related to CPU vulnerabilities mitigations, and might be worth a bug report against the kernel, either Debian or upstream, assuming it also appears /without/ your -march=bdver2 flag: > mm/memory.o: warning: objtool: If this is a retpoline, please patch it in > with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE. Note that someone from the Gentoo community has developed a set of patches to expand the possibilities of optimization for the kernel, depending on Linux and GCC versions. You may be interested in the following one for Buster: https://github.com/graysky2/kernel_gcc_patch/blob/master/enable_additional_cpu_optimizations_for_gcc_v8.1%2B_kernel_v4.13%2B.patch These mainly apply changes in various code sections to put the flags in place, and provide options through the .config file of the source code. I haven't tested it, but I don't believe this will solve your warnings, reading through the patch. Yet it does a bit more than just replacing the compiler flag: there is notably a component related to L1 cache shift which is modified too. That should bring an appreciable performance boost if it corrects cache line mismatch. Please be aware that CPU optimizations in kernel, targeting Zen and Skylake in this case, seemed to be hardly detectable, or even counter productive, with various computer usage patterns, according to measures done by Phoronix earlier this year: https://www.phoronix.com/scan.php?page=article&item=linux-50-march&num=1 Of course this may not be the case for your own typical load, but I would recommend to do a few measures, to assess the actual performance gain on your machine with, and without, CPU specific compiler optimizations. Kind regards, -- Étienne Mollier <etienne.moll...@mailoo.org> 5ab1 4edf 63bb ccff 8b54 2fa9 59da 56fe fff3 882d
signature.asc
Description: OpenPGP digital signature