From: Eric Dumazet <dada1@cosmosbay.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: "H. Peter Anvin" <hpa@linux.intel.com>,
linux-kernel@vger.kernel.org, vgoyal@redhat.com,
hbabu@us.ibm.com, kexec@lists.infradead.org,
ying.huang@intel.com, mingo@elte.hu, tglx@linutronix.de,
ebiederm@xmission.com, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 01/14] x86, boot: align the .bss section in the decompressor
Date: Fri, 08 May 2009 10:18:07 +0200 [thread overview]
Message-ID: <4A03EABF.40702@cosmosbay.com> (raw)
In-Reply-To: <20090508071759.GA12808@uranus.ravnborg.org>
Sam Ravnborg a écrit :
> On Thu, May 07, 2009 at 03:26:49PM -0700, H. Peter Anvin wrote:
>> From: H. Peter Anvin <hpa@zytor.com>
>>
>> Aligning the .bss section makes it trivially faster, and makes using
>> larger transfers for the clear slightly easier.
>>
>> [ Impact: trivial performance enhancement, future patch prep ]
>>
>> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
>> ---
>> arch/x86/boot/compressed/vmlinux.lds.S | 1 +
>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S
>> index 0d26c92..27c168d 100644
>> --- a/arch/x86/boot/compressed/vmlinux.lds.S
>> +++ b/arch/x86/boot/compressed/vmlinux.lds.S
>> @@ -42,6 +42,7 @@ SECTIONS
>> *(.data.*)
>> _edata = . ;
>> }
>> + . = ALIGN(32);
>
> Where does this magic 32 comes from?
> I would assume the better choice would be:
> . = ALIGN(L1_CACHE_BYTES);
>
> So we match the relevant CPU.
>
> In general for alignmnet of output sections I see the need for:
> 1) Function call
> 2) L1_CACHE_BYTES
> 3) PAGE_SIZE
> 4) 2*PAGE_SIZE
>
> But I see magic constant used here and there that does not match
> the above (when looking at all archs).
> So I act when I see a new 'magic' number..
>
I totally agree
gcc itself has a strange 32 bytes alignement rule (unless using -Os) for
object of a >= 32 bytes size. Did you know that ?
$ cat try.c
char foo[32] = {1};
$ gcc -O -S try.c
.file "try.c"
.globl foo
.data
.align 32 <<< HERE , what a mess >>
.type foo, @object
.size foo, 32
foo:
.byte 1
.zero 31
.ident "GCC: (GNU) 4.4.0"
.section .note.GNU-stack,"",@progbits
It makes many .o kernel files marked with a 2**5 alignement of .data or percpudata
At link time, it creates many holes.
In my opinion, gcc should have a separate option than -Os, as this as too expensive
side effects on the code speed.
I can save lot of data space if I patch gcc-4.4.0/config/i386/i386.c
to :
/* Compute the alignment for a static variable.
TYPE is the data type, and ALIGN is the alignment that
the object would ordinarily have. The value of this function is used
instead of that alignment to align the object. */
int
ix86_data_alignment (tree type, int align)
{
- int max_align = optimize_size ? BITS_PER_WORD : MIN (256, MAX_OFILE_ALIGNMENT);
+ int max_align = BITS_PER_WORD;
if (AGGREGATE_TYPE_P (type)
&& TYPE_SIZE (type)
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
&& (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= (unsigned) max_align
|| TREE_INT_CST_HIGH (TYPE_SIZE (type)))
&& align < max_align)
align = max_align;
/* x86-64 ABI requires arrays greater than 16 bytes to be aligned
to 16byte boundary. */
if (TARGET_64BIT)
{
if (AGGREGATE_TYPE_P (type)
&& TYPE_SIZE (type)
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
&& (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 128
|| TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 128)
return 128;
next prev parent reply other threads:[~2009-05-08 8:19 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 22:26 [PATCH 00/14] RFC: x86: relocatable kernel changes H. Peter Anvin
2009-05-07 22:26 ` [PATCH 01/14] x86, boot: align the .bss section in the decompressor H. Peter Anvin
2009-05-08 7:17 ` Sam Ravnborg
2009-05-08 8:18 ` Eric Dumazet [this message]
2009-05-08 16:54 ` H. Peter Anvin
2009-05-08 7:53 ` Cyrill Gorcunov
2009-05-08 17:03 ` H. Peter Anvin
2009-05-08 17:15 ` Cyrill Gorcunov
2009-05-08 17:21 ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 02/14] x86, boot: honor CONFIG_PHYSICAL_START when relocatable H. Peter Anvin
2009-05-08 7:34 ` Sam Ravnborg
2009-05-08 16:58 ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 03/14] x86, config: change defaults PHYSICAL_START and PHYSICAL_ALIGN H. Peter Anvin
2009-05-08 7:36 ` Sam Ravnborg
2009-05-08 9:47 ` Ingo Molnar
2009-05-08 17:01 ` H. Peter Anvin
2009-05-07 22:26 ` [PATCH 04/14] x86, boot: unify use LOAD_PHYSICAL_ADDR and LOAD_PHYSICAL_ALIGN H. Peter Anvin
2009-05-07 22:26 ` [PATCH 05/14] kbuild: allow compressors (gzip, bzip2, lzma) to take multiple inputs H. Peter Anvin
2009-05-08 7:42 ` Sam Ravnborg
2009-05-08 20:18 ` H. Peter Anvin
2009-05-08 20:47 ` Sam Ravnborg
2009-05-08 20:49 ` H. Peter Anvin
2009-05-08 21:33 ` Sam Ravnborg
2009-05-07 22:26 ` [PATCH 06/14] x86: add a Kconfig symbol for when relocations are needed H. Peter Anvin
2009-05-07 22:26 ` [PATCH 07/14] x86, boot: simplify arch/x86/boot/compressed/Makefile H. Peter Anvin
2009-05-08 7:45 ` Sam Ravnborg
2009-05-07 22:26 ` [PATCH 08/14] x86, boot: use BP_scratch in arch/x86/boot/compressed/head_*.S H. Peter Anvin
2009-05-07 22:26 ` [PATCH 09/14] x86, boot: add new runtime_address and runtime_size bzImage fields H. Peter Anvin
2009-05-08 7:55 ` Sam Ravnborg
2009-05-08 21:09 ` H. Peter Anvin
2009-05-08 21:35 ` Sam Ravnborg
2009-05-07 22:26 ` [PATCH 10/14] x86, doc: document the runtime_start " H. Peter Anvin
2009-05-07 22:26 ` [PATCH 11/14] x86, boot: use rep movsq to move kernel on 64 bits H. Peter Anvin
2009-05-07 22:27 ` [PATCH 12/14] x86, boot: zero EFLAGS on 32 bits H. Peter Anvin
2009-05-07 22:27 ` [PATCH 13/14] x86: make CONFIG_RELOCATABLE the default H. Peter Anvin
2009-05-07 22:27 ` [PATCH 14/14] x86, defconfig: update defconfigs to relocatable H. Peter Anvin
2009-05-08 1:23 ` [PATCH 00/14] RFC: x86: relocatable kernel changes Eric W. Biederman
2009-05-08 5:31 ` H. Peter Anvin
2009-05-08 6:54 ` Eric W. Biederman
2009-05-08 18:04 ` H. Peter Anvin
2009-05-08 18:47 ` H. Peter Anvin
2009-05-11 5:18 ` RFC: x86: relocatable kernel changes (revised spec) H. Peter Anvin
2009-05-11 11:54 ` Eric W. Biederman
2009-05-11 16:03 ` H. Peter Anvin
2009-05-11 17:56 ` RFC: x86: relocatable kernel changes (revised spec v2) H. Peter Anvin
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=4A03EABF.40702@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=ebiederm@xmission.com \
--cc=hbabu@us.ibm.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sam@ravnborg.org \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
--cc=ying.huang@intel.com \
/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