From: Josh Poimboeuf <jpoimboe@kernel.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Uros Bizjak <ubizjak@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Nadav Amit <namit@vmware.com>, Andy Lutomirski <luto@kernel.org>,
Brian Gerst <brgerst@gmail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()
Date: Wed, 11 Oct 2023 18:35:07 -0700 [thread overview]
Message-ID: <20231012013507.jrqnm35p7az6atov@treble> (raw)
In-Reply-To: <9b71932a-d410-4b92-b605-d6acc5d35069@zytor.com>
On Wed, Oct 11, 2023 at 04:15:15PM -0700, H. Peter Anvin wrote:
> On 10/11/23 15:37, Ingo Molnar wrote:
> >
> > * Linus Torvalds <torvalds@linux-foundation.org> 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".
Indeed, I added a printf to "size", it shows that all the following
sections are "text":
.text
.pci_fixup
.tracedata
__ksymtab
__ksymtab_gpl
__ksymtab_strings
__init_rodata
__param
__ex_table
.notes
.orc_header
.orc_unwind_ip
.orc_unwind
.init.text
.altinstr_aux
.x86_cpu_dev.init
.parainstructions
.retpoline_sites
.return_sites
.call_sites
.altinstructions
.altinstr_replacement
.exit.text
.smp_locks
I can't fathom why it doesn't just filter based on the EXECINSTR section
flag.
"size" is probably worse than useless, as many of these sections can
change size rather arbitrarily, especially .orc_* and .*_sites.
I can't help but wonder how many hasty optimizations have been made over
the years based on the sketchy output of this tool.
It should be trivial to replace the use of "size" with our own
"text_size" script which does what we want, e.g., filter on EXECINSTR.
Here are the current EXECINSTR sections:
~/git/binutils-gdb/binutils $ readelf -WS /tmp/vmlinux |grep X
[ 1] .text PROGBITS ffffffff81000000 200000 1200000 00 AX 0 0 4096
[21] .init.text PROGBITS ffffffff833b7000 27b7000 091b50 00 AX 0 0 16
[22] .altinstr_aux PROGBITS ffffffff83448b50 2848b50 00176a 00 AX 0 0 1
[30] .altinstr_replacement PROGBITS ffffffff8372661a 2b2661a 0028b9 00 AX 0 0 1
[32] .exit.text PROGBITS ffffffff83728f10 2b28f10 0030c7 00 AX 0 0 16
As Ingo mentioned, we could make .altinstr_replacement non-executable.
That confuses objtool, but I think we could remedy that pretty easily.
Though, another problem is that .text has a crazy amount of padding
which makes it always the same size, due to the SRSO alias mitigation
alignment linker magic. We should fix that somehow.
--
Josh
next prev parent reply other threads:[~2023-10-12 1:35 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 16:42 [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() Uros Bizjak
2023-10-10 17:32 ` Linus Torvalds
2023-10-10 18:22 ` Uros Bizjak
2023-10-10 18:25 ` Nadav Amit
2023-10-10 18:42 ` Linus Torvalds
2023-10-10 18:37 ` Linus Torvalds
2023-10-10 18:41 ` Uros Bizjak
2023-10-10 18:52 ` Linus Torvalds
2023-10-11 7:27 ` Uros Bizjak
2023-10-11 7:45 ` Uros Bizjak
2023-10-11 19:40 ` Linus Torvalds
2023-10-11 18:42 ` Uros Bizjak
2023-10-11 19:51 ` Linus Torvalds
2023-10-11 19:52 ` Linus Torvalds
2023-10-11 20:00 ` Uros Bizjak
2023-10-11 22:37 ` Ingo Molnar
2023-10-11 23:15 ` H. Peter Anvin
2023-10-12 1:35 ` Josh Poimboeuf [this message]
2023-10-12 6:19 ` Ingo Molnar
2023-10-12 16:08 ` Josh Poimboeuf
2023-10-12 17:59 ` Ingo Molnar
2023-10-12 21:30 ` Josh Poimboeuf
2023-10-13 10:52 ` Ingo Molnar
2023-10-11 7:41 ` Nadav Amit
2023-10-11 19:37 ` Linus Torvalds
2023-10-11 21:32 ` Uros Bizjak
2023-10-11 21:54 ` Linus Torvalds
2023-10-12 15:19 ` Nadav Amit
2023-10-12 16:33 ` Uros Bizjak
2023-10-12 16:55 ` Uros Bizjak
2023-10-12 17:10 ` Linus Torvalds
2023-10-12 17:47 ` Linus Torvalds
2023-10-12 18:01 ` Uros Bizjak
2023-10-13 9:38 ` Uros Bizjak
2023-10-13 11:53 ` Uros Bizjak
2023-10-13 16:38 ` Linus Torvalds
2023-10-12 17:52 ` Uros Bizjak
2023-11-20 9:39 ` Use %a asm operand modifier to obtain %rip-relative addressing Uros Bizjak
2023-10-12 16:56 ` [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() Linus Torvalds
2023-10-12 17:16 ` Linus Torvalds
2023-10-12 19:32 ` Nadav Amit
2023-10-12 19:40 ` Linus Torvalds
2023-10-16 18:52 ` Uros Bizjak
2023-10-16 19:24 ` Linus Torvalds
2023-10-16 20:35 ` Nadav Amit
2023-10-16 20:59 ` Linus Torvalds
2023-10-16 23:02 ` Linus Torvalds
2023-10-16 23:14 ` Linus Torvalds
2023-10-17 7:23 ` Nadav Amit
2023-10-17 19:00 ` Linus Torvalds
2023-10-17 19:11 ` Uros Bizjak
2023-10-17 21:05 ` Uros Bizjak
2023-10-17 21:53 ` Linus Torvalds
2023-10-17 22:06 ` Nadav Amit
2023-10-17 22:29 ` Nadav Amit
2023-10-18 7:46 ` Uros Bizjak
2023-10-18 9:04 ` Uros Bizjak
2023-10-18 10:54 ` Nadav Amit
2023-10-18 12:14 ` Uros Bizjak
2023-10-18 13:15 ` Uros Bizjak
2023-10-18 14:46 ` Nadav Amit
2023-10-18 15:17 ` Uros Bizjak
2023-10-18 16:03 ` Nadav Amit
2023-10-18 16:26 ` Linus Torvalds
2023-10-18 17:23 ` Uros Bizjak
2023-10-18 18:11 ` Linus Torvalds
2023-10-18 18:08 ` Uros Bizjak
2023-10-18 18:15 ` Linus Torvalds
2023-10-18 18:26 ` Uros Bizjak
2023-10-18 19:33 ` Uros Bizjak
2023-10-18 20:17 ` Nadav Amit
2023-10-18 20:22 ` Linus Torvalds
2023-10-18 20:34 ` Linus Torvalds
2023-10-18 20:51 ` Uros Bizjak
2023-10-18 21:09 ` Uros Bizjak
2023-10-18 21:10 ` Linus Torvalds
2023-10-18 21:40 ` Uros Bizjak
2023-10-18 22:40 ` Linus Torvalds
2023-10-18 23:06 ` Linus Torvalds
2023-10-19 7:04 ` Uros Bizjak
2023-10-19 16:59 ` Linus Torvalds
2023-10-19 17:21 ` Uros Bizjak
2023-10-19 18:06 ` Linus Torvalds
2023-10-19 18:16 ` Uros Bizjak
2023-10-19 18:49 ` Linus Torvalds
2023-10-19 19:07 ` Linus Torvalds
2023-10-20 7:57 ` Uros Bizjak
2023-10-19 21:04 ` Linus Torvalds
2023-10-19 22:39 ` Linus Torvalds
2023-10-20 8:08 ` Uros Bizjak
2023-10-19 8:44 ` Peter Zijlstra
2023-10-19 8:54 ` Peter Zijlstra
2023-10-19 17:04 ` Linus Torvalds
2023-10-19 18:13 ` Peter Zijlstra
2023-10-19 18:22 ` Linus Torvalds
2023-10-19 18:37 ` Uros Bizjak
2023-10-19 9:07 ` Peter Zijlstra
2023-10-19 9:23 ` Uros Bizjak
2023-10-18 20:42 ` Uros Bizjak
2023-10-19 16:32 ` Uros Bizjak
2023-10-19 17:08 ` Linus Torvalds
2023-10-18 18:29 ` Nadav Amit
2023-10-18 16:12 ` Linus Torvalds
2023-10-18 17:07 ` Uros Bizjak
2023-10-18 18:01 ` Linus Torvalds
2023-10-16 21:09 ` Uros Bizjak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231012013507.jrqnm35p7az6atov@treble \
--to=jpoimboe@kernel.org \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=namit@vmware.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).