[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQQwy7l_OCzG430i@fedora>
Date: Fri, 31 Oct 2025 11:45:15 +0800
From: Ming Lei <ming.lei@...hat.com>
To: Caleb Sander Mateos <csander@...estorage.com>
Cc: Jens Axboe <axboe@...nel.dk>, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ublk: use copy_{to,from}_iter() for user copy
On Thu, Oct 30, 2025 at 07:05:21PM -0600, Caleb Sander Mateos wrote:
> ublk_copy_user_pages()/ublk_copy_io_pages() currently uses
> iov_iter_get_pages2() to extract the pages from the iov_iter and
> memcpy()s between the bvec_iter and the iov_iter's pages one at a time.
> Switch to using copy_to_iter()/copy_from_iter() instead. This avoids the
> user page reference count increments and decrements and needing to split
> the memcpy() at user page boundaries. It also simplifies the code
> considerably.
>
> Signed-off-by: Caleb Sander Mateos <csander@...estorage.com>
> ---
> drivers/block/ublk_drv.c | 62 +++++++++-------------------------------
> 1 file changed, 14 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 0c74a41a6753..852350e639d6 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -912,58 +912,47 @@ static const struct block_device_operations ub_fops = {
> .open = ublk_open,
> .free_disk = ublk_free_disk,
> .report_zones = ublk_report_zones,
> };
>
> -#define UBLK_MAX_PIN_PAGES 32
> -
> struct ublk_io_iter {
> - struct page *pages[UBLK_MAX_PIN_PAGES];
> struct bio *bio;
> struct bvec_iter iter;
> };
->pages[] is actually for pinning user io pages in batch, so killing it may cause
perf drop.
This similar trick is used in direct io code path too.
Thanks
Ming
Powered by blists - more mailing lists