Skip to contentSkip to conversation

f2fs: Use memcpy_page() in f2fs_copy_page()

PATCH In review Fabio M. De Francesco 2 participants 3 messages Jul 16, 2022 – Jul 17, 2022 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: Use memcpy_page() in f2fs_copy_page()

The use of kmap() is being deprecated in favor of kmap_local_page().

Two main problems with kmap(): (1) It comes with an overhead as mapping space is restricted and protected by a global lock for synchronization and
(2) it also requires global TLB invalidation when the kmap’s pool wraps and it might block when the mapping space is fully utilized until a slot becomes available.

Therefore, replace kmap() with kmap_local_page() in f2fs_copy_page() and use memcpy_page() instead of open coding kmap_local_page() + memcpy().

---
 fs/f2fs/f2fs.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/f2fs/f2fs.h +1 -5
index d9bbecd008d2..f04e760bb1c1 100644
@@ -2698,12 +2698,8 @@ static inline struct page *f2fs_pagecache_get_page(
 
 static inline void f2fs_copy_page(struct page *src, struct page *dst)
 {
-	char *src_kaddr = kmap(src);
-	char *dst_kaddr = kmap(dst);
 
-	memcpy(dst_kaddr, src_kaddr, PAGE_SIZE);
-	kunmap(dst);
-	kunmap(src);
+	memcpy_page(dst, 0, src, 0, PAGE_SIZE);
 }
 
 static inline void f2fs_put_page(struct page *page, int unlock)
Signature · 1 line
2.37.1
#1 lore raw

fs/f2fs/f2fs.h static inline struct page *f2fs_pagecache_get_page( · line 2702

Quoted 9 lines · Fabio M. De Francesco

static inline void f2fs_copy_page(struct page *src, struct page *dst) {

fs/f2fs/f2fs.h +1 -5
-	char *src_kaddr = kmap(src);
-	char *dst_kaddr = kmap(dst);
 
-	memcpy(dst_kaddr, src_kaddr, PAGE_SIZE);
-	kunmap(dst);
-	kunmap(src);
+	memcpy_page(dst, 0, src, 0, PAGE_SIZE);

Please remove f2fs_copy_page entirely and open code this in the only caller.

#2 lore raw
Quoted 6 lines · On domenica 17 luglio 2022 08:55:20 CEST Christoph Hellwig wrote:
Quoted 5 lines · Fabio M. De Francesco

static inline void f2fs_copy_page(struct page *src, struct page *dst) {

fs/f2fs/f2fs.h +0 -2
-	char *src_kaddr = kmap(src);
-	char *dst_kaddr = kmap(dst);
Quoted 8 lines

fs/f2fs/f2fs.h static inline struct page *f2fs_pagecache_get_page( · line 2702

Quoted 4 lines
fs/f2fs/f2fs.h +1 -3
-	memcpy(dst_kaddr, src_kaddr, PAGE_SIZE);
-	kunmap(dst);
-	kunmap(src);
+	memcpy_page(dst, 0, src, 0, PAGE_SIZE);

Please remove f2fs_copy_page entirely and open code this in the only caller.

I've changed the subject of the new patch, therefore we won't have a second version of this:

"f2fs: Delete f2fs_copy_page() and replace with memcpy_page()" is at
https://lore.kernel.org/lkml/[email protected]/

Thanks for your suggestion,

Fabio