* Re: -freg-struct-return?
2007-02-22 8:09 ` -freg-struct-return? Jeremy Fitzhardinge
@ 2007-02-22 8:15 ` Arjan van de Ven
2007-02-22 8:30 ` -freg-struct-return? Jeremy Fitzhardinge
2007-02-22 8:37 ` -freg-struct-return? Ingo Molnar
2007-02-22 8:38 ` [patch] x86: add -freg-struct-return to CFLAGS Ingo Molnar
` (2 subsequent siblings)
3 siblings, 2 replies; 20+ messages in thread
From: Arjan van de Ven @ 2007-02-22 8:15 UTC (permalink / raw)
To: Jeremy Fitzhardinge; +Cc: Andi Kleen, Linux Kernel Mailing List
> Do we have much assembler which cares about the struct return calling
> convention? If not, it should be a fairly easy test.
is there an attribute to turn it off? because if so we should just make
that part of "asmlinkage".... (not that I know much code using structs
in asm)
--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 8:15 ` -freg-struct-return? Arjan van de Ven
@ 2007-02-22 8:30 ` Jeremy Fitzhardinge
2007-02-22 8:37 ` -freg-struct-return? Ingo Molnar
1 sibling, 0 replies; 20+ messages in thread
From: Jeremy Fitzhardinge @ 2007-02-22 8:30 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Andi Kleen, Linux Kernel Mailing List
Arjan van de Ven wrote:
>> Do we have much assembler which cares about the struct return calling
>> convention? If not, it should be a fairly easy test.
>>
>
> is there an attribute to turn it off? because if so we should just make
> that part of "asmlinkage".... (not that I know much code using structs
> in asm)
>
There doesn't appear to be; just -freg-struct-return and
-fpcc-struct-return.
J
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 8:15 ` -freg-struct-return? Arjan van de Ven
2007-02-22 8:30 ` -freg-struct-return? Jeremy Fitzhardinge
@ 2007-02-22 8:37 ` Ingo Molnar
1 sibling, 0 replies; 20+ messages in thread
From: Ingo Molnar @ 2007-02-22 8:37 UTC (permalink / raw)
To: Arjan van de Ven
Cc: Jeremy Fitzhardinge, Andi Kleen, Linux Kernel Mailing List
* Arjan van de Ven <arjan@infradead.org> wrote:
> > Do we have much assembler which cares about the struct return
> > calling convention? If not, it should be a fairly easy test.
>
> is there an attribute to turn it off? because if so we should just
> make that part of "asmlinkage".... (not that I know much code using
> structs in asm)
i dont know of any such code - asmlinkage is 'long' or pointer based.
Ingo
^ permalink raw reply [flat|nested] 20+ messages in thread
* [patch] x86: add -freg-struct-return to CFLAGS
2007-02-22 8:09 ` -freg-struct-return? Jeremy Fitzhardinge
2007-02-22 8:15 ` -freg-struct-return? Arjan van de Ven
@ 2007-02-22 8:38 ` Ingo Molnar
2007-02-22 11:23 ` Andi Kleen
2007-02-22 18:35 ` Adrian Bunk
2007-02-22 9:50 ` -freg-struct-return? Jakub Jelinek
2007-02-22 11:22 ` -freg-struct-return? Andi Kleen
3 siblings, 2 replies; 20+ messages in thread
From: Ingo Molnar @ 2007-02-22 8:38 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Arjan van de Ven, Andi Kleen, Linux Kernel Mailing List,
Andrew Morton, Linus Torvalds
Subject: [patch] x86: add -freg-struct-return to CFLAGS
From: Ingo Molnar <mingo@elte.hu>
Jeremy Fitzhardinge suggested the use of -freg-struct-return, which does
structure-returns (such as when using pte_t) in registers instead of on
the stack.
that is indeed so, and this option reduced the kernel size a bit:
text data bss dec hex filename
4799506 543456 3760128 9103090 8ae6f2 vmlinux.before
4798117 543456 3760128 9101701 8ae185 vmlinux.after
the resulting kernel booted fine on my testbox. Lets go for it.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/i386/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/arch/i386/Makefile
===================================================================
--- linux.orig/arch/i386/Makefile
+++ linux/arch/i386/Makefile
@@ -31,7 +31,7 @@ LDFLAGS_vmlinux := --emit-relocs
endif
CHECKFLAGS += -D__i386__
-CFLAGS += -pipe -msoft-float -mregparm=3
+CFLAGS += -pipe -msoft-float -mregparm=3 -freg-struct-return
# prevent gcc from keeping the stack 16 byte aligned
CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch] x86: add -freg-struct-return to CFLAGS
2007-02-22 8:38 ` [patch] x86: add -freg-struct-return to CFLAGS Ingo Molnar
@ 2007-02-22 11:23 ` Andi Kleen
2007-02-22 11:27 ` Arjan van de Ven
2007-02-22 18:35 ` Adrian Bunk
1 sibling, 1 reply; 20+ messages in thread
From: Andi Kleen @ 2007-02-22 11:23 UTC (permalink / raw)
To: Ingo Molnar
Cc: Jeremy Fitzhardinge, Arjan van de Ven, Linux Kernel Mailing List,
Andrew Morton, Linus Torvalds
On Thu, Feb 22, 2007 at 09:38:22AM +0100, Ingo Molnar wrote:
> Subject: [patch] x86: add -freg-struct-return to CFLAGS
> From: Ingo Molnar <mingo@elte.hu>
>
> Jeremy Fitzhardinge suggested the use of -freg-struct-return, which does
> structure-returns (such as when using pte_t) in registers instead of on
> the stack.
>
> that is indeed so, and this option reduced the kernel size a bit:
>
> text data bss dec hex filename
> 4799506 543456 3760128 9103090 8ae6f2 vmlinux.before
> 4798117 543456 3760128 9101701 8ae185 vmlinux.after
>
> the resulting kernel booted fine on my testbox. Lets go for it.
Ok I added it for now. Let's see what happens.
I guess people maintaining external Makefiles without Kbuild
are in for a nasty surprise again though. Cannot be avoided unfortunately.
-Andi
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch] x86: add -freg-struct-return to CFLAGS
2007-02-22 11:23 ` Andi Kleen
@ 2007-02-22 11:27 ` Arjan van de Ven
0 siblings, 0 replies; 20+ messages in thread
From: Arjan van de Ven @ 2007-02-22 11:27 UTC (permalink / raw)
To: Andi Kleen
Cc: Ingo Molnar, Jeremy Fitzhardinge, Linux Kernel Mailing List,
Andrew Morton, Linus Torvalds
> I guess people maintaining external Makefiles without Kbuild
> are in for a nasty surprise again though.
that 1) shouldn't be needed at all for 2.6 and 2) is fragile as heck no
matter, I don't think anyone still is doing that... I sure hope that if
anyone still does it that they have no users at all, for the sake of the
users :)
--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch] x86: add -freg-struct-return to CFLAGS
2007-02-22 8:38 ` [patch] x86: add -freg-struct-return to CFLAGS Ingo Molnar
2007-02-22 11:23 ` Andi Kleen
@ 2007-02-22 18:35 ` Adrian Bunk
2007-02-22 22:31 ` H. Peter Anvin
1 sibling, 1 reply; 20+ messages in thread
From: Adrian Bunk @ 2007-02-22 18:35 UTC (permalink / raw)
To: Ingo Molnar
Cc: Jeremy Fitzhardinge, Arjan van de Ven, Andi Kleen,
Linux Kernel Mailing List, Andrew Morton, Linus Torvalds
On Thu, Feb 22, 2007 at 09:38:22AM +0100, Ingo Molnar wrote:
>...
> --- linux.orig/arch/i386/Makefile
> +++ linux/arch/i386/Makefile
> @@ -31,7 +31,7 @@ LDFLAGS_vmlinux := --emit-relocs
> endif
> CHECKFLAGS += -D__i386__
>
> -CFLAGS += -pipe -msoft-float -mregparm=3
> +CFLAGS += -pipe -msoft-float -mregparm=3 -freg-struct-return
>
> # prevent gcc from keeping the stack 16 byte aligned
> CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
Why is this i386 specific?
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch] x86: add -freg-struct-return to CFLAGS
2007-02-22 18:35 ` Adrian Bunk
@ 2007-02-22 22:31 ` H. Peter Anvin
0 siblings, 0 replies; 20+ messages in thread
From: H. Peter Anvin @ 2007-02-22 22:31 UTC (permalink / raw)
To: Adrian Bunk
Cc: Ingo Molnar, Jeremy Fitzhardinge, Arjan van de Ven, Andi Kleen,
Linux Kernel Mailing List, Andrew Morton, Linus Torvalds
Adrian Bunk wrote:
> On Thu, Feb 22, 2007 at 09:38:22AM +0100, Ingo Molnar wrote:
>> ...
>> --- linux.orig/arch/i386/Makefile
>> +++ linux/arch/i386/Makefile
>> @@ -31,7 +31,7 @@ LDFLAGS_vmlinux := --emit-relocs
>> endif
>> CHECKFLAGS += -D__i386__
>>
>> -CFLAGS += -pipe -msoft-float -mregparm=3
>> +CFLAGS += -pipe -msoft-float -mregparm=3 -freg-struct-return
>>
>> # prevent gcc from keeping the stack 16 byte aligned
>> CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
>
> Why is this i386 specific?
>
Because virtually all other architectures have it as their ABI default,
anyway, and ABI selection should be per architecture.
-hpa
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 8:09 ` -freg-struct-return? Jeremy Fitzhardinge
2007-02-22 8:15 ` -freg-struct-return? Arjan van de Ven
2007-02-22 8:38 ` [patch] x86: add -freg-struct-return to CFLAGS Ingo Molnar
@ 2007-02-22 9:50 ` Jakub Jelinek
2007-02-22 11:22 ` -freg-struct-return? Andi Kleen
3 siblings, 0 replies; 20+ messages in thread
From: Jakub Jelinek @ 2007-02-22 9:50 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Arjan van de Ven, Andi Kleen, Linux Kernel Mailing List
On Thu, Feb 22, 2007 at 12:09:04AM -0800, Jeremy Fitzhardinge wrote:
> Arjan van de Ven wrote:
> > Do we know how many gcc bugs this has? (regparm used to have many)
> > other than that.. sounds like a win...
> >
>
> The documentation suggests that its the preferred mode of operation, and
> that its the default on platforms where gcc is the primary compiler. So
> the fact that it isn't for Linux suggests either an oversight or that it
> is actually broken...
It is used for Linux on many architectures (x86_64, sparc64, ia64,
ppc{,64}, arm, sh, m68k to name just a few), but it is an ABI decision,
so e.g. on i386 is not used by default as the ABI mandates structs/unions
are returned in memory.
Jakub
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 8:09 ` -freg-struct-return? Jeremy Fitzhardinge
` (2 preceding siblings ...)
2007-02-22 9:50 ` -freg-struct-return? Jakub Jelinek
@ 2007-02-22 11:22 ` Andi Kleen
2007-02-22 16:42 ` -freg-struct-return? H. Peter Anvin
3 siblings, 1 reply; 20+ messages in thread
From: Andi Kleen @ 2007-02-22 11:22 UTC (permalink / raw)
To: Jeremy Fitzhardinge; +Cc: Arjan van de Ven, Linux Kernel Mailing List
On Thu, Feb 22, 2007 at 12:09:04AM -0800, Jeremy Fitzhardinge wrote:
> Arjan van de Ven wrote:
> > Do we know how many gcc bugs this has? (regparm used to have many)
> > other than that.. sounds like a win...
> >
>
> The documentation suggests that its the preferred mode of operation, and
> that its the default on platforms where gcc is the primary compiler. So
> the fact that it isn't for Linux suggests either an oversight or that it
> is actually broken...
>
> Do we have much assembler which cares about the struct return calling
> convention? If not, it should be a fairly easy test.
I didn't think we had any that returned structures.
-Andi
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 11:22 ` -freg-struct-return? Andi Kleen
@ 2007-02-22 16:42 ` H. Peter Anvin
2007-02-22 17:39 ` -freg-struct-return? Jeremy Fitzhardinge
0 siblings, 1 reply; 20+ messages in thread
From: H. Peter Anvin @ 2007-02-22 16:42 UTC (permalink / raw)
To: Andi Kleen
Cc: Jeremy Fitzhardinge, Arjan van de Ven, Linux Kernel Mailing List
Andi Kleen wrote:
>
> I didn't think we had any that returned structures.
>
Sometimes returning small structures is really nice. If you can pass
them in registers, it's often generates the fastest possible code; much
better than using a pointer.
-hpa
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 16:42 ` -freg-struct-return? H. Peter Anvin
@ 2007-02-22 17:39 ` Jeremy Fitzhardinge
2007-02-22 18:36 ` -freg-struct-return? Andi Kleen
0 siblings, 1 reply; 20+ messages in thread
From: Jeremy Fitzhardinge @ 2007-02-22 17:39 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Andi Kleen, Arjan van de Ven, Linux Kernel Mailing List
H. Peter Anvin wrote:
> Sometimes returning small structures is really nice. If you can pass
> them in registers, it's often generates the fastest possible code;
> much better than using a pointer.
Yes, but specifically, are there any pieces of assembler which return
structures? It appears there are none (since Ingo got a booting
kernel), but there might be something obscure in some corner.
J
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 17:39 ` -freg-struct-return? Jeremy Fitzhardinge
@ 2007-02-22 18:36 ` Andi Kleen
2007-02-22 18:48 ` -freg-struct-return? H. Peter Anvin
2007-02-22 18:56 ` -freg-struct-return? Jan Engelhardt
0 siblings, 2 replies; 20+ messages in thread
From: Andi Kleen @ 2007-02-22 18:36 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: H. Peter Anvin, Arjan van de Ven, Linux Kernel Mailing List
On Thu, Feb 22, 2007 at 09:39:04AM -0800, Jeremy Fitzhardinge wrote:
> H. Peter Anvin wrote:
> > Sometimes returning small structures is really nice. If you can pass
> > them in registers, it's often generates the fastest possible code;
> > much better than using a pointer.
>
> Yes, but specifically, are there any pieces of assembler which return
> structures? It appears there are none (since Ingo got a booting
> kernel), but there might be something obscure in some corner.
When I did the x86-64 port I went over all assembler and I can't remember
anything that did that. Of course there might be out of tree drivers
that do, but they just have to fix it up.
BTW would it make sense to have a special announcement list for such changes?
-Andi
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 18:36 ` -freg-struct-return? Andi Kleen
@ 2007-02-22 18:48 ` H. Peter Anvin
2007-02-23 0:21 ` -freg-struct-return? Andi Kleen
2007-02-22 18:56 ` -freg-struct-return? Jan Engelhardt
1 sibling, 1 reply; 20+ messages in thread
From: H. Peter Anvin @ 2007-02-22 18:48 UTC (permalink / raw)
To: Andi Kleen
Cc: Jeremy Fitzhardinge, Arjan van de Ven, Linux Kernel Mailing List
Andi Kleen wrote:
> On Thu, Feb 22, 2007 at 09:39:04AM -0800, Jeremy Fitzhardinge wrote:
>> H. Peter Anvin wrote:
>>> Sometimes returning small structures is really nice. If you can pass
>>> them in registers, it's often generates the fastest possible code;
>>> much better than using a pointer.
>> Yes, but specifically, are there any pieces of assembler which return
>> structures? It appears there are none (since Ingo got a booting
>> kernel), but there might be something obscure in some corner.
>
> When I did the x86-64 port I went over all assembler and I can't remember
> anything that did that. Of course there might be out of tree drivers
> that do, but they just have to fix it up.
>
> BTW would it make sense to have a special announcement list for such changes?
>
To some degree linux-arch would be a good list for it, but it's closed,
even to monitor.
-hpa
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 18:48 ` -freg-struct-return? H. Peter Anvin
@ 2007-02-23 0:21 ` Andi Kleen
0 siblings, 0 replies; 20+ messages in thread
From: Andi Kleen @ 2007-02-23 0:21 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Jeremy Fitzhardinge, Arjan van de Ven, Linux Kernel Mailing List
> To some degree linux-arch would be a good list for it, but it's closed,
> even to monitor.
linux-arch is only for architecture code, but yes it serves a similar
purpose. But it's very specialized. What is discussed there is unlikely
to be of much interest to most people.
I was thinking of a relatively low volume list where quick notes for
any general interfaces changes that likely needs adaptions in a wide range of
code could be sent. Then even people who cannot follow l-k or git due
to volume could subscribe to that and adapt their code as needed.
-Andi
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 18:36 ` -freg-struct-return? Andi Kleen
2007-02-22 18:48 ` -freg-struct-return? H. Peter Anvin
@ 2007-02-22 18:56 ` Jan Engelhardt
2007-02-22 19:12 ` -freg-struct-return? H. Peter Anvin
1 sibling, 1 reply; 20+ messages in thread
From: Jan Engelhardt @ 2007-02-22 18:56 UTC (permalink / raw)
To: Andi Kleen
Cc: Jeremy Fitzhardinge, H. Peter Anvin, Arjan van de Ven,
Linux Kernel Mailing List
On Feb 22 2007 19:36, Andi Kleen wrote:
>
>BTW would it make sense to have a special announcement list for such changes?
A changelog in the kernel tree would be helpful. A real changelog that is,
not that info blob located at /Documentation/Changes.
Jan
--
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: -freg-struct-return?
2007-02-22 18:56 ` -freg-struct-return? Jan Engelhardt
@ 2007-02-22 19:12 ` H. Peter Anvin
0 siblings, 0 replies; 20+ messages in thread
From: H. Peter Anvin @ 2007-02-22 19:12 UTC (permalink / raw)
To: Jan Engelhardt
Cc: Andi Kleen, Jeremy Fitzhardinge, Arjan van de Ven,
Linux Kernel Mailing List
Jan Engelhardt wrote:
> On Feb 22 2007 19:36, Andi Kleen wrote:
>> BTW would it make sense to have a special announcement list for such changes?
>
> A changelog in the kernel tree would be helpful. A real changelog that is,
> not that info blob located at /Documentation/Changes.
>
I presume you're talking about a BSD-style ChangeLog. I've always found
those utterly useless, since they're basically the equivalent of SCM
history but without any of the abilities to sort, filter, etc, thus
making it utterly impossible to find anything. They're a pain to
maintain (they inherently *always* cause merge failures) and add very
little.
-hpa
^ permalink raw reply [flat|nested] 20+ messages in thread