All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] affs: replace kmap_atomic() with kmap_local_page()
@ 2022-07-12 22:27 David Sterba
  2022-07-12 23:02 ` Fabio M. De Francesco
  2022-07-21 18:50 ` [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic() David Sterba
  0 siblings, 2 replies; 5+ messages in thread
From: David Sterba @ 2022-07-12 22:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: David Sterba, Ira Weiny, Fabio M . De Francesco

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. With kmap_local_page(), the mapping is per thread,
CPU local and not globally visible, like in this case around a simple
memcpy().

CC: Ira Weiny <ira.weiny@intel.com>
CC: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/affs/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index cd00a4c68a12..92754c40c5cd 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -545,9 +545,9 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 			return PTR_ERR(bh);
 		tmp = min(bsize - boff, to - pos);
 		BUG_ON(pos + tmp > to || tmp > bsize);
-		data = kmap_atomic(page);
+		data = kmap_local_page(page);
 		memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
-		kunmap_atomic(data);
+		kunmap_local(data);
 		affs_brelse(bh);
 		bidx++;
 		pos += tmp;
-- 
2.36.1


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

* Re: [PATCH] affs: replace kmap_atomic() with kmap_local_page()
  2022-07-12 22:27 [PATCH] affs: replace kmap_atomic() with kmap_local_page() David Sterba
@ 2022-07-12 23:02 ` Fabio M. De Francesco
  2022-07-21 18:50 ` [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic() David Sterba
  1 sibling, 0 replies; 5+ messages in thread
From: Fabio M. De Francesco @ 2022-07-12 23:02 UTC (permalink / raw)
  To: linux-fsdevel, David Sterba; +Cc: David Sterba, Ira Weiny

On mercoledì 13 luglio 2022 00:27:44 CEST David Sterba wrote:
> The use of kmap() is being deprecated in favor of kmap_local_page()
> where it is feasible. With kmap_local_page(), the mapping is per thread,
> CPU local and not globally visible, like in this case around a simple
> memcpy().
> 
> CC: Ira Weiny <ira.weiny@intel.com>
> CC: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/affs/file.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/affs/file.c b/fs/affs/file.c
> index cd00a4c68a12..92754c40c5cd 100644
> --- a/fs/affs/file.c
> +++ b/fs/affs/file.c
> @@ -545,9 +545,9 @@ affs_do_readpage_ofs(struct page *page, unsigned to, 
int create)
>  			return PTR_ERR(bh);
>  		tmp = min(bsize - boff, to - pos);
>  		BUG_ON(pos + tmp > to || tmp > bsize);
> -		data = kmap_atomic(page);
> +		data = kmap_local_page(page);
>  		memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
> -		kunmap_atomic(data);
> +		kunmap_local(data);
>  		affs_brelse(bh);
>  		bidx++;
>  		pos += tmp;
> -- 
> 2.36.1
> 
It looks good but... what about using memcpy_to_page() instead of open 
coding kmap_local_page() + memcpy() and delete variable "char *data" since 
it will become unused?

Thanks,

Fabio





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

* [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic()
  2022-07-12 22:27 [PATCH] affs: replace kmap_atomic() with kmap_local_page() David Sterba
  2022-07-12 23:02 ` Fabio M. De Francesco
@ 2022-07-21 18:50 ` David Sterba
  2022-07-21 22:07   ` Ira Weiny
  1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2022-07-21 18:50 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: David Sterba, Ira Weiny, Fabio M . De Francesco

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. For kmap around a memcpy there's a convenience
helper memcpy_to_page, use it.

CC: Ira Weiny <ira.weiny@intel.com>
CC: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/affs/file.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index cd00a4c68a12..45a21729f358 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -526,7 +526,6 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 	struct inode *inode = page->mapping->host;
 	struct super_block *sb = inode->i_sb;
 	struct buffer_head *bh;
-	char *data;
 	unsigned pos = 0;
 	u32 bidx, boff, bsize;
 	u32 tmp;
@@ -545,9 +544,7 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 			return PTR_ERR(bh);
 		tmp = min(bsize - boff, to - pos);
 		BUG_ON(pos + tmp > to || tmp > bsize);
-		data = kmap_atomic(page);
-		memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
-		kunmap_atomic(data);
+		memcpy_to_page(page, pos, AFFS_DATA(bh) + boff, tmp);
 		affs_brelse(bh);
 		bidx++;
 		pos += tmp;
-- 
2.36.1


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

* Re: [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic()
  2022-07-21 18:50 ` [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic() David Sterba
@ 2022-07-21 22:07   ` Ira Weiny
  2022-07-22 21:49     ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Ira Weiny @ 2022-07-21 22:07 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-fsdevel, Fabio M . De Francesco

On Thu, Jul 21, 2022 at 08:50:24PM +0200, David Sterba wrote:
> The use of kmap() is being deprecated in favor of kmap_local_page()
> where it is feasible. For kmap around a memcpy there's a convenience
> helper memcpy_to_page, use it.
> 
> CC: Ira Weiny <ira.weiny@intel.com>

Typo in the subject: s/memcpy_to_page/memcpy_to_zero

Other than that.

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

> CC: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/affs/file.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/affs/file.c b/fs/affs/file.c
> index cd00a4c68a12..45a21729f358 100644
> --- a/fs/affs/file.c
> +++ b/fs/affs/file.c
> @@ -526,7 +526,6 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
>  	struct inode *inode = page->mapping->host;
>  	struct super_block *sb = inode->i_sb;
>  	struct buffer_head *bh;
> -	char *data;
>  	unsigned pos = 0;
>  	u32 bidx, boff, bsize;
>  	u32 tmp;
> @@ -545,9 +544,7 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
>  			return PTR_ERR(bh);
>  		tmp = min(bsize - boff, to - pos);
>  		BUG_ON(pos + tmp > to || tmp > bsize);
> -		data = kmap_atomic(page);
> -		memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
> -		kunmap_atomic(data);
> +		memcpy_to_page(page, pos, AFFS_DATA(bh) + boff, tmp);
>  		affs_brelse(bh);
>  		bidx++;
>  		pos += tmp;
> -- 
> 2.36.1
> 

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

* Re: [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic()
  2022-07-21 22:07   ` Ira Weiny
@ 2022-07-22 21:49     ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2022-07-22 21:49 UTC (permalink / raw)
  To: Ira Weiny; +Cc: David Sterba, linux-fsdevel, Fabio M . De Francesco

On Thu, Jul 21, 2022 at 03:07:38PM -0700, Ira Weiny wrote:
> On Thu, Jul 21, 2022 at 08:50:24PM +0200, David Sterba wrote:
> > The use of kmap() is being deprecated in favor of kmap_local_page()
> > where it is feasible. For kmap around a memcpy there's a convenience
> > helper memcpy_to_page, use it.
> > 
> > CC: Ira Weiny <ira.weiny@intel.com>
> 
> Typo in the subject: s/memcpy_to_page/memcpy_to_zero
> 
> Other than that.
> 
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>

Thanks, fixed.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 22:27 [PATCH] affs: replace kmap_atomic() with kmap_local_page() David Sterba
2022-07-12 23:02 ` Fabio M. De Francesco
2022-07-21 18:50 ` [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic() David Sterba
2022-07-21 22:07   ` Ira Weiny
2022-07-22 21:49     ` David Sterba

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.