public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joanne Koong <joannelkoong@gmail.com>
To: Horst Birthelmer <horst@birthelmer.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Bernd Schubert <bernd@bsbernd.com>,
	linux-fsdevel@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Horst Birthelmer <hbirthelmer@ddn.com>
Subject: Re: [PATCH] fuse: when copying a folio delay the mark dirty until the end
Date: Mon, 16 Mar 2026 10:29:52 -0700	[thread overview]
Message-ID: <CAJnrk1Yyp+3YDYNTzyTUQLUDsiQ9WB181-mu1FOpGyaVTu=_1Q@mail.gmail.com> (raw)
In-Reply-To: <20260316-mark-dirty-per-folio-v1-1-8dc39c94b7ce@ddn.com>

On Mon, Mar 16, 2026 at 8:16 AM Horst Birthelmer <horst@birthelmer.com> wrote:
>
> From: Horst Birthelmer <hbirthelmer@ddn.com>
>
> Doing set_page_dirty_lock() for every page is inefficient
> for large folios.
> When copying a folio (and with large folios enabled,
> this can be many pages) we can delay the marking dirty
> and flush_dcache_page() until the whole folio is handled
> and do it once per folio instead of once per page.
>
> Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
> ---
> Currently when doing a folio copy
> flush_dcache_page(cs->pg) and set_page_dirty_lock(cs->pg)
> are called for every page.
>
> We can do this at the end for the whole folio.

Hi Horst,

I think these are two different entities. cs->pg is the page that
corresponds to the userspace buffer / pipe while the (large) folio
corresponds to the pages in the page cache. flush_dcache_folio(folio)
and flush_dcache_page(cs->pg) are not interchangeable (I don't think
it's likely either that the pages backing the userspace buffer/pipe
are large folios).

Thanks,
Joanne

> ---
>  fs/fuse/dev.c        | 9 +++++++--
>  fs/fuse/fuse_dev_i.h | 1 +
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 0b0241f47170d4640f0b8f3cae8be1f78944a456..ae96a48f898e883b4e96147f3b27398261c5e844 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -855,7 +855,7 @@ void fuse_copy_finish(struct fuse_copy_state *cs)
>                         buf->len = PAGE_SIZE - cs->len;
>                 cs->currbuf = NULL;
>         } else if (cs->pg) {
> -               if (cs->write) {
> +               if (cs->write && !cs->copy_folio) {
>                         flush_dcache_page(cs->pg);
>                         set_page_dirty_lock(cs->pg);
>                 }
> @@ -1126,6 +1126,7 @@ static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop,
>                         folio_zero_range(folio, 0, size);
>         }
>
> +       cs->copy_folio = true;
>         while (count) {
>                 if (cs->write && cs->pipebufs && folio) {
>                         /*
> @@ -1167,8 +1168,12 @@ static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop,
>                 } else
>                         offset += fuse_copy_do(cs, NULL, &count);
>         }
> -       if (folio && !cs->write)
> +       if (folio) {
>                 flush_dcache_folio(folio);
> +               if (cs->write)
> +                       folio_mark_dirty_lock(folio);
> +       }
> +       cs->copy_folio = false;
>         return 0;
>  }
>
> diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
> index 134bf44aff0d39ae8d5d47cf1518efcf2f1cfc23..4a433d902266d573ad1c19adbdd573440e2a77b2 100644
> --- a/fs/fuse/fuse_dev_i.h
> +++ b/fs/fuse/fuse_dev_i.h
> @@ -33,6 +33,7 @@ struct fuse_copy_state {
>         unsigned int offset;
>         bool write:1;
>         bool move_folios:1;
> +       bool copy_folio:1;
>         bool is_uring:1;
>         struct {
>                 unsigned int copied_sz; /* copied size into the user buffer */
>
> ---
> base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c
> change-id: 20260316-mark-dirty-per-folio-be87b6b4bf56
>
> Best regards,
> --
> Horst Birthelmer <hbirthelmer@ddn.com>
>

  reply	other threads:[~2026-03-16 17:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 15:16 [PATCH] fuse: when copying a folio delay the mark dirty until the end Horst Birthelmer
2026-03-16 17:29 ` Joanne Koong [this message]
2026-03-16 20:02   ` Horst Birthelmer
2026-03-16 22:06     ` Joanne Koong
2026-03-18 14:03       ` Horst Birthelmer
2026-03-18 21:19         ` Joanne Koong
2026-03-18 21:52           ` Bernd Schubert
2026-03-19  1:32             ` Joanne Koong
2026-03-19  4:27               ` Darrick J. Wong
2026-03-20 17:24                 ` Joanne Koong
2026-03-19  8:32               ` Horst Birthelmer
2026-03-20 17:18                 ` Joanne Koong
2026-03-26  6:35 ` kernel test robot
2026-03-26 15:05   ` [LTP] " Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJnrk1Yyp+3YDYNTzyTUQLUDsiQ9WB181-mu1FOpGyaVTu=_1Q@mail.gmail.com' \
    --to=joannelkoong@gmail.com \
    --cc=bernd@bsbernd.com \
    --cc=hbirthelmer@ddn.com \
    --cc=horst@birthelmer.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox