Thread View: muc.lists.freebsd.bugs
4 messages
4 total messages
Started by bugzilla-noreply
Sat, 28 Nov 2026 16:04
[Bug 301237] vn_io_fault1() calls cloneuio() unconditionally, so single-buffer regular-file reads and writes heap-allocate a uio...
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 16:04
Date: Sat, 28 Nov 2026 16:04
91 lines
5908 bytes
5908 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301237
Bug ID: 301237
Summary: vn_io_fault1() calls cloneuio() unconditionally, so
single-buffer regular-file reads and writes
heap-allocate a uio on every call
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
On filesystems setting MNTK_NO_IOPF (UFS, ZFS, NFS client, msdosfs, and
nullfs), every regular-file read(2), pread(2), write(2), and pwrite(2)
enters vn_io_fault1() with uio->uio_iovcnt == 1. In sys/kern/vfs_vnops.c
(main 2534dcb233ad), vn_io_fault1() always heap-clones uio via
cloneuio() and frees it at exit:
uio_clone = cloneuio(uio);
...
error = vn_io_fault_doio(args, uio, td);
if (error != EFAULT)
goto out;
...
out:
freeuio(uio_clone);
cloneuio() calls malloc(sizeof(struct uio) + sizeof(struct iovec),
M_IOV, M_WAITOK) and freeuio() calls free(..., M_IOV) on every single-iov
transfer, including cached UFS VIRF_PGREAD reads that never fault or use
uio_clone.
On FreeBSD 16.0-CURRENT amd64 GENERIC-NODEBUG (main 2534dcb233ad, Xeon
6975P-C), timing 300000 cached 64-byte UFS pread(2) calls pinned to one
CPU (ns/op, 10 runs):
cc -O2 -Wall -Wextra -Werror -pthread -o vn_io_fault_bench vn_io_fault_bench.c
for i in $(jot 10); do cpuset -l 2 ./vn_io_fault_bench pread64 1 300000
/var/tmp; done
x base_p64.txt
+ patched_p64.txt
+--------------------------------------------------------------------------+
| + x |
| ++ x |
| ++ xx |
| ++++ + xxx|
||___M_A_____| A| |
+--------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 10 175.21 175.59 175.29 175.312 0.11242775
+ 10 163.64 166.9 163.81 164.126 0.98608316
Difference at 95.0% confidence
-11.186 +/- 0.659393
-6.38062% +/- 0.375827%
(Student's t, pooled s = 0.701783)
Cached 4096-byte UFS pread(2) latency (pread4k 1 300000, N=10) drops
from 198.71 to 189.63 ns/op (-4.57% +/- 0.74% at 95% confidence), and
DTrace fbt::cloneuio:entry and fbt::freeuio:entry counts across 7000
pread(2) calls drop from 7001 to 0. On the iovcnt == 2 preadv(2) control
(where cloneuio() still runs), baseline and patched show no difference
at 95% confidence (227.51 vs 228.44 ns/op). Under debug GENERIC
(INVARIANTS and WITNESS), vn_io_fault_bench verify passes on both UFS
and ZFS (demand-paged > io_hold_cnt reads, partial-fault reads and UFS
IO_UNIT writes, misaligned page-straddling faults, PROT_NONE faults, and
self-mapped file writes), along with the 3 GiB big_unmapped_read test
and Kyua sys/aio and sys/vfs suites.
Storing single-iov clones in a stack struct uio and struct iovec[1] when
uio->uio_iovcnt == 1 (matching zfs_uiocopy() in spl_uio.c) and calling
freeuio() only for heap clones avoids per-call M_IOV allocations.
Source inspection shows the same unconditional cloneuio() call on
stable/15 and stable/14; I have only runtime-tested UFS and ZFS on
16.0-CURRENT amd64 (not NFS client, msdosfs, or nullfs mounts).
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301237] vn_io_fault1() calls cloneuio() unconditionally, so single-buffer regular-file reads and writes heap-allocate a uio...
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 16:04
Date: Sat, 28 Nov 2026 16:04
16 lines
2554 bytes
2554 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301237 --- Comment #1 from laamalif@proton.me --- Created attachment 277904 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277904&action=edit use a stack uio and iovec[1] in vn_io_fault1() when uio_iovcnt == 1 -- You are receiving this mail because: You are the assignee for the bug. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301237] vn_io_fault1() calls cloneuio() unconditionally, so single-buffer regular-file reads and writes heap-allocate a uio...
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 16:04
Date: Sat, 28 Nov 2026 16:04
17 lines
2568 bytes
2568 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301237 --- Comment #2 from laamalif@proton.me --- Created attachment 277905 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277905&action=edit benchmark: cached UFS pread/pwrite/preadv microbenchmark and UFS/ZFS EFAULT verifier -- You are receiving this mail because: You are the assignee for the bug. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301237] vn_io_fault1() calls cloneuio() unconditionally, so single-buffer regular-file reads and writes heap-allocate a uio...
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 16:40
Date: Sat, 28 Nov 2026 16:40
37 lines
3970 bytes
3970 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301237 --- Comment #3 from laamalif@proton.me --- Re-tested on FreeBSD 16.0-CURRENT amd64 at origin/main (44de1df2a033), preserving the INT_MAX-bounded uiomove() loop introduced by b487aca48535. Under GENERIC-NODEBUG pinned to CPU 2 across 10 runs, cached 64-byte UFS pread(2) drops from 176.03 to 164.00 ns/op (-6.83% +/- 1.07% at 95% confidence), cached 4096-byte UFS pread(2) drops from 197.74 to 186.25 ns/op (-5.81% +/- 0.43% at 95% confidence), and the two-iovec preadv(2) control shows no difference proven at 95% confidence (225.18 vs. 226.27 ns/op). Under GENERIC with INVARIANTS and WITNESS enabled at 44de1df2a033, UFS and ZFS fault-path verification, the 3 GiB big_unmapped_read regression test, and the Kyua sys/aio and sys/vfs suites pass. In vn_io_fault1(), vn_io_fault_doio() receives only the original caller uio or the local short_uio; neither uio_clone nor small_iov is passed to filesystem callbacks. Both small_clone and small_iov[1] have function scope and remain valid through all exit paths, including the goto out cleanup path. The only operation consuming uio_clone is synchronous uiomove(NULL, len, uio_clone) under UIO_NOCOPY, while fault-retry page state is maintained separately in td->td_ma. Assigning small_clone = *uio, copying the single iovec, and redirecting small_clone.uio_iov reproduces cloneuio() copy semantics without modifying the original uio, and all UIO_USERSPACE callers provide a valid kernel-space uio_iov pointer when uio_iovcnt == 1 (as existing cloneuio() and vn_io_fault_prefault_user() already require). Multi-iovec requests retain the heap-backed cloneuio() path. -- You are receiving this mail because: You are the assignee for the bug. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads