Re: [PATCH 2/2] x86, boot: Optimize the elf header handling.

From: Eric W. Biederman
Date: Sun Jul 01 2012 - 15:20:36 EST


"H. Peter Anvin" <hpa@xxxxxxxxx> writes:

> On 07/01/2012 11:25 AM, Eric W. Biederman wrote:
>>
>> Well I see what is going on now.
>>
>> In the vmlinux the paddrs and the poffsests stop tracking when they
>> come to the percpu PT_LOAD segment.
>>
>> It looks like we give the percpu segment a 4K alignment in memory
>> and a 2M alignment in the file.
>>
>> It looks like something is causing ld to compute an unfortunate physical
>> load address for the percpu section.
>>
>> At first glace I would say that is a bug. Either we need the alignment
>> or we don't. But if we need the alignment we certainly need it to
>> be respected for the real memory locations of the init symbols..
>>
>
> If we don't need it, I think we can use -z max-page-size=4096, but we
> use the PMD alignment for percpu on x86-64; Tejun, does that apply to
> the .data..percpu section in the executable as well?

Grumble Grumble.

If I force a 2M alignment, poffsets and paddrs align and my previous
patches work. Although I don't expect that to be more than a testing
hack.

Meanwhile if I force a 4K max page size for most purposes things look
better from a file offset perspective. But the data segment is now less
aligned in the file than it is in memory and my patches don't work.

Sigh.

I feel like I have stumbled into pandoras box.

Eric


diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index af6fb8a..7276d44 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -187,6 +187,7 @@ SECTIONS
* output PHDR, so the next output section - .init.text - should
* start another segment - init.
*/
+ . = ALIGN(0x200000);
PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
#endif


> -hpa

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1f25214..b5b31c3 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -120,7 +120,7 @@ avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_
KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr)
KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr)

-LDFLAGS := -m elf_$(UTS_MACHINE)
+LDFLAGS := -m elf_$(UTS_MACHINE) -z max-page-size=4096

# Speed up the build
KBUILD_CFLAGS += -pipe


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/