From: Sumitra Sharma <sumitraartsy@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ira Weiny <ira.weiny@intel.com>, Fabio <fmdefrancesco@gmail.com>,
Deepak R Varma <drv@mailo.com>,
Sumitra Sharma <sumitraartsy@gmail.com>
Subject: [PATCH] fs/vboxsf: Replace kmap() with kmap_local_{page, folio}()
Date: Tue, 27 Jun 2023 06:51:15 -0700 [thread overview]
Message-ID: <20230627135115.GA452832@sumitra.com> (raw)
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@intel.com>
Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>
---
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;
--
2.25.1
next reply other threads:[~2023-06-27 13:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 13:51 Sumitra Sharma [this message]
2023-06-27 14:34 ` [PATCH] fs/vboxsf: Replace kmap() with kmap_local_{page, folio}() Hans de Goede
2023-06-27 17:46 ` Matthew Wilcox
2023-06-27 18:10 ` Hans de Goede
2023-06-27 18:19 ` Hans de Goede
2023-06-27 17:48 ` Matthew Wilcox
2023-06-27 18:04 ` Hans de Goede
2023-06-29 4:30 ` Sumitra Sharma
2023-06-29 5:35 ` Hans de Goede
2023-06-28 17:15 ` Matthew Wilcox
2023-06-28 22:23 ` Fabio M. De Francesco
2023-06-28 22:40 ` Fabio M. De Francesco
2023-06-29 2:13 ` Ira Weiny
2023-06-29 3:16 ` Matthew Wilcox
2023-06-29 15:04 ` Fabio M. De Francesco
2023-06-29 2:23 ` Ira Weiny
2023-06-29 3:08 ` Matthew Wilcox
2023-06-29 9:28 ` Sumitra Sharma
2023-06-29 10:01 ` Hans de Goede
2023-06-29 14:42 ` Matthew Wilcox
2023-06-29 15:01 ` Hans de Goede
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=20230627135115.GA452832@sumitra.com \
--to=sumitraartsy@gmail.com \
--cc=drv@mailo.com \
--cc=fmdefrancesco@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ira.weiny@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.