[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6a566e51-6288-f782-2fa5-f9b0349b6d7c@redhat.com>
Date: Tue, 27 Jun 2023 16:34:51 +0200
From: Hans de Goede <hdegoede@...hat.com>
To: Sumitra Sharma <sumitraartsy@...il.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Ira Weiny <ira.weiny@...el.com>, Fabio <fmdefrancesco@...il.com>,
Deepak R Varma <drv@...lo.com>
Subject: Re: [PATCH] fs/vboxsf: Replace kmap() with kmap_local_{page, folio}()
Hi,
On 6/27/23 15:51, Sumitra Sharma wrote:
> kmap() has been deprecated in favor of the kmap_local_page() due to high
> cost, restricted mapping space, the overhead of a global lock for
> synchronization, and making the process sleep in the absence of free
> slots.
>
> kmap_local_{page, folio}() is faster than kmap() and offers thread-local
> and CPU-local mappings, can take pagefaults in a local kmap region and
> preserves preemption by saving the mappings of outgoing tasks and
> restoring those of the incoming one during a context switch.
>
> The difference between kmap_local_page() and kmap_local_folio() consist
> only in the first taking a pointer to a page and the second taking two
> arguments, a pointer to a folio and the byte offset within the folio which
> identifies the page.
>
> The mappings are kept thread local in the functions 'vboxsf_read_folio',
> 'vboxsf_writepage', 'vboxsf_write_end' in file.c
>
> Suggested-by: Ira Weiny <ira.weiny@...el.com>
> Signed-off-by: Sumitra Sharma <sumitraartsy@...il.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@...hat.com>
Regards,
Hans
> ---
> fs/vboxsf/file.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c
> index 572aa1c43b37..5190619bc3c5 100644
> --- a/fs/vboxsf/file.c
> +++ b/fs/vboxsf/file.c
> @@ -234,7 +234,7 @@ static int vboxsf_read_folio(struct file *file, struct folio *folio)
> u8 *buf;
> int err;
>
> - buf = kmap(page);
> + buf = kmap_local_folio(folio, off);
>
> err = vboxsf_read(sf_handle->root, sf_handle->handle, off, &nread, buf);
> if (err == 0) {
> @@ -245,7 +245,7 @@ static int vboxsf_read_folio(struct file *file, struct folio *folio)
> SetPageError(page);
> }
>
> - kunmap(page);
> + kunmap_local(buf);
> unlock_page(page);
> return err;
> }
> @@ -286,10 +286,10 @@ static int vboxsf_writepage(struct page *page, struct writeback_control *wbc)
> if (!sf_handle)
> return -EBADF;
>
> - buf = kmap(page);
> + buf = kmap_local_page(page);
> err = vboxsf_write(sf_handle->root, sf_handle->handle,
> off, &nwrite, buf);
> - kunmap(page);
> + kunmap_local(buf);
>
> kref_put(&sf_handle->refcount, vboxsf_handle_release);
>
> @@ -320,10 +320,10 @@ static int vboxsf_write_end(struct file *file, struct address_space *mapping,
> if (!PageUptodate(page) && copied < len)
> zero_user(page, from + copied, len - copied);
>
> - buf = kmap(page);
> + buf = kmap_local_page(page);
> err = vboxsf_write(sf_handle->root, sf_handle->handle,
> pos, &nwritten, buf + from);
> - kunmap(page);
> + kunmap_local(buf);
>
> if (err) {
> nwritten = 0;
Powered by blists - more mailing lists