Skip to content

drm/asahi: report that GEM_USERPTR pins are not bounded by RLIMIT_MEMLOCK - #3088

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/asahi-userptr-no-memlock-bit
Nov 24, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/asahi-userptr-no-memlock-bit

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What: Report a new feature bit, DRM_ASAHI_FEATURE_USERPTR_NO_MEMLOCK (bit 43), alongside DRM_ASAHI_FEATURE_USERPTR. Since #2961, GEM_USERPTR takes any range the GPU memory limits admit. Older kernels charge the pins to RLIMIT_MEMLOCK (8 MiB by default). Userspace can't tell the two apart before it imports, so Borealis has to choose between failing large host imports on older kernels and hiding VK_EXT_external_memory_host on fixed ones. Borealis reads this bit in aurora-silicon/mesa#963.

Tested: MacBook Neo and J616s M4 Pro, with fleet88 and this commit's aurora.ko: userptr selftest 5/5 (it now also checks the bit), Borealis offers VK_EXT_external_memory_host at the default 8 MiB, a 96 MiB host import works, Geekbench 6 Vulkan completes, dEQP-VK.memory.external_memory_host.* 4 pass / 8 not supported / 0 fail. No kernel errors.

Risk: two-way · Macs whose GPU offers GEM_USERPTR (M4 Pro/Max, M5 family, A18 Pro). It only adds a bit; no behaviour changes.

Not yet: nothing on hardware.

Details
  • file.rs: the bit is reported wherever supports_user_memory() reports GEM_USERPTR, since UserPages::pin() no longer checks RLIMIT_MEMLOCK.
  • uapi: the bit is defined after bit 41 with a comment saying what older kernels do. Bit 42 is left for DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL (drm/asahi: g17: fan M5 Pro compute out to sibling channels for sustained heavy kicks #3035).
  • selftest: memlock_does_not_bound also expects the bit. On a kernel without this commit only that assertion fails (4/5).

checkpatch --strict is clean. rustfmt shows the same differences in file.rs before and after this commit; none are from these lines.

Evidence

Module-only aurora.ko: fleet88 (d420ae2b) + this commit's diff, built in a copy of the tree fleet88 was built in. Its Rust undefined symbols match the stock fleet88 aurora.ko (181/181), vermagic 7.3.0-aurora-fleet88. It was loaded on a one-shot boot that blacklists the stock module, and each Mac rebooted to its saved fleet88 afterwards. The rows were run with the code of this commit; amending the message to fix a checkpatch commit reference didn't change the code.

Mac kernel selftest Borealis ext at 8 MiB (with the Mesa PR) 96 MiB import Geekbench 6 Vulkan at 8 MiB
Neo fleet88 4/5 (bit absent) not offered plain path completes https://browser.geekbench.com/v6/compute/6989728
Neo fleet88 + this 5/5 offered ok completes https://browser.geekbench.com/v6/compute/6989731
J616s fleet88 4/5 (bit absent) not offered plain path completes https://browser.geekbench.com/v6/compute/6989741
J616s fleet88 + this 5/5 offered ok completes https://browser.geekbench.com/v6/compute/6989744

…LOCK

Since commit 8a92c87 ("drm/asahi: bound GEM_USERPTR pins by the GPU
memory limits, not RLIMIT_MEMLOCK") GEM_USERPTR takes a range of any size
the GPU memory limits admit. Earlier kernels with GEM_USERPTR charge the
pins to the caller's RLIMIT_MEMLOCK and refuse a larger range with ENOMEM;
the systemd default is 8 MiB. Userspace cannot tell the two apart before
it imports, so an API without a size bound of its own on imports
(VK_EXT_external_memory_host) either has to offer them on every kernel
and fail large imports on the older ones, or check the memlock limit on
every kernel and stop offering them where the limit no longer applies.

Report DRM_ASAHI_FEATURE_USERPTR_NO_MEMLOCK with DRM_ASAHI_FEATURE_USERPTR.
Bit 42 is taken by DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL, which is in
review. The userptr selftest checks the bit in memlock_does_not_bound.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 24, 2026 17:34
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at e21d48c6: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at e21d48c6
Conflicts ok none
PR text ok Risk: two-way · Macs whose GPU offers GEMUSERPTR (M4 Pro/Max, M5 family, A18 Pro). It only adds a bit; no behaviour changes.

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 24, 2026
@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Independent source and hardware evidence review at e21d48c624bdecd3207592a29efff1e328a181b2. Feature bit 43 is free at this base. The open compute-channel patch uses bit 42. The new bit is emitted through the same capability predicate as GEM_USERPTR and this change adds no new pin or allocation behavior.

I checked the module-build commit ad0edd9412ae against this head. Both have the same parent and source tree, 32d045fb8e73c8267e4a7c81fb26c4b255eae6ae. The exact change was loaded on fleet88 on Neo and J616s. Each reported the feature at the default 8 MiB limit, passed 5/5 USERPTR selftests, and imported 96 MiB with zero mismatches in 25,165,824 checked words. Both ordinary restores returned to saved fleet88 with an empty next entry, SELinux Enforcing, and zero failed units.

ROW e21d48c | MacBook Neo (J700) | PASS | Fleet88 with the candidate module, 5/5 USERPTR selftests and 96 MiB imported with 0 mismatches at stock 8 MiB memlock. Saved boot restored.

ROW e21d48c | J616s (M4 Pro regression) | PASS | Fleet88 with the candidate module, 5/5 USERPTR selftests and 96 MiB imported with 0 mismatches at stock 8 MiB memlock. Saved boot restored.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 24, 2026
@RyanTheTide
RyanTheTide merged commit 9e9749c into main Nov 24, 2026
5 of 6 checks passed
@RyanTheTide
RyanTheTide deleted the fix/asahi-userptr-no-memlock-bit branch November 24, 2026 18:07

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: post-merge review at e21d48c624bd (merged as 9e9749c4). I found no defect and there is nothing to revert or fix.

Blockers: none

Checked:

  • No uapi collision. On main, bits 40 (VDM_USC_INVALIDATE), 41 (COMPUTE_ONLY) and 43 (USERPTR_NO_MEMLOCK) are defined. Bit 42 is used only by the open #3035 (COMPUTE_MULTI_CHANNEL). No other open linux PR touching asahi_drm.h (3044, 3035, 2887) and no open mesa PR touching the header copy (585 adds bit 41, 390) defines bit 43. The mesa copy from aurora-silicon/mesa#963 uses the same value.
  • The bit tells the truth. On main, UserPages::pin() (gem.rs ~L500-560) adds the range to mm->pinned_vm and pins with FOLL_LONGTERM without any RLIMIT_MEMLOCK comparison. The GPU memory ledger is what bounds it. file.rs reports the bit under the same supports_user_memory() condition as DRM_ASAHI_FEATURE_USERPTR, so the bit is never reported without USERPTR.
  • Selftest: memlock_does_not_bound now also expects the bit. It is an EXPECT_*, so on an older kernel the test still runs the memlock body and reports both results.

Notes (not blocking):

  1. Backports: the bit is only true together with the UserPages::pin() change from #2961. Any lab or fleet branch that cherry-picks this commit must carry #2961 too. Otherwise Borealis offers unbounded host imports on a kernel that still charges memlock, and large imports fail with VK_ERROR_OUT_OF_DEVICE_MEMORY. A Depends-on/Fixes-style note in the fleet cut list would cover it.
  2. Pre-existing from #2961, not this PR: these pins still raise pinned_vm, which io_uring fixed buffers, RDMA and VFIO compare with RLIMIT_MEMLOCK. A process that imports, say, 96 MiB of host memory into the GPU at the default 8 MiB limit will then have its io_uring buffer registration refused. That is the documented trade-off in gem.rs. It may be worth one line in the uapi comment ("still shown in VmPin and counted by other pinners") so userspace isn't surprised; the mesa header text already says the pages show in VmPin.
  3. The PR merged without a non-author review. This pass is that review after the fact.
Evidence
  • git grep '<< *4[0-9])' 9e9749c4 -- include/uapi/drm/asahi_drm.h
  • gh pr diff for linux 3044/3035/2887 and mesa 585/390, grepped for bit 4x defines
  • git grep -n 'pinned_vm\|FOLL_LONGTERM\|MEMLOCK' 9e9749c4 -- drivers/gpu/drm/asahi: gem.rs L454-598; no rlimit check on the pin path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant