libhugetlbfs / libhugetlbfs

218 stars 92 forks source link

--hugetlbfs-align fails with 1GB hugepages for x86_64 #70

Open gabriel-rodriguez opened 2 years ago

gabriel-rodriguez commented 2 years ago

Hi all,

I've been trying to link applications to use 1GB hugepages for the text/BSS segments. Unfortunately, I'm getting errors when running as segments would overlap. Upon closer inspection, segments are aligned to 4MiB boundaries, and therefore no wonder they would overlap. Looking at the linker script, I can see that the hugepagesize is computed as follows:

MB=$((1024*1024))
case "$EMU" in
elf32ppclinux)          HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
elf64ppc|elf64lppc)
        hpage_kb=$(cat /proc/meminfo  | grep Hugepagesize: | awk '{print $2}')
        MMU_TYPE=$(cat /proc/cpuinfo  | grep MMU | awk '{ print $3}')
        HPAGE_SIZE=$((hpage_kb * 1024))
        if [ "$MMU_TYPE" == "Hash" ] ; then
                SLICE_SIZE=$((256*$MB))
        else
                SLICE_SIZE=$HPAGE_SIZE
        fi ;;
elf_i386|elf_x86_64)    HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
elf_s390|elf64_s390)    HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
armelf*_linux_eabi|aarch64elf*|aarch64linux*)
        hpage_kb=$(cat /proc/meminfo  | grep Hugepagesize: | awk '{print $2}')
        HPAGE_SIZE=$((hpage_kb * 1024))
        SLICE_SIZE=$HPAGE_SIZE ;;

i.e., for elf_x86_64 the HPAGE_SIZE is fixed to 4MiB, instead of extracting it from /proc/meminfo. Trying to use the same approach as for elf64ppc fails, but how can this issue be fixed to make segments 1GiB-aligned?

Thanks in advance!

Young-xin commented 11 months ago

hi, I have encountered the same problem,How did you handle it? Did it succeed?

gabriel-rodriguez commented 11 months ago

No, I haven't yet found a good solution for it, IIRC (my memory is sketchy after 18 months :-))

On Wed, Sep 20, 2023 at 12:14 PM Young-xin @.***> wrote:

hi, I have encountered the same problem,How did you handle it? Did it succeed?

— Reply to this email directly, view it on GitHub https://github.com/libhugetlbfs/libhugetlbfs/issues/70#issuecomment-1727411497, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA52KQPTWOCUH22I7CE5VGLX3K6ZLANCNFSM5ROTITOQ . You are receiving this because you authored the thread.Message ID: @.***>

Young-xin commented 11 months ago

thanks,