public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: Use memcpy_page() in f2fs_copy_page()
@ 2022-07-16 20:43 Fabio M. De Francesco
  2022-07-17  6:55 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio M. De Francesco @ 2022-07-16 20:43 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, Nick Terrell, linux-f2fs-devel,
	linux-kernel
  Cc: Fabio M. De Francesco, Ira Weiny

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().

Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
 fs/f2fs/f2fs.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index d9bbecd008d2..f04e760bb1c1 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -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)
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: Use memcpy_page() in f2fs_copy_page()
  2022-07-16 20:43 [PATCH] f2fs: Use memcpy_page() in f2fs_copy_page() Fabio M. De Francesco
@ 2022-07-17  6:55 ` Christoph Hellwig
  2022-07-17  8:44   ` Fabio M. De Francesco
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-07-17  6:55 UTC (permalink / raw)
  To: Fabio M. De Francesco
  Cc: Jaegeuk Kim, Chao Yu, Nick Terrell, linux-f2fs-devel,
	linux-kernel, Ira Weiny

On Sat, Jul 16, 2022 at 10:43:53PM +0200, Fabio M. De Francesco wrote:
>  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);

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: Use memcpy_page() in f2fs_copy_page()
  2022-07-17  6:55 ` Christoph Hellwig
@ 2022-07-17  8:44   ` Fabio M. De Francesco
  0 siblings, 0 replies; 3+ messages in thread
From: Fabio M. De Francesco @ 2022-07-17  8:44 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jaegeuk Kim, Chao Yu, Nick Terrell, linux-f2fs-devel,
	linux-kernel, Ira Weiny

On domenica 17 luglio 2022 08:55:20 CEST Christoph Hellwig wrote:
> On Sat, Jul 16, 2022 at 10:43:53PM +0200, Fabio M. De Francesco wrote:
> >  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);
> 
> 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/20220717083613.3861-1-fmdefrancesco@gmail.com/

Thanks for your suggestion,

Fabio



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-17  8:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-16 20:43 [PATCH] f2fs: Use memcpy_page() in f2fs_copy_page() Fabio M. De Francesco
2022-07-17  6:55 ` Christoph Hellwig
2022-07-17  8:44   ` Fabio M. De Francesco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox