Thread (92 messages) 92 messages, 15 authors, 2020-11-10

Re: [PATCH RFC PKS/PMEM 33/58] fs/cramfs: Utilize new kmap_thread()

From: Dan Williams <hidden>
Date: 2020-10-13 19:41:55
Also in: amd-gfx, bpf, ceph-devel, dri-devel, intel-gfx, intel-wired-lan, io-uring, kexec, kvm, linux-bcache, linux-btrfs, linux-cifs, linux-doc, linux-efi, linux-ext4, linux-f2fs-devel, linux-fsdevel, linux-kselftest, linux-mm, linux-mmc, linux-nfs, linux-rdma, linux-scsi, linux-um, linuxppc-dev, lkml, netdev, nvdimm, target-devel, xen-devel

On Tue, Oct 13, 2020 at 12:37 PM Matthew Wilcox [off-list ref] wrote:
On Tue, Oct 13, 2020 at 11:44:29AM -0700, Dan Williams wrote:
quoted
On Fri, Oct 9, 2020 at 12:52 PM [off-list ref] wrote:
quoted
From: Ira Weiny <ira.weiny@intel.com>

The kmap() calls in this FS are localized to a single thread.  To avoid
the over head of global PKRS updates use the new kmap_thread() call.

Cc: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 fs/cramfs/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 912308600d39..003c014a42ed 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -247,8 +247,8 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
                struct page *page = pages[i];

                if (page) {
-                       memcpy(data, kmap(page), PAGE_SIZE);
-                       kunmap(page);
+                       memcpy(data, kmap_thread(page), PAGE_SIZE);
+                       kunmap_thread(page);
Why does this need a sleepable kmap? This looks like a textbook
kmap_atomic() use case.
There's a lot of code of this form.  Could we perhaps have:

static inline void copy_to_highpage(struct page *to, void *vfrom, unsigned int size)
{
        char *vto = kmap_atomic(to);

        memcpy(vto, vfrom, size);
        kunmap_atomic(vto);
}

in linux/highmem.h ?
Nice, yes, that could also replace the local ones in lib/iov_iter.c
(memcpy_{to,from}_page())
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help