[PATCH v4] elf: Support THP segment load with madvise enabled THP

H.J. Lu hjl.tools@gmail.com
Mon Apr 20 21:45:58 GMT 2026


On Mon, Apr 20, 2026 at 9:15 PM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 4/18/26 11:15 PM, H.J. Lu wrote:
> > Changes from v3:
> >
> > 1. Fold the -z separate-code linker option check.
> > 2. Move DL_MAP_DEFAULT_THP_PAGESIZE to <hugepages.h>
> > and default it to 0.
> > 3. Don't run strace tests for cross-compiling.
> > 4. Remove return after FAIL_UNSUPPORTED in THP test.
> >
> > Changes from v2:
> >
> > 1.  Keep _dl_map_segment_align name.
> > 2.  Pass size_t to _dl_map_segment_align.
> > 3.  Enable THP if THP is always enabled in the kernel.
> > 4.  Disable THP if THP page size > MAX_THP_PAGESIZE
> >
> > Changes from v1:
> >
> > 1. Rebased against the v10 THP test patch from WANG Rui <wangrui@loongson.cn>.
> > 2. Keep DL_MAP_DEFAULT_THP_PAGESIZE.
> >
>
> This has a 32-bit Arm regression:
> https://patchwork.sourceware.org/project/glibc/patch/CAMe9rOqKfFXMDY07GRuppudP3V9fsCDXoyxDesPMNQLDrRhzvg@mail.gmail.com/
>
> Produces 4 regressions:
>    |
>    | regressions.sum:
>    | Running glibc:elf ...
>    | FAIL: elf/tst-thp-1-no-s-code-pde
>    | FAIL: elf/tst-thp-1-no-s-code-static
>    | FAIL: elf/tst-thp-1-pde
>    | FAIL: elf/tst-thp-1-static
>
> I know you're already in discussions with Linaro about this issue.
>
> Please be aware that the Linaro report should have all the information you need.
>

It looks like PIE works and PDE doesn't work on arm.
My arm cross glibc test binaries look like

[hjl@gnu-zen4-1 glibc]$ readelf -lW elf/tst-thp-1-pde

Elf file type is EXEC (Executable file)
Entry point 0x2003dc
There are 11 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  ARM_EXIDX      0x2400e24 0x02400e24 0x02400e24 0x000c8 0x000c8 R   0x4
  PHDR           0x000034 0x00000034 0x00000034 0x00160 0x00160 R   0x4
  INTERP         0x010194 0x00010194 0x00010194 0x00019 0x00019 R   0x1
      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]
  LOAD           0x000000 0x00000000 0x00000000 0x11374 0x11374 R   0x200000
  LOAD           0x200000 0x00200000 0x00200000 0x20032d0 0x20032d0 R E 0x200000
  LOAD           0x2400000 0x02400000 0x02400000 0x00f10 0x00f10 R   0x200000
  LOAD           0x25ffebc 0x027ffebc 0x027ffebc 0x002a4 0x002c4 RW  0x200000
  DYNAMIC        0x25fff08 0x027fff08 0x027fff08 0x000f8 0x000f8 RW  0x4
  NOTE           0x2400ef0 0x02400ef0 0x02400ef0 0x00020 0x00020 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x25ffebc 0x027ffebc 0x027ffebc 0x00144 0x00144 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     .ARM.exidx
   01
   02     .interp
   03     .interp .hash .gnu.hash .dynsym .dynstr .gnu.version
.gnu.version_r .rel.dyn .rel.plt
   04     .init .plt .text .fini
   05     .rodata .ARM.extab .ARM.exidx .eh_frame .note.ABI-tag
   06     .init_array .fini_array .data.rel.ro .dynamic .got .data .bss
   07     .dynamic
   08     .note.ABI-tag
   09
   10     .init_array .fini_array .data.rel.ro .dynamic
[hjl@gnu-zen4-1 glibc]$

No idea why these tests failed on arm.

These are what I asked Linaro.  I couldn't find them in the Linaro report.
I haven't heard back from them.

---
>
> Produces 4 regressions:
>   |
>   | regressions.sum:
>   | Running glibc:elf ...
>   | FAIL: elf/tst-thp-1-no-s-code-pde
>   | FAIL: elf/tst-thp-1-no-s-code-static
>   | FAIL: elf/tst-thp-1-pde
>   | FAIL: elf/tst-thp-1-static

What do they report, like in elf/tst-thp-1-pde.out?  What is in
/sys/kernel/mm/transparent_hugepage/hpage_pmd_size?
---

-- 
H.J.


More information about the Libc-alpha mailing list