public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org,
	bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com,
	willy@infradead.org, shakeel.butt@linux.dev,
	kernel-team@meta.com
Subject: Re: [PATCH 01/12] fuse: support copying large folios
Date: Thu, 21 Nov 2024 17:27:58 -0500	[thread overview]
Message-ID: <20241121222758.GB1974911@perftesting> (raw)
In-Reply-To: <20241109001258.2216604-2-joannelkoong@gmail.com>

On Fri, Nov 08, 2024 at 04:12:47PM -0800, Joanne Koong wrote:
> Currently, all folios associated with fuse are one page size. As part of
> the work to enable large folios, this commit adds support for copying
> to/from folios larger than one page size.
> 
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
>  fs/fuse/dev.c | 89 +++++++++++++++++++++++----------------------------
>  1 file changed, 40 insertions(+), 49 deletions(-)
> 
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 29fc61a072ba..9914cc1243f4 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -703,7 +703,7 @@ struct fuse_copy_state {
>  	struct page *pg;
>  	unsigned len;
>  	unsigned offset;
> -	unsigned move_pages:1;
> +	unsigned move_folios:1;
>  };
>  
>  static void fuse_copy_init(struct fuse_copy_state *cs, int write,
> @@ -836,10 +836,10 @@ static int fuse_check_folio(struct folio *folio)
>  	return 0;
>  }
>  
> -static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
> +static int fuse_try_move_folio(struct fuse_copy_state *cs, struct folio **foliop)
>  {
>  	int err;
> -	struct folio *oldfolio = page_folio(*pagep);
> +	struct folio *oldfolio = *foliop;
>  	struct folio *newfolio;
>  	struct pipe_buffer *buf = cs->pipebufs;
>  
> @@ -860,7 +860,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
>  	cs->pipebufs++;
>  	cs->nr_segs--;
>  
> -	if (cs->len != PAGE_SIZE)
> +	if (cs->len != folio_size(oldfolio))
>  		goto out_fallback;
>  
>  	if (!pipe_buf_try_steal(cs->pipe, buf))
> @@ -906,7 +906,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
>  	if (test_bit(FR_ABORTED, &cs->req->flags))
>  		err = -ENOENT;
>  	else
> -		*pagep = &newfolio->page;
> +		*foliop = newfolio;
>  	spin_unlock(&cs->req->waitq.lock);
>  
>  	if (err) {
> @@ -939,8 +939,8 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
>  	goto out_put_old;
>  }
>  
> -static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
> -			 unsigned offset, unsigned count)
> +static int fuse_ref_folio(struct fuse_copy_state *cs, struct folio *folio,
> +			  unsigned offset, unsigned count)
>  {
>  	struct pipe_buffer *buf;
>  	int err;
> @@ -948,17 +948,17 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
>  	if (cs->nr_segs >= cs->pipe->max_usage)
>  		return -EIO;
>  
> -	get_page(page);
> +	folio_get(folio);
>  	err = unlock_request(cs->req);
>  	if (err) {
> -		put_page(page);
> +		folio_put(folio);
>  		return err;
>  	}
>  
>  	fuse_copy_finish(cs);
>  
>  	buf = cs->pipebufs;
> -	buf->page = page;
> +	buf->page = &folio->page;
>  	buf->offset = offset;
>  	buf->len = count;
>  
> @@ -970,20 +970,24 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
>  }
>  
>  /*
> - * Copy a page in the request to/from the userspace buffer.  Must be
> + * Copy a folio in the request to/from the userspace buffer.  Must be
>   * done atomically
>   */
> -static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep,
> -			  unsigned offset, unsigned count, int zeroing)
> +static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop,
> +			   unsigned offset, unsigned count, int zeroing)
>  {
>  	int err;
> -	struct page *page = *pagep;
> +	struct folio *folio = *foliop;
> +	size_t size = folio_size(folio);
>  
> -	if (page && zeroing && count < PAGE_SIZE)
> -		clear_highpage(page);
> +	if (folio && zeroing && count < size) {
> +		void *kaddr = kmap_local_folio(folio, 0);
> +		memset(kaddr, 0, size);
> +		kunmap_local(kaddr);

There's a folio_zero_range() that can be used here instead of this, but be sure
you get it right, I definitely did it wrong recently and I think Jan had to fix
my mistake.  Thanks,

Josef

  reply	other threads:[~2024-11-21 22:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-09  0:12 [PATCH 00/12] fuse: support large folios Joanne Koong
2024-11-09  0:12 ` [PATCH 01/12] fuse: support copying " Joanne Koong
2024-11-21 22:27   ` Josef Bacik [this message]
2024-11-09  0:12 ` [PATCH 02/12] fuse: support large folios for retrieves Joanne Koong
2024-11-21 22:28   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 03/12] fuse: refactor fuse_fill_write_pages() Joanne Koong
2024-11-21 22:28   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 04/12] fuse: support large folios for non-writeback writes Joanne Koong
2024-11-12 17:32   ` Joanne Koong
2024-11-13 18:41     ` Joanne Koong
2024-11-21 22:32   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 05/12] fuse: support large folios for folio reads Joanne Koong
2024-11-22 14:42   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 06/12] fuse: support large folios for symlinks Joanne Koong
2024-11-22 14:43   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 07/12] fuse: support large folios for stores Joanne Koong
2024-11-22 14:45   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 08/12] fuse: support large folios for queued writes Joanne Koong
2024-11-22 14:45   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 09/12] fuse: support large folios for readahead Joanne Koong
2024-11-22 14:47   ` Josef Bacik
2024-11-25 19:23     ` Joanne Koong
2024-11-09  0:12 ` [PATCH 10/12] fuse: support large folios for direct io Joanne Koong
2024-11-22 14:49   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 11/12] fuse: support large folios for writeback Joanne Koong
2024-11-22 14:50   ` Josef Bacik
2024-11-09  0:12 ` [PATCH 12/12] fuse: enable large folios Joanne Koong
2024-11-22 14:51   ` Josef Bacik
2024-11-09  0:22 ` [PATCH 00/12] fuse: support " Joanne Koong
2024-11-09  0:32   ` Bernd Schubert
2024-11-11 17:44     ` Joanne Koong
2024-11-13 18:58   ` Joanne Koong

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=20241121222758.GB1974911@perftesting \
    --to=josef@toxicpanda.com \
    --cc=bernd.schubert@fastmail.fm \
    --cc=jefflexu@linux.alibaba.com \
    --cc=joannelkoong@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=shakeel.butt@linux.dev \
    --cc=willy@infradead.org \
    /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