Skip to content

When building for aarch64 on Linux, use 64K granularity by default for LG_PAGE to allow 64K and 16K kernel pages to work - #2845

Closed
dneary wants to merge 2 commits into
jemalloc:devfrom
dneary:dev
Closed

dneary wants to merge 2 commits into
jemalloc:devfrom
dneary:dev

Conversation

@dneary

@dneary dneary commented May 7, 2025

Copy link
Copy Markdown

By default, jemalloc builds with LG_SIZE=12 for 2^12 byte page allocation granularity. This breaks any Arm64 system running a 16K kernel (as Macs and Raspberry Pi 5 systems do) and any Arm64 distributions running 16K or 64K kernels. As the larker kernel granule offers considerable performance benefits, many people want to use them, but projects with jemalloc as a dependency do not work when compiled with the default flags.

This patch changes the default LG_PAGE size to 16 (2^16 = 64K) which will work on all Arm64 systems. People who know they will be running jemalloc on 4K systems and want to optimize memory efficiency for that granule size can use --with-lg-page=12 .

This patch fixes the issue described in #2639

@baonq-me

baonq-me commented May 8, 2025

Copy link
Copy Markdown

@baonq-me

baonq-me commented May 8, 2025

Copy link
Copy Markdown

Got error when running make test on GH200 system which use 64K page size

=== test/unit/prof_sys_thread_name ===
<jemalloc>: Invalid conf pair: experimental_lg_prof_threshold:22
test_prof_sys_thread_name:test/unit/prof_sys_thread_name.c:28: Test skipped: (!config_prof)
test_prof_sys_thread_name (non-reentrant): skip
test_prof_sys_thread_name:test/unit/prof_sys_thread_name.c:28: Test skipped: (!config_prof)
test_prof_sys_thread_name (libc-reentrant): skip
test_prof_sys_thread_name:test/unit/prof_sys_thread_name.c:28: Test skipped: (!config_prof)
test_prof_sys_thread_name (arena_new-reentrant): skip
test_prof_sys_thread_name_mt:test/unit/prof_sys_thread_name.c:93: Test skipped: (!config_prof)
test_prof_sys_thread_name_mt (non-reentrant): skip
test_prof_sys_thread_name_mt:test/unit/prof_sys_thread_name.c:93: Test skipped: (!config_prof)
test_prof_sys_thread_name_mt (libc-reentrant): skip
test_prof_sys_thread_name_mt:test/unit/prof_sys_thread_name.c:93: Test skipped: (!config_prof)
test_prof_sys_thread_name_mt (arena_new-reentrant): skip
--- pass: 0/6, skip: 6/6, fail: 0/6 ---

=== test/unit/psset ===
test_empty:test/unit/psset.c:125: Test skipped: (hpa_hugepage_size_exceeds_limit())
test_empty (non-reentrant): skip
Segmentation fault
Test harness error: test/unit/psset w/ MALLOC_CONF=""
Use prefix to debug, e.g. JEMALLOC_TEST_PREFIX="gdb --args" sh test/test.sh test/unit/psset
make: *** [Makefile:706: check_unit] Error 1

And I just found this

/*
 * Used to validate that the hugepage size is not unexpectedly high.  The huge
 * page features (HPA, metadata_thp) are primarily designed with a 2M THP size
 * in mind.  Much larger sizes are not tested and likely to cause issues such as
 * bad fragmentation or simply broken.
 */
#define HUGEPAGE_MAX_EXPECTED_SIZE ((size_t)(16U << 20))

@dneary

dneary commented May 13, 2025 •

Copy link
Copy Markdown
Author

Can anyone help me understand why the Cirrus CI/Travis CI checks are all failing? It seems unrelated to the patch, and I don't understand.

@sallyhaj

Copy link
Copy Markdown

@dneary I don't have enough knowledge to say. I think @paravoid can help, as he maintains this package in Debian.

@paravoid

Copy link
Copy Markdown
Contributor

I do maintain the jemalloc packages in Debian, but I don't know why these CI failures would be related to that -- am I missing something? (Note that I'm not affiliated with upstream development in any way.)

@lexprfuncall

lexprfuncall commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor

Hi @dneary, thanks for the PR. I fixed this in facebook/jemalloc/#34 and since our unfork, should be in jemalloc/jemalloc now, see https://github.com/jemalloc/jemalloc/blob/dev/configure.ac#L1988-L1991. If you think anything is missing, feel free to open an issue and PR so we can follow-up on it.

@dneary

dneary commented Apr 19, 2026

Copy link
Copy Markdown
Author

Thanks! Looks like I did it right, which is reassuring.

@lexprfuncall

Copy link
Copy Markdown
Contributor

Thanks! Looks like I did it right, which is reassuring.

I think so. Had the repository been open we could have just merged what you had.

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.

5 participants