Re: Re: Re: [PATCH] fuse: when copying a folio delay the mark dirty until the end

From: Joanne Koong

Date: Wed Mar 18 2026 - 17:19:33 EST


On Wed, Mar 18, 2026 at 7:03 AM Horst Birthelmer <horst@xxxxxxxxxxxxx> wrote:
>
> Hi Joanne,
>
> I wonder, would something like this help for large folios?

Hi Horst,

I don't think it's likely that the pages backing the userspace buffer
are large folios, so I think this may actually add extra overhead with
the extra folio_test_dirty() check.

>From what I've seen, the main cost that dwarfs everything else for
writes/reads is the actual IO, the context switches, and the memcpys.
I think compared to these things, the set_page_dirty_lock() cost is
negligible and pretty much undetectable.

Thanks,
Joanne

>
> @@ -856,8 +856,11 @@ void fuse_copy_finish(struct fuse_copy_state *cs)
> cs->currbuf = NULL;
> } else if (cs->pg) {
> if (cs->write) {
> + struct folio *folio = page_folio(cs->pg);
> +
> flush_dcache_page(cs->pg);
> - set_page_dirty_lock(cs->pg);
> + if (!folio_test_dirty(folio))
> + set_page_dirty_lock(cs->pg);
> }
> put_page(cs->pg);
> }
>
> Do you have seen any problems with spin locks being way too costly while
> doing writes?
>
> That was actually why I started looking into this.
>
> Thanks,
> Horst