Re: [PATCH] iomap: move prefaulting out of hot write path

From: Jinliang Zheng
Date: Thu Oct 09 2025 - 22:05:22 EST


> On 11/9/25 08:01, Darrick J. Wong wrote:
> > On Thu, Oct 09, 2025 at 05:08:51PM +0800, alexjlzheng@xxxxxxxxx wrote:
> >> From: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx>
> >>
> >> Prefaulting the write source buffer incurs an extra userspace access
> >> in the common fast path. Make iomap_write_iter() consistent with
> >> generic_perform_write(): only touch userspace an extra time when
> >> copy_folio_from_iter_atomic() has failed to make progress.
> >>
> >> This patch is inspired by commit 665575cff098 ("filemap: move
> >> prefaulting out of hot write path").
> > Seems fine to me, but I wonder if dhansen has any thoughts about this
> > patch ... which exactly mirrors one he sent eight months ago?
>
> I don't _really_ care all that much. But, yeah, I would have expected
> a little shout-out or something when someone copies the changelog and
> code verbatim from another patch:
>
> https://lore.kernel.org/lkml/20250129181753.3927F212@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
>
> and then copies a comment from a second patch I did.

Sorry for forgetting to CC you in my previous email.

When I sent V1[1], I hadn't come across this email (which was an oversight on my part):
- https://lore.kernel.org/lkml/20250129181753.3927F212@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/

At that time, I was quite puzzled about why generic_perform_write() had moved prefaulting
out of the hot write path, while iomap_write_iter() had not done the same.

It wasn't until I was preparing V2[2] that I found the email above. However, the code around
had already undergone some changes by then, so I rebased the code in this email onto the
upstream version. My apologies for forgetting to CC you earlier.

[1] https://lore.kernel.org/linux-xfs/20250726090955.647131-2-alexjlzheng@xxxxxxxxxxx/
[2] https://lore.kernel.org/linux-xfs/20250730164408.4187624-2-alexjlzheng@xxxxxxxxxxx/

Hope you know I didn't mean any offense. Sorry about that.

>
> But I guess I was cc'd at least. Also, if my name isn't on this one,
> then I don't have to fix any of the bugs it causes. Right? ;)
>
> Just one warning: be on the lookout for bugs in the area. The
> prefaulting definitely does a good job of hiding bugs in other bits
> of the code. The generic_perform_write() gunk seems to have uncovered
> a bug or two.

Indeed, the reason I sent this patch was precisely because I was unsure why the change
for iomap_write_iter() hadn't been merged like the one for generic_perform_write() — I
wondered if there might be some underlying issue. I hoped to seek everyone's thoughts
through this patch. :)

>
> Also, didn't Christoph ask you to make the comments wider the last
> time Alex posted this? I don't think that got changed.
>
> https://lore.kernel.org/lkml/aIt8BYa6Ti6SRh8C@xxxxxxxxxxxxx/
>
> Overall, the change still seems as valid to me as it did when I wrote the
> patch in the first place. Although it feels funny to ack my own
> patch.

If moving prefaulting out of the hot write path in iomap_write_iter() is indeed
acceptable, would you mind taking the time to rebase the code from your patch onto
the latest upstream version and submit a new patch? After all, you are the
original author of the change. :)

Thank you very much,
Jinliang. :)