Re: [PATCH RFC 0/3] fs/pipe: copy a run of pipe buffers in one user access section

From: Chris Down

Date: Tue Nov 17 2026 - 04:04:48 EST


Hi Breno,

Breno Leitao writes:
fs/pipe.c into lib/iov_iter.c. The main question is whether that helper
is welcome there, or, make the party a bit uglier.

Hmm, I think the part more likely to get pushback is patch 1, rather
than where the helper lives. :-) It adds an x86-only user copy primitive,
and then lib/iov_iter.c has to look for it with an #ifdef on its name,
which the patch (rightly) acknowledges as a bit of a Macgyver.

When Christophe proposed another user copy variant in April, Linus asked
for the existing unsafe_copy_*() helpers to be extended instead of
growing a new interface [1]. And in a related thread he called x86's
unsafe_copy_to_user() "almost entirely unoptimized" [2], which is the
same reason patch 1 gives for not using it.

Based on that discussion, I'd think that the better way would be to make
x86's unsafe_copy_to_user() use the rep movs body from patch 1 for
larger copies. Then copy_bvecs_to_iter_full() can be written with
scoped_user_write_access_size() and unsafe_copy_to_user() for every
architecture, without the #ifdef.

[1] https://lore.kernel.org/all/CAHk-=whC1DZojwdMB1=sJWG2=dsCdfyU8N6tDE1qx50HRZ-WJQ@xxxxxxxxxxxxxx/
[2] https://lore.kernel.org/all/CAHk-=wi1rrcijcD0i7V7JD6bLL-yKHUX-hcxtLx=BUd34phdug@xxxxxxxxxxxxxx/

Thanks!

Chris