Skip to content

[26.04-linux-nvidia-bos] Backport: fuse: back uncached readdir buffers with pages#461

Closed
nvmochs wants to merge 1 commit into
NVIDIA:26.04_linux-nvidia-bosfrom
nvmochs:nvb6059208_fuse_readdir_70bos
Closed

[26.04-linux-nvidia-bos] Backport: fuse: back uncached readdir buffers with pages#461
nvmochs wants to merge 1 commit into
NVIDIA:26.04_linux-nvidia-bosfrom
nvmochs:nvb6059208_fuse_readdir_70bos

Conversation

@nvmochs

@nvmochs nvmochs commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

This updates FUSE uncached readdir to back the temporary output buffer with pages and set out_pages, instead of passing the buffer as a kvec output argument.

For virtiofs, kvec output arguments are copied through req->argbuf, which is allocated with kmalloc(..., GFP_ATOMIC). Large uncached readdir requests can therefore require a multi-megabyte contiguous atomic allocation before the request is queued. Using output pages lets transports such as virtiofs pass the buffer as scatter-gather entries instead.

The existing uncached readdir buffer sizing is unchanged. Pages are mapped with vm_map_ram() only while parsing returned dirents.

LKML:
[PATCH v4] fuse: back uncached readdir buffers with pages - https://lore.kernel.org/all/20260526152021.891412-1-mochs@nvidia.com/

linux-next:
2fcb1dd15fab fuse: back uncached readdir buffers with pages

Testing

Validated the original failing configuration:

4K host page size + 64K guest page size
virtme-ng with --overlay-rwdir /tmp

Command:

git log --oneline -1
getconf PAGE_SIZE
vng --run arch/arm64/boot/Image --memory 16G --cpus 4 --overlay-rwdir /tmp --exec 'uname -r; getconf PAGE_SIZE; ls /tmp; echo "ls rc=$?"; python3 -c "import os; print(len(os.listdir(\"/tmp\")))"'

Result:

nvidia@gb200-nvl4-47:~/mochs/nvbugs_6059208/NV-Kernels$ git log --oneline -1;getconf PAGE_SIZE;vng --run arch/arm64/boot/Image     --memory 16G --cpus 4 --overlay-rwdir /tmp     --exec 'uname -r; getconf PAGE_SIZE; ls /tmp; echo "ls rc=$?"; python3 -c "import os; print(len(os.listdir(\"/tmp\")))"'
ed45d16373e4 (HEAD -> nvb6059208_fuse_readdir_70bos, origin/nvb6059208_fuse_readdir_70bos) fuse: back uncached readdir buffers with pages
4096
7.0.0+
65536
hca_self_test_modprobe.output
mstflint_lockfiles
snap-private-tmp
systemd-private-0e36d3a03cea44e3bb3be4dcbee6cc15-ModemManager.service-1EqTRU
systemd-private-0e36d3a03cea44e3bb3be4dcbee6cc15-fwupd.service-1M1G3S
systemd-private-0e36d3a03cea44e3bb3be4dcbee6cc15-polkit.service-zWSn0u
systemd-private-0e36d3a03cea44e3bb3be4dcbee6cc15-systemd-logind.service-Nr99bX
systemd-private-0e36d3a03cea44e3bb3be4dcbee6cc15-systemd-resolved.service-vuJ3EG
systemd-private-0e36d3a03cea44e3bb3be4dcbee6cc15-systemd-timesyncd.service-7ttgTq
virtiofsd-wrapper.log
virtme_retimh08q0x
virtmejqwurv07
virtmejqwurv07.pid
ls rc=0
18

This is the configuration that previously failed with Cannot allocate memory.


LP: https://bugs.launchpad.net/ubuntu/+source/linux-nvidia/+bug/2156632

NVbug: 6059208

Commit dabb903 ("fuse: increase readdir buffer size") changed
fuse_readdir_uncached() to size its temporary buffer from ctx->count.
This is useful for overlayfs and other in-kernel callers that use
INT_MAX to indicate an unlimited directory read.

The larger buffer is currently supplied as a kvec output argument. For
virtiofs, kvec arguments are copied through req->argbuf, which is
allocated with kmalloc(..., GFP_ATOMIC). A large uncached readdir buffer
can therefore require a multi-megabyte contiguous atomic allocation
before the request is queued.

Avoid the large bounce-buffer allocation by backing uncached readdir
output with pages and setting out_pages. Transports such as virtiofs can
then pass the pages as scatter-gather entries instead of copying the
output through argbuf.

Map the pages with vm_map_ram() only while parsing the returned dirents.
The existing parser can then continue to use a linear kernel mapping.

[SzM: separate allocation of pages into a helper function]

Fixes: dabb903 ("fuse: increase readdir buffer size")
Cc: stable@vger.kernel.org
Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
(cherry picked from commit 2fcb1dd15faba5657b825cc5d54423251c70e79a linux-next)
Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
@nirmoy nirmoy added the help wanted Extra attention is needed label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Validation Report

Patchscan ✅ No Missing Fixes

All cherry-picked commits checked — no missing upstream fixes found.

PR Lint ❌ Errors found

Details
Checking 1 commits...

Cherry-pick digest:
┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐
│ Local        │ Referenced upstream / Patch subject                              │ Patch-ID   │ Subject │ SoB chain                 │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ed45d16373e4 │ [SAUCE] fuse: back uncached readdir buffers with pages           │ N/A        │ N/A     │ mochs, mszeredi, mochs    │
└──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘

Lint results:
E: ed45d16373e4 ("fuse: back uncached readdir buffers with pages"): not SAUCE/UBUNTU/Revert but has no upstream reference trailer (cherry picked from commit ... or backported from ...)

@nirmoy

nirmoy commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

BaseOS Kernel Review

Summary

Only a minor commit-message hygiene issue was found: commit ed45d16 has a duplicated Signed-off-by line for Matthew R. Ochs that should be deduplicated. No runtime or correctness problems were identified.

Findings: Critical: 0, High: 0, Medium: 0, Low: 1

Latest watcher review: open review

Kernel deb build: successful (download debs, 4 files)

Head: ed45d16373e4

This comment is maintained by nv-pr-bot. It is updated when the GitHub watcher publishes a newer review.

@clsotog clsotog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Acked-by: Carol L Soto <csoto@nvidia.com>

@jamieNguyenNVIDIA

Copy link
Copy Markdown
Collaborator

Acked-by: Jamie Nguyen <jamien@nvidia.com>

@nirmoy nirmoy added has_2_acks and removed help wanted Extra attention is needed has_1_ack labels Jun 12, 2026
@nvmochs

nvmochs commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

Merged, closing PR.

64f3653d74d6 (nresolute/nvidia-bos-next) fuse: back uncached readdir buffers with pages

@nvmochs nvmochs closed this Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants