Re: [PATCH v5] x86: Avoid relocation information in final vmlinux

From: Nathan Chancellor
Date: Tue Mar 21 2023 - 01:24:26 EST


On Mon, Mar 20, 2023 at 01:12:07PM -0700, Dave Hansen wrote:
> On 3/20/23 05:10, Petr Pavlu wrote:
> > The issue is then that the collected vmlinux file and hence distribution
> > packages end up unnecessarily large because of this extra data. The
> > following is a size comparison of vmlinux v6.0 with and without the
> > relocation information:
> > | Configuration | With relocs | Stripped relocs |
> > | x86_64_defconfig | 70 MB | 43 MB |
> > | +CONFIG_DEBUG_INFO | 818 MB | 367 MB |
> >
> > Optimize a resulting vmlinux by adding a postlink step that splits the
> > relocation information into vmlinux.relocs and then strips it from the
> > vmlinux binary.
>
> When I saw that this adds a postlink step, I read that as, "adds another
> step to the unbearably slow single-threaded part of kernel builds". :)
>
> But, here's one data point that made me feel a lot better. Using a
> random .config:
>
> > https://sr71.net/~dave/intel/config-reloctest
>
> the builds get a _bit_ slower, going from 37.0s->37.7s. This is pretty
> arbitrary of course, using my compiler on my hardware, so YMMV. But,
> for me, this seems like a reasonable tradeoff given the space savings.
>
> I'd be curious what other people are seeing.

I am seeing a negligible difference (~1%) with LLVM 16 when targeting
the following configuration combinations and building the 'bzImage'
target.

* allmodconfig:

Benchmark 1: v6.3-rc3
Time (mean ± σ): 93.370 s ± 0.313 s [User: 3462.570 s, System: 371.420 s]
Range (min … max): 92.993 s … 93.659 s 5 runs

Benchmark 2: v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"
Time (mean ± σ): 93.539 s ± 0.193 s [User: 3464.361 s, System: 370.709 s]
Range (min … max): 93.281 s … 93.816 s 5 runs

Summary
'v6.3-rc3' ran
1.00 ± 0.00 times faster than 'v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"'

* allmodconfig + debug info (DWARF5):

Benchmark 1: v6.3-rc3
Time (mean ± σ): 97.952 s ± 0.451 s [User: 3673.380 s, System: 378.814 s]
Range (min … max): 97.420 s … 98.568 s 5 runs

Benchmark 2: v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"
Time (mean ± σ): 98.302 s ± 1.050 s [User: 3674.310 s, System: 378.323 s]
Range (min … max): 97.603 s … 100.152 s 5 runs

Summary
'v6.3-rc3' ran
1.00 ± 0.01 times faster than 'v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"'

* allyesconfig bzImage:

Benchmark 1: v6.3-rc3
Time (mean ± σ): 674.232 s ± 1.581 s [User: 24901.883 s, System: 2223.728 s]
Range (min … max): 672.478 s … 676.678 s 5 runs

Benchmark 2: v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"
Time (mean ± σ): 679.783 s ± 2.454 s [User: 24903.720 s, System: 2228.943 s]
Range (min … max): 676.369 s … 682.772 s 5 runs

Summary
'v6.3-rc3' ran
1.01 ± 0.00 times faster than 'v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"'

* allyesconfig + debug info (DWARF5):

Benchmark 1: v6.3-rc3
Time (mean ± σ): 709.745 s ± 1.880 s [User: 26570.531 s, System: 2304.563 s]
Range (min … max): 707.918 s … 712.818 s 5 runs

Benchmark 2: v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"
Time (mean ± σ): 711.773 s ± 1.152 s [User: 26571.973 s, System: 2307.176 s]
Range (min … max): 710.127 s … 713.224 s 5 runs

Summary
'v6.3-rc3' ran
1.00 ± 0.00 times faster than 'v6.3-rc3 + "x86: Avoid relocation information in final vmlinux"'

Cheers,
Nathan