linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: NeilBrown <neilb@suse.de>
Cc: Christoph Hellwig <hch@infradead.org>,
	David Howells <dhowells@redhat.com>, <linux-nfs@vger.kernel.org>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 09/10] MM: submit multipage write for SWP_FS_OPS swap-space
Date: Mon, 18 Apr 2022 14:59:34 +0800	[thread overview]
Message-ID: <033ccf1a-c6b5-fd77-0ad0-4915ff07bc15@huawei.com> (raw)
In-Reply-To: <164859778128.29473.5191868522654408537.stgit@noble.brown>

On 2022/3/30 7:49, NeilBrown wrote:
> swap_writepage() is given one page at a time, but may be called repeatedly
> in succession.
> For block-device swapspace, the blk_plug functionality allows the
> multiple pages to be combined together at lower layers.
> That cannot be used for SWP_FS_OPS as blk_plug may not exist - it is
> only active when CONFIG_BLOCK=y.  Consequently all swap reads over NFS
> are single page reads.
> 
> With this patch we pass a pointer-to-pointer via the wbc.
> swap_writepage can store state between calls - much like the pointer
> passed explicitly to swap_readpage.  After calling swap_writepage() some
> number of times, the state will be passed to swap_write_unplug() which
> can submit the combined request.
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: NeilBrown <neilb@suse.de>
...
>  
>  static int swap_writepage_fs(struct page *page, struct writeback_control *wbc)
>  {
> -	struct swap_iocb *sio;
> +	struct swap_iocb *sio = NULL;
>  	struct swap_info_struct *sis = page_swap_info(page);
>  	struct file *swap_file = sis->swap_file;
> -	struct address_space *mapping = swap_file->f_mapping;
> -	struct iov_iter from;
> -	int ret;
> +	loff_t pos = page_file_offset(page);
>  
>  	set_page_writeback(page);
>  	unlock_page(page);
> -	sio = mempool_alloc(sio_pool, GFP_NOIO);
> -	init_sync_kiocb(&sio->iocb, swap_file);
> -	sio->iocb.ki_complete = sio_write_complete;
> -	sio->iocb.ki_pos = page_file_offset(page);
> -	sio->bvec[0].bv_page = page;
> -	sio->bvec[0].bv_len = PAGE_SIZE;
> -	sio->bvec[0].bv_offset = 0;
> -	iov_iter_bvec(&from, WRITE, &sio->bvec[0], 1, PAGE_SIZE);
> -	ret = mapping->a_ops->swap_rw(&sio->iocb, &from);
> -	if (ret != -EIOCBQUEUED)
> -		sio_write_complete(&sio->iocb, ret);
> -	return ret;
> +	if (wbc->swap_plug)
> +		sio = *wbc->swap_plug;
> +	if (sio) {
> +		if (sio->iocb.ki_filp != swap_file ||
> +		    sio->iocb.ki_pos + sio->pages * PAGE_SIZE != pos) {
> +			swap_write_unplug(sio);
> +			sio = NULL;
> +		}
> +	}
> +	if (!sio) {
> +		sio = mempool_alloc(sio_pool, GFP_NOIO);
> +		init_sync_kiocb(&sio->iocb, swap_file);
> +		sio->iocb.ki_complete = sio_write_complete;
> +		sio->iocb.ki_pos = pos;
> +		sio->pages = 0;
> +	}
> +	sio->bvec[sio->pages].bv_page = page;
> +	sio->bvec[sio->pages].bv_len = PAGE_SIZE;

Many thanks for your patch. And sorry for late responding and newbie question. Does swap_writepage_fs
support transhuge page now? We could come across transhuge page here. But bv_len == PAGE_SIZE and pages
== 1 is assumed here. Do we need something like below:

sio->bvec[sio->pages].bv_len = thp_size(page);
sio->pages += thp_nr_pages(page);

Thanks! :)

> +	sio->bvec[sio->pages].bv_offset = 0;
...
> .
> 



  reply	other threads:[~2022-04-18  6:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 23:49 [PATCH 00/10] MM changes to improve swap-over-NFS support NeilBrown
2022-03-29 23:49 ` [PATCH 08/10] MM: submit multipage reads for SWP_FS_OPS swap-space NeilBrown
2022-03-29 23:49 ` [PATCH 06/10] MM: perform async writes to SWP_FS_OPS swap-space using ->swap_rw NeilBrown
2022-03-29 23:49 ` [PATCH 05/10] MM: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space NeilBrown
2022-03-29 23:49 ` [PATCH 07/10] DOC: update documentation for swap_activate and swap_rw NeilBrown
2022-03-29 23:49 ` [PATCH 02/10] MM: drop swap_dirty_folio NeilBrown
2022-03-29 23:49 ` [PATCH 01/10] MM: create new mm/swap.h header file NeilBrown
2022-03-29 23:49 ` [PATCH 03/10] MM: move responsibility for setting SWP_FS_OPS to ->swap_activate NeilBrown
2022-03-29 23:49 ` [PATCH 04/10] MM: reclaim mustn't enter FS for SWP_FS_OPS swap-space NeilBrown
2022-03-29 23:49 ` [PATCH 09/10] MM: submit multipage write " NeilBrown
2022-04-18  6:59   ` Miaohe Lin [this message]
2022-04-26  1:58     ` NeilBrown
2022-03-29 23:49 ` [PATCH 10/10] VFS: Add FMODE_CAN_ODIRECT file flag NeilBrown
2022-03-30 10:26 ` [PATCH 00/10] MM changes to improve swap-over-NFS support David Howells
2022-03-31  1:12   ` NeilBrown
2022-04-19 15:57     ` Geert Uytterhoeven
2022-04-26  2:04       ` NeilBrown
2022-03-31  8:13 ` David Howells
  -- strict thread matches above, loose matches on Subject: below --
2022-03-06 23:49 NeilBrown
2022-03-06 23:49 ` [PATCH 09/10] MM: submit multipage write for SWP_FS_OPS swap-space NeilBrown

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=033ccf1a-c6b5-fd77-0ad0-4915ff07bc15@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).