Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()

From: H. Peter Anvin
Date: Wed Oct 11 2023 - 19:15:57 EST


On 10/11/23 15:37, Ingo Molnar wrote:

* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

The only drawback is a larger binary size:

text data bss dec hex filename
25546594 4387686 808452 30742732 1d518cc vmlinux-new.o
25515256 4387814 808452 30711522 1d49ee2 vmlinux-old.o

that increases by 31k (0.123%), probably due to 1578 rdgsbase alternatives.

I'm actually surprised that it increases the text size. The 'rdgsbase'
instruction should be smaller than a 'mov %gs', so I would have
expected the *data* size to increase due to the alternatives tables,
but not the text size.

[ Looks around ]

Oh. It's because we put the altinstructions into the text section.
That's kind of silly, but whatever.

Yeah, we should probably move .altinstructions from init-text to .init.data
or so? Contains a bunch of other sections too that don't get executed
directly ... and in fact has some non-code data structures too, such as ...
".apicdrivers". :-/

I suspect people put all that into .text because it was the easiest place
to modify in the x86 linker script, and linker scripts are arguably scary.


Well, it's more than that; "size" considers all non-writable sections to be "text".

-hpa