Skip to contentSkip to conversation

Make gcc -align options .config-settable

PATCH Andi Kleen 3 participants 7 messages Oct 8, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 8 lines · Denis Vlasenko

Resend.

With all alignment options set to 1 (minimum alignment), I've got 5% smaller vmlinux compared to one built with default code alignment.

Rediffed against 2.6.9-rc3.
Please apply.

I agree with the basic idea (the big alignments also always annoy me when I look at disassembly), but I think your CONFIG options are far too complicated. I don't think anybody will go as far as to tune loops vs function calls.

I would just do a single CONFIG_NO_ALIGNMENTS that sets everything to 1, that should be enough.

-Andi

#2 lore raw
Quoted 10 lines · Andi Kleen
Quoted 8 lines · Denis Vlasenko

Resend.

With all alignment options set to 1 (minimum alignment), I've got 5% smaller vmlinux compared to one built with default code alignment.

Rediffed against 2.6.9-rc3.
Please apply.

Quoted 7 lines

I agree with the basic idea (the big alignments also always annoy me when I look at disassembly), but I think your CONFIG options are far too complicated. I don't think anybody will go as far as to tune loops vs function calls.

I would just do a single CONFIG_NO_ALIGNMENTS that sets everything to 1, that should be enough.

For me, yes, but there are people which are slightly less obsessed with code size than me.

They might want to say "try to align to 16 bytes if it costs less than 5 bytes" etc.

Also bencmarking people may do little research on real usefulness of various kinds of alignment.

Signature · 1 line
vda
#3 lore raw
Quoted 19 lines · Denis Vlasenko
Quoted 10 lines · Andi Kleen
Quoted 8 lines · Denis Vlasenko

Resend.

With all alignment options set to 1 (minimum alignment), I've got 5% smaller vmlinux compared to one built with default code alignment.

Rediffed against 2.6.9-rc3.
Please apply.

Quoted 7 lines

I agree with the basic idea (the big alignments also always annoy me when I look at disassembly), but I think your CONFIG options are far too complicated. I don't think anybody will go as far as to tune loops vs function calls.

I would just do a single CONFIG_NO_ALIGNMENTS that sets everything to 1, that should be enough.

Quoted 8 lines

For me, yes, but there are people which are slightly less obsessed with code size than me.

They might want to say "try to align to 16 bytes if it costs less than 5 bytes" etc.

Also bencmarking people may do little research on real usefulness of various kinds of alignment.

I think that removing aligns completly will be very bad. I am Gentoo user and I set my user space CFLAGS for all system to -falign-loops -fno-align-<everything else>. I did not tested it in depth, but my simple tests show that unaligning loops is a very bad idea. Unaligning functions is safer since small and fast functions should be always inlined.

Thanks,

Grzegorz Kulewski

#4 lore raw
Quoted 7 lines · Grzegorz Kulewski
Quoted 2 lines

Also bencmarking people may do little research on real usefulness of various kinds of alignment.

I think that removing aligns completly will be very bad. I am Gentoo user and I set my user space CFLAGS for all system to -falign-loops -fno-align-<everything else>. I did not tested it in depth, but my simple tests show that unaligning loops is a very bad idea. Unaligning functions

That depends on how often that loop runs. 90% of code runs only 10% of time. I think ultimately we want to mark other 10% of code with:

int __hotpath often_called_func()
{
...
}

Rest of code is to be optimized for size.

Quoted 1 line

is safer since small and fast functions should be always inlined.

Concept of alignment does not apply to inlined functions at all. --
vda

#5 lore raw
Quoted 11 lines · Denis Vlasenko
Quoted 7 lines · Grzegorz Kulewski
Quoted 2 lines

Also bencmarking people may do little research on real usefulness of various kinds of alignment.

I think that removing aligns completly will be very bad. I am Gentoo user and I set my user space CFLAGS for all system to -falign-loops -fno-align-<everything else>. I did not tested it in depth, but my simple tests show that unaligning loops is a very bad idea. Unaligning functions

That depends on how often that loop runs. 90% of code runs only 10% of time. I think ultimately we want to mark other 10% of code with:

Well, loops should probably always be aligned because aligning them will not make the code significantly larger (I think, I did not mensure it), but it will make the code significantly faster, and more friendly to processor's cache.

Quoted 3 lines
Quoted 1 line

is safer since small and fast functions should be always inlined.

Concept of alignment does not apply to inlined functions at all.

That is my point. It is safe not to align functions because fast and often called ones will be inlined and will not be slowed down by lack of alignment.

Thanks,

Grzegorz Kulewski

author
#6 lore raw
In reply to Denis Vlasenko
Quoted 16 lines · Denis Vlasenko
Quoted 15 lines · Andi Kleen
Quoted 8 lines · Denis Vlasenko

Resend.

With all alignment options set to 1 (minimum alignment), I've got 5% smaller vmlinux compared to one built with default code alignment.

Rediffed against 2.6.9-rc3.
Please apply.

I agree with the basic idea (the big alignments also always annoy me when I look at disassembly), but I think your CONFIG options are far too complicated. I don't think anybody will go as far as to tune loops vs function calls.

Quoted 8 lines
Quoted 2 lines

I would just do a single CONFIG_NO_ALIGNMENTS that sets everything to 1, that should be enough.

For me, yes, but there are people which are slightly less obsessed with code size than me.

They might want to say "try to align to 16 bytes if it costs less than 5 bytes" etc.

If they want to go down to that low level they can as well edit the Makefiles. But we already have far too many configs and adding new ones for obscure compiler options is not a good idea.

Also we don't normally add stuff "just in case", but only when people actually use it.

-Andi

#7 lore raw
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

I would just do a single CONFIG_NO_ALIGNMENTS that sets everything to 1, that should be enough.

For me, yes, but there are people which are slightly less obsessed with code size than me.

They might want to say "try to align to 16 bytes if it costs less than 5 bytes" etc.

Quoted 6 lines

If they want to go down to that low level they can as well edit the Makefiles. But we already have far too many configs and adding new ones for obscure compiler options is not a good idea.

Also we don't normally add stuff "just in case", but only when people actually use it.

I have a suspicion that if I had submitted CONFIG_NO_ALIGNMENTS patch instead, there would be comments from another crowd, about it being too coarse.

Look at the post of Grzegorz Kulewski.

Anyway, I don't have strong preference. I just want to be at least able to disable code alignment completely.
--
vda