Skip to content

setup: dynamically detect default huge page size#1600

Open
Kprateek283 wants to merge 1 commit into
axboe:masterfrom
Kprateek283:fix-huge-page-size
Open

setup: dynamically detect default huge page size#1600
Kprateek283 wants to merge 1 commit into
axboe:masterfrom
Kprateek283:fix-huge-page-size

Conversation

@Kprateek283

@Kprateek283 Kprateek283 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Replaces the hardcoded 2MB huge page size with dynamic detection by
parsing /proc/meminfo. This fixes no-mmap allocation failures on
architectures with different default huge page sizes (like ARM64
which often uses 512MB) or x86 systems configured for 1GB pages.

  • Safely parses /proc/meminfo without allocating memory.
  • Uses raw syscalls and manual byte-by-byte matching to maintain strict compatibility with CONFIG_NOLIBC builds (avoiding strstr).
  • Drops the MAP_HUGE_2MB mmap flag to allow the kernel to correctly apply the system's default huge page size.
  • Falls back safely to 2MB if /proc/meminfo is unreadable.

git request-pull output:

The following changes since commit 2750b94a77ea9e4e156fd0caa5c14552e7d1397f:

  Merge branch 'poll-update-trigger' of https://github.com/schlad/liburing (2026-06-10 06:57:31 -0600)

are available in the Git repository at:

  https://github.com/Kprateek283/liburing.git fix-huge-page-size

for you to fetch changes up to 69c3265ab7cacbcb981f7bc6346f89ea076cf672:

  setup: dynamically detect default huge page size (2026-06-12 00:56:19 +0530)

----------------------------------------------------------------
Prateek (1):
      setup: dynamically detect default huge page size

 src/setup.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 68 insertions(+), 16 deletions(-)

By submitting this pull request, I acknowledge that:

  1. I have followed the above pull request guidelines.
  2. I have the rights to submit this work under the same license.
  3. I agree to a Developer Certificate of Origin (see https://developercertificate.org for more information).

    Replaces the hardcoded 2MB huge page size with dynamic detection by
    parsing /proc/meminfo. This fixes no-mmap allocation failures on
    architectures with different default huge page sizes (like ARM64
    which often uses 512MB) or x86 systems configured for 1GB pages.

    - Safely parses /proc/meminfo without allocating memory.
    - Uses raw syscalls and manual byte-by-byte matching to maintain
      strict compatibility with CONFIG_NOLIBC builds (avoiding strstr).
    - Drops the MAP_HUGE_2MB mmap flag to allow the kernel to correctly
      apply the system's default huge page size.
    - Falls back safely to 2MB if /proc/meminfo is unreadable.

Signed-off-by: Prateek <kprateek283@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant