Skip to contentSkip to conversation

x86_64: use -mskip-rax-setup when available

PATCH In review Rasmus Villemoes 3 participants 9 messages Apr 20, 2015 – Apr 23, 2015 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86_64: use -mskip-rax-setup when available

gcc 5 supports the option -mskip-rax-setup to avoid emitting the two-byte instruction xor %eax,%eax before a vararg function call. Clearing %eax is redundant in the kernel, since no callee expects any floating point arguments, and hence never use the incoming value of %eax for anything.

For a defconfig kernel, the .text saving is around 26 kB:

$ size /tmp/vmlinux.{old,new}
   text    data     bss     dec     hex filename
12221850        1735352 1077248 15034450         e56852 /tmp/vmlinux.old
12195955        1735352 1077248 15008555         e5032b /tmp/vmlinux.new

---

Nothing seems to have happened on the kernel side since H.J. Lu implemented this in December. Since gcc 5 is officially released soon, I think it would be nice if this could soak in -next until the next merge window.

 arch/x86/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/Makefile +2 -0
index 2fda005bb334..00bc42c4cbd1 100644
@@ -81,6 +81,8 @@ else
         KBUILD_CFLAGS += $(call cc-option,-mno-80387)
         KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
 
+        KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
+
 	# Use -mpreferred-stack-boundary=3 if supported.
 	KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
 
Signature · 1 line
2.1.3
maintainer
#1 lore raw
Quoted 13 lines · Rasmus Villemoes

gcc 5 supports the option -mskip-rax-setup to avoid emitting the two-byte instruction xor %eax,%eax before a vararg function call. Clearing %eax is redundant in the kernel, since no callee expects any floating point arguments, and hence never use the incoming value of %eax for anything.

For a defconfig kernel, the .text saving is around 26 kB:

$ size /tmp/vmlinux.{old,new}
   text    data     bss     dec     hex filename
12221850        1735352 1077248 15034450         e56852 /tmp/vmlinux.old
12195955        1735352 1077248 15008555         e5032b /tmp/vmlinux.new
Quoted 5 lines

---

Nothing seems to have happened on the kernel side since H.J. Lu implemented this in December. Since gcc 5 is officially released

I see the same patch from him from Apr. 16th:

https://lkml.kernel.org/r/CAMe9rOrfDo3MGaQc_s5crw3TrYhS8NtqeyRcUFiA0yAV8e9Nig@mail.gmail.com

Why are you sending it too?

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#2 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 3 lines · Rasmus Villemoes

Nothing seems to have happened on the kernel side since H.J. Lu implemented this in December. Since gcc 5 is officially released

I see the same patch from him from Apr. 16th:

https://lkml.kernel.org/r/CAMe9rOrfDo3MGaQc_s5crw3TrYhS8NtqeyRcUFiA0yAV8e9Nig@mail.gmail.com

Why are you sending it too?

Hadn't seen that, so I wrongly assumed everybody had forgotten about it. I don't care about the S-o-b on the trivial Makefile patch, but my request for a feature-suggested-by or similar still stands.

Rasmus

maintainer
#3 lore raw
Quoted 3 lines · Rasmus Villemoes

Hadn't seen that, so I wrongly assumed everybody had forgotten about it. I don't care about the S-o-b on the trivial Makefile patch, but my request for a feature-suggested-by or similar still stands.

I don't understand what that means. Are you saying, you want the patch in or you want attribution or ...?

/me is confused.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#4 lore raw
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Rasmus Villemoes

Hadn't seen that, so I wrongly assumed everybody had forgotten about it. I don't care about the S-o-b on the trivial Makefile patch, but my request for a feature-suggested-by or similar still stands.

I don't understand what that means. Are you saying, you want the patch in

Mostly this, of course, or the whole thing would have been pointless.

Quoted 1 line

or you want attribution or ...?

That would be nice.

Rasmus

maintainer
#5 lore raw
Quoted 3 lines · Rasmus Villemoes
Quoted 1 line

or you want attribution or ...?

That would be nice.

I fail to see for what - I see H.J. Lu's patch from Dec. 2014 and you repeating the same patch months later.

Don't get me wrong - I'd gladly add your attribution too but it is his patch which should go because it was the first. It is only fair this way IMO.

Now, if you go and test his patch on latest linus/master, I'd gladly add your Tested-by...

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#6 lore raw
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Rasmus Villemoes
Quoted 1 line

or you want attribution or ...?

That would be nice.

I fail to see for what - I see H.J. Lu's patch from Dec. 2014 and you repeating the same patch months later.

I think we're talking past each other. What I'd like credit for is coming up with the idea of omitting the xor %eax,%eax in the first place (the original mail was sent to [email protected] [cc'ed to a few x86 maintainers], but that doesn't seem to be publicly archived).

So it is very much not about (attribution for) the Makefile patch itself.

Quoted 2 lines

[...] it is his patch which should go because it was the first. It is only fair this way IMO.

Agreed - all I ask for is being mentioned somewhere in the commit log. Again, I only sent the April 20 patch because I hadn't seen anything happen since December.

Rasmus

maintainer
#7 lore raw
Quoted 4 lines · Rasmus Villemoes

I think we're talking past each other. What I'd like credit for is coming up with the idea of omitting the xor %eax,%eax in the first place (the original mail was sent to [email protected] [cc'ed to a few x86 maintainers], but that doesn't seem to be publicly archived).

Ok, now *this* I was missing. I'll add that information to the commit message.

Quoted 3 lines

Agreed - all I ask for is being mentioned somewhere in the commit log. Again, I only sent the April 20 patch because I hadn't seen anything happen since December.

Right, and I think situations like that can be much easier handled in the future by you or the person who's interested in the patch, replying to the original submission and asking what the status is instead of doing a new and identical patch.

We're on the same page now :-)

Thanks!

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#8 lore raw
In reply to Borislav Petkov
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Rasmus Villemoes
Quoted 1 line

or you want attribution or ...?

That would be nice.

I fail to see for what - I see H.J. Lu's patch from Dec. 2014 and you repeating the same patch months later.

This optimization I implemented in GCC was suggested by Rasmus. He should be recognized.

Quoted 6 lines

Don't get me wrong - I'd gladly add your attribution too but it is his patch which should go because it was the first. It is only fair this way IMO.

Now, if you go and test his patch on latest linus/master, I'd gladly add your Tested-by...

Thanks.

Signature · 1 line
H.J.