Repository navigation
arm64: configs: asahi: Cap the page block order at 2 MiB - #599
Merged
Merged
Conversation
With 16K pages the page block order follows the PMD order, so a page block is 32 MiB. khugepaged sizes min_free_kbytes from the page block size, eleven blocks per zone, which comes to 360448 kB (352 MiB) on every 8 GB Mac with this config. The low and high watermarks follow at 440 MiB and 528 MiB, and the per-CPU page list limits are derived from the low watermark, so another 250 to 440 MiB of free pages sits on per-CPU lists where MemFree and MemAvailable do not count it. On a MacBook Neo (8 GB) idling at the GNOME desktop this explains about 1.4 GiB of the 2.9 GiB that free and the desktop monitors report as used: 1.2 GiB of watermark deductions in MemAvailable plus 265 MiB on the per-CPU lists. kswapd also keeps about half a gigabyte free that the page cache could use. The M2 MacBook Air shows the same 360448 kB. Cap the page block order at 7, a 2 MiB block, the same size 4K arm64 and x86 kernels use. min_free_kbytes on the Neo drops to about 22 MiB and the high watermark to about 37 MiB. 32 MiB transparent huge pages are still allocated; compaction needs more free blocks to build one, as the Kconfig help notes. THP is madvise only in our configs. CMA areas need 2 MiB alignment instead of 32 MiB. Booted in QEMU (virt, 6 CPUs, 8 GB, 16K pages, THP madvise) with only this option changed: order 11: min_free_kbytes 411824, MemAvailable 7476144 kB order 7: min_free_kbytes 45056, MemAvailable 8026816 kB QEMU has two zones, so its values are twice a single-zone Mac's. A 128 MiB MADV_HUGEPAGE region got 4 of 4 32 MiB THPs with no fallback on both kernels. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Boot-tested in fleet10 (7.3.0-aurora-fleet10): integration/aurora 1173b79 plus 587, 588, 589, 590, 596, 599, 600, 601, 603, 604, 605, 607 and 608, built with the shipping recipe (Fedora Asahi base + asahi.config, 0 mismatches, all distro gates). apple-dcp host selftests 80/80, and the other host tests match integration/aurora exactly (62 pass, the same 26 pre-existing failures). One-shot boots on the Neo (J700), the M2 and the M1 Pro, compared with each machine's fleet9 boot; fleet10 is now the default on all three. Full dmesg and journals are in aurora-ctl reports/fleet10-20261030. Result for this PR: pass, and the numbers match the prediction.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On 16K-page kernels a page block is 32 MiB, so khugepaged sets
min_free_kbytesto 360448 kB (352 MiB) on every 8 GB Mac. The low and high watermarks follow at 440 and 528 MiB, and the per-CPU free lists are sized from the low watermark. That is a large share of the "3 GB used at idle" DJ saw on a fresh Fedora install.Measured on the Neo (8 GB, GNOME, fleet9, idle):
The M2 MacBook Air shows the same 360448 kB.
This sets
CONFIG_PAGE_BLOCK_MAX_ORDER=7(2 MiB blocks, the 4K arm64 and x86 size) in the shared asahi.config. Predicted for the Neo:min_free_kbytesabout 22 MiB, high watermark about 37 MiB, and the reported idle use down by roughly 1.3 GiB. About 0.5 GiB more RAM is left for the page cache before kswapd runs.Tested:
min_free_kbytes411824 and MemAvailable 7476144 kB. Order 7 gives 45056 and 8026816 kB. QEMU has two zones, so its values are twice a Mac's. A 128 MiBMADV_HUGEPAGEregion got 4 of 4 32 MiB THPs with no fallback on both kernels.olddefconfig, the value survives as 7.Not tested yet: a hardware boot. This needs one universal-kernel boot on the Neo or M2 to check
/proc/sys/vm/min_free_kbytes,/proc/pagetypeinfo, and the idlefree -m. Fedora and ALARM merge asahi.config at build time. nixos-aurora keeps a vendored copy (kernel/asahi.config plus a resolved kernel/config withPAGE_BLOCK_MAX_ORDER=11), so it needs the usual tracking sync.Trade-off: building a 32 MiB THP needs compaction across 16 page blocks instead of one, so PMD THP is harder to get under fragmentation. The Kconfig help notes this. Our configs use THP only on madvise, and mTHP sizes are below 2 MiB anyway.
🤖 Generated with Claude Code