Skip to content

arm64: user4k: turn 4K userspace on by default, keep user4k=off - #2272

Closed
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
sweep-kcmd/user4k-default
Closed

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
sweep-kcmd/user4k-default

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Per-process 4K userspace pages (CONFIG_ARM64_USER4K_EXPERIMENTAL, default y) became an opt-in behind the user4k=on early parameter in 1705968. Every Aurora distribution now adds that parameter on every supported Mac:

  • Fedora: kiwi kernelcmdline, plus aurora-userpages' %posttrans via grubby.
  • Arch: /etc/default/grub.d/50-aurora-user4k.cfg.
  • NixOS: aurora.userpages → boot.kernelParams.

The lab machines (M1 Pro, M2, J616s, Neo) also boot with it. The behaviour every shipped system runs with should be the kernel's default, not a command-line knob each distribution has to add.

This change:

  • arm64_user4k_on is initialised to true. The early parameter is unchanged: user4k=off (or 0/n) still turns the feature off for that boot, with the same effects as before. The page-size prctls refuse non-native sizes, every exec gets the native granule, the 4K user granule capability is not detected, and the MM_SUBPAGE page_ext record (32 bytes per native page, about 0.2% of RAM with 16K pages) is not reserved. user4k=on is still accepted and does nothing.
  • What the feature offers still depends on the CPU, not on a chip list. The 4K granule is offered only when the sanitised system-wide ID_AA64MMFR0_EL1.TGran4 says every CPU supports it, as before.
  • Comments, Kconfig help, kernel-parameters.txt, user4k.rst, user_page_size.rst and the userpages launcher's hint and README now describe user4k=off as the switch.

Testing:

  • The changed C files (arch/arm64/mm/context.c, arch/arm64/kernel/process.c, arch/arm64/kernel/cpufeature.c, with the edited asm/mmu.h and asm/mmu_context.h) were compiled with the exact clang command lines of the current fleet release build (LLVM=1, release config). They build cleanly. arm64_user4k_on lands in .data..ro_after_init with value 1.
  • A full Image/modules build and the KUnit suites were not run on this branch (the buildbox was saturated). The only functional change is the initial value of a __ro_after_init bool. Existing test configs pass --kernel_args user4k=on and keep working. The arm64-user4k-policy suite still covers the off state with user4k=off.

Hardware rows still needed: boot this kernel without any user4k= on Neo (T8140), J616s (T6040), M1 Pro (T6000) and M2 (T8112). On each, expect the 4K userspace translation granule capability line in dmesg, userpages 4k true to succeed and userpages --status to report 4K under the launcher. Then boot once with user4k=off and expect the capability line gone and userpages 4k true to fail with the off hint.

Ordering: merge this first. The distribution changes that stop adding user4k=on must ship in the same package build as a kernel containing this commit:

  • fedora-aurora: drop user4k=on (rides the kernel-aurora bump)
  • alarm-aurora: drop the 50-aurora-user4k.cfg drop-in (rides the linux-aurora bump)
  • nixos-aurora: userpages stops adding user4k=on (rides the kernel pin bump)

Assisted-by: LLM (Claude:Opus 5.5)

Commit 1705968 ("arm64: user4k: keep 4K userspace off unless
booted with user4k=on") made the per-process user granule an opt-in
while it had been tested only on the J700. Since then every Aurora
distribution boots every supported Mac with user4k=on: Fedora's kiwi
images and aurora-userpages' %posttrans, Arch's
/etc/default/grub.d/50-aurora-user4k.cfg and NixOS's
aurora.userpages module all add it, and the lab fleet (M1 Pro, M2,
J616s, Neo) runs with it. The option that decides the behaviour of
every shipped system should be the kernel's default, not a command-line
knob each distribution has to add.

Initialise arm64_user4k_on to true. The early parameter is unchanged:
user4k=off (or 0/n) still turns the feature off for that boot, with the
same effects as before (the page-size prctls refuse non-native sizes,
every exec gets the native granule, no 4K user granule capability is
detected and the page_ext record is not reserved). user4k=on stays
accepted and is now a no-op.

The decision is still per CPU capability: a CPU without the 4K
translation granule gets no alternative, as before.

Update the comments, Kconfig help, kernel-parameters.txt, user4k.rst,
user_page_size.rst and the userpages launcher's hint and README to
describe user4k=off as the switch.

Signed-off-by: Ryan Murray <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware rows, 2026-11-20: one-shot boots of 7.3.0-aurora-sweepk2. The source is sweep-kcmd/sweepk2-kit cc59ea1, which is integration/aurora 0abc2f3 plus #2292 (make aurora_defconfig), #2286 and #2272. Each boot ran with no machine-specific kernel arguments. The test entries dropped user4k=on, plymouth.ignore-serial-consoles and the apple_sep trace/guard arguments; only root/rootflags/quiet plus the lab watchdog arguments remained.

Mac SoC boot /proc/config.gz == built config tipd command nodes 4K userspace (no user4k=on) WFI register save wfxt hwcap SHA-256 loop (schedutil) failed units / AVC / kernel errors / oops / DART faults
MacBook Neo J700 T8140 32 s yes 2 yes yes hidden 216 runs, 0 wrong 0 / 0 / 0 / 0 / 0
MacBook Pro J616s T6040 62 s yes 4 yes yes hidden 504 runs, 0 wrong 0 / 0 / 0 / 0 / 0
MacBook Pro J316s T6000 45 s yes 4 yes n/a (M1) absent 360 runs, 0 wrong 0 / 0 / 0 / 0 / 0
MacBook Air J413 T8112 27 s yes 3 yes n/a (M2) absent 288 runs, 0 wrong 0 / 0 / 0 / 0 / 0

All four Macs:

  • Boot state: SELinux enforcing, KASLR active (non-zero _text), iommu: DMA domain TLB invalidation policy: strict mode, PREEMPT_LAZY, renderD128 + apple-drm bound.
  • Idle: cpuidle states are entered on every CPU.
  • T8140: booted without arm64.nowfxt or idle=nop; the MIDR-based WFI save and WFxT hiding cover it.

Each Mac went back to its normal kernel afterwards.

Not covered by these rows: suspend/resume, GPU/NVMe throughput against the current kernel, and audio.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware rows for this head (198b011), built into 7.3.0-aurora-fleet77 (integration/aurora b4cd7b3 + this PR + 15 other open PRs as plain merges), booted with no user4k= argument at all:

Mac userpages 4k true boot log default boot
MacBook Neo (T8140) OK CPU features: detected: 4K userspace translation granule fleet77
MacBook Air M2 (T8112) OK fleet77
MacBook Pro M1 Pro (T6000) OK fleet77
MacBook Pro M4 Pro (T6040) booted, not run fleet77
MacBook Air M3 15" (T8122) booted, not run fleet77

All five: SELinux enforcing, 0 failed units, 0 AVC, 0 oops, s2idle 2/2 on the PMU RTC, and the dEQP-VK smoke list (16541 cases) unchanged from the previous kernel. Marking this ready; the image and spec changes that drop the argument (fedora-aurora#417, nixos-aurora#326) stay ordered after the kernel bump that carries it, as their descriptions say.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 21, 2026 06:32
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers. The change is the initialiser of arm64_user4k_on; kstrtobool still parses user4k=off/0/n and user4k=on becomes a no-op. All readers (has_user4k_granule, arm64_bprm_prepare_mm, arch_mm_init_exec, subpage_ext_needed) run after early parameters, so there is no ordering change. With the default on, the page_ext subpage record (about 32 bytes per 16K page) is reserved on every boot; distributions already boot with user4k=on, so this matches what users run today. Nit: the edited ARM64_USER4K_KUNIT_TEST help line in arch/arm64/Kconfig.debug is not reflowed. Rows still to add: a 13-inch M4 Air (J713) boot with no user4k= argument and userpages 4k.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 198b01135512.

The functional change itself (arch/arm64/mm/context.c:48 initializing arm64_user4k_on = true) is clean, CPU-capability-gated via ID_AA64MMFR0_EL1.TGran4, and all 7 CI checks (host-tests, source, rust-build, kunit, DWC3/ATC matrix) are green.

Hard-rule blocker

  1. Agent Co-Authored-By trailer in commit 198b01135512b794213760d2a48d644ce78bad98
    The commit carries:
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    
    Per pre-pr-checklist.md §4 (hard rule), commits must carry human identity and a human Signed-off-by only — no agent Co-Authored-By, no agent sign-off, and no Assisted-by in commit messages. Agent attribution belongs only on the last line of the PR body (which is already present). Please drop the Co-Authored-By trailer from the commit.

Hardware rows still needed

  • user4k=off opt-out boot row: explicitly listed in the PR body ("boot once with user4k=off and expect the capability line gone and userpages 4k true to fail with the off hint"), but neither the sweepk2 nor fleet77 row comment booted with user4k=off.
  • T8132 row (J713 M4 Air or J773g M4 mini) booted without user4k= plus userpages 4k true (and note userpages 4k true was "booted, not run" on T6040 and T8122 in the fleet77 table).

Nits

  • tools/aurora-userpages/userpages.c:23-29: off_hint() now prints "Smaller page sizes are off: the kernel was booted with user4k=off.\n" on EINVAL, which is misleading on a kernel built without CONFIG_ARM64_USER4K_EXPERIMENTAL (that also returns EINVAL).
  • arch/arm64/Kconfig.debug:74-75: line 75 is un-reflowed (107 columns).

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Replaced by #2731: the same code change with a commit that carries only the human sign-off, and the two nits from the review fixed (userpages hint, Kconfig help reflow). The 13-inch M4 Air (J713) now runs it on its default kernel with no user4k= argument, userpages 4k true OK. The user4k=off row is listed there as still to run.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #2731 (same change, commit without the trailer).

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.

2 participants