lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <165093831774.1648.3187486020864614234@noble.neil.brown.name>
Date:   Tue, 26 Apr 2022 11:58:37 +1000
From:   "NeilBrown" <neilb@...e.de>
To:     "Miaohe Lin" <linmiaohe@...wei.com>
Cc:     "Christoph Hellwig" <hch@...radead.org>,
        "David Howells" <dhowells@...hat.com>, linux-nfs@...r.kernel.org,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        "Andrew Morton" <akpm@...ux-foundation.org>
Subject: Re: [PATCH 09/10] MM: submit multipage write for SWP_FS_OPS swap-space

On Mon, 18 Apr 2022, Miaohe Lin wrote:
> 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@....de>
> > Signed-off-by: NeilBrown <neilb@...e.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);

Yes, that probably makes sense.  I'll have a closer look and maybe
resend later this week.

Thanks,
NeilBrown


> 
> Thanks! :)
> 
> > +	sio->bvec[sio->pages].bv_offset = 0;
> ...
> > .
> > 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ