public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs: Replace kmap() with kmap_local_page()
@ 2022-06-28 18:24 Fabio M. De Francesco
  2022-07-01 18:54 ` Ira Weiny
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio M. De Francesco @ 2022-06-28 18:24 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker, Jens Axboe, Chaitanya Kulkarni,
	Kees Cook, Martin K. Petersen, Gustavo A. R. Silva, Chuck Lever,
	Baptiste Lepers, linux-nfs, linux-kernel
  Cc: Fabio M. De Francesco, Ira Weiny

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

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Furthermore, the mapping can be acquired from any context
(including interrupts).

Therefore, use kmap_local_page() in nfs_do_filldir() because this mapping
is per thread, CPU local, and not globally visible.

Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---

I cannot test this patch for several reasons. While these changes seem safe
and trivial, I would feel better if people familiar with NFS could take the
time to properly test this patch. Thank you.

 fs/nfs/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 0c4e8dd6aa96..8b89f10d8899 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1084,7 +1084,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc,
 	struct nfs_cache_array *array;
 	unsigned int i;
 
-	array = kmap(desc->page);
+	array = kmap_local_page(desc->page);
 	for (i = desc->cache_entry_index; i < array->size; i++) {
 		struct nfs_cache_array_entry *ent;
 
@@ -1110,7 +1110,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc,
 	if (array->page_is_eof)
 		desc->eof = !desc->eob;
 
-	kunmap(desc->page);
+	kunmap_local(array);
 	dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %llu\n",
 			(unsigned long long)desc->dir_cookie);
 }
-- 
2.36.1


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

* Re: [PATCH] nfs: Replace kmap() with kmap_local_page()
  2022-06-28 18:24 [PATCH] nfs: Replace kmap() with kmap_local_page() Fabio M. De Francesco
@ 2022-07-01 18:54 ` Ira Weiny
  0 siblings, 0 replies; 2+ messages in thread
From: Ira Weiny @ 2022-07-01 18:54 UTC (permalink / raw)
  To: Fabio M. De Francesco
  Cc: Trond Myklebust, Anna Schumaker, Jens Axboe, Chaitanya Kulkarni,
	Kees Cook, Martin K. Petersen, Gustavo A. R. Silva, Chuck Lever,
	Baptiste Lepers, linux-nfs, linux-kernel

On Tue, Jun 28, 2022 at 08:24:26PM +0200, Fabio M. De Francesco wrote:
> The use of kmap() is being deprecated in favor of kmap_local_page().
> 
> With kmap_local_page(), the mapping is per thread, CPU local and not
> globally visible. Furthermore, the mapping can be acquired from any context
> (including interrupts).
> 
> Therefore, use kmap_local_page() in nfs_do_filldir() because this mapping
> is per thread, CPU local, and not globally visible.
> 
> Suggested-by: Ira Weiny <ira.weiny@intel.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
> 
> I cannot test this patch for several reasons. While these changes seem safe
> and trivial, I would feel better if people familiar with NFS could take the
> time to properly test this patch. Thank you.
> 
>  fs/nfs/dir.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 0c4e8dd6aa96..8b89f10d8899 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -1084,7 +1084,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc,
>  	struct nfs_cache_array *array;
>  	unsigned int i;
>  
> -	array = kmap(desc->page);
> +	array = kmap_local_page(desc->page);
>  	for (i = desc->cache_entry_index; i < array->size; i++) {
>  		struct nfs_cache_array_entry *ent;
>  
> @@ -1110,7 +1110,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc,
>  	if (array->page_is_eof)
>  		desc->eof = !desc->eob;
>  
> -	kunmap(desc->page);
> +	kunmap_local(array);
>  	dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %llu\n",
>  			(unsigned long long)desc->dir_cookie);
>  }
> -- 
> 2.36.1
> 

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

end of thread, other threads:[~2022-07-01 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-28 18:24 [PATCH] nfs: Replace kmap() with kmap_local_page() Fabio M. De Francesco
2022-07-01 18:54 ` Ira Weiny

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