Skip to content

drm/asahi: fail large G17 backing population without direct reclaim - #397

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
fix/asahi-large-bo-no-direct-reclaim
Oct 23, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
fix/asahi-large-bo-no-direct-reclaim

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

On G17 the first VM_BIND of a user object pins all of its backing. For a large object under memory pressure, direct reclaim and compaction run once per folio, and the bind can sit there for minutes. On the Neo a 3.25 GB Vulkan allocation never returned from VM_BIND within 237 s, with the task throttled in memcg high reclaim the whole time.

The first patch lets shmem drivers opt out of direct reclaim before the object is published. Placement and background reclaim are kept, and a pin that can't be satisfied fails with ENOMEM instead. drm/asahi uses it for G17 user objects of 256 MiB or more. Kernel objects and smaller resources keep their current policy, and userspace can drop cached BOs and retry. KUnit covers the GFP mask, a real pin, an oversized pin failing fast and the size boundary.

The second patch appends optional device-wide and per-client capacity fields to GET_PARAMS, so userspace can size its heap from the same limits GEM creation enforces. The existing prefix and bounded writes are unchanged for older userspace.

Results on the Neo

  • The two 1M-instance CPU acceleration structure CTS cases now end in 7 to 12 s with VK_ERROR_OUT_OF_DEVICE_MEMORY, instead of timing out after more than 330 s. They need far more BLAS storage than the machine has, so a fast clean failure is the right result.
  • VM_BIND fails with ENOMEM in 0.12 s, and a 3.25 GB probe allocation returns out of memory in 0.29 s, after which a small allocation still succeeds.
  • All 6 smaller control runs pass.

Build and tests on this head

  • defconfig + asahi.config + olddefconfig, Image, modules and dtbs, W=1 on the touched code
  • KUnit on arm64 with 16K pages, lockdep and panic_on_warn=1. asahi* 69/69, drm_gem_shmem* 10/10 (the oversized pin returned ENOMEM in 9.7 s under QEMU TCG), rust_drm_sched 3/3

🤖 Generated with Claude Code

The first VM bind pins an entire object. Repeating direct reclaim and
compaction for each folio of a large user buffer can leave allocation
blocked for minutes under memory pressure. Allow shmem drivers to opt
out of direct reclaim before publishing the object, preserving
placement and background reclaim.

Use the policy for G17 user objects of at least 256 MiB. Kernel objects
and smaller resources keep their existing allocation policy. Userspace
can release cached objects and retry on ENOMEM.

Test successful pinning, a real oversized pin failure and the policy
boundaries. KUnit cases run in kernel threads with no return to
userspace, so the oversized case flushes deferred fput when it frees
its object, releasing the page cache before the next case. It is marked
slow.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Append optional device-wide and per-client capacity fields so userspace
can expose a heap bounded by the same limits GEM creation enforces.
Preserve the existing prefix and bounded writes for older userspace.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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