affs: replace kmap_atomic() with kmap_local_page()
Subsystems (2)
David Sterba
maintainerPATCH 1/1 affs: replace kmap_atomic() with kmap_local_page()
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().
--- fs/affs/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/affs/file.c +2 -2
@@ -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;
Signature · 1 line
2.36.1
fs/affs/file.c affs_do_readpage_ofs(struct page *page, unsigned to,
Quoted 17 lines · On mercoledì 13 luglio 2022 00:27:44 CEST David Sterba wrote:
The use of
kmap()is being deprecated in favor ofkmap_local_page()where it is feasible. Withkmap_local_page(), the mapping is per thread, CPU local and not globally visible, like in this case around a simplememcpy().CC Ira Weiny <[email protected]>CC Fabio M. De Francesco <[email protected]>Signed-off-by David Sterba <[email protected]>--- fs/affs/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/affs/file.c +0
-0@@ -545,9 +545,9 @@ affs_do_readpage_ofs(struct page *page, unsigned to,
int create)
Quoted 14 lines
fs/affs/file.c +2
-2return 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;Signature · 1 line
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
David Sterba
maintainerPATCH v2 1/1 affs: use memcpy_to_zero and remove replace kmap_atomic()
In reply to David SterbaThe 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.
--- fs/affs/file.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/affs/file.c +1 -4
@@ -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;
Signature · 1 line
2.36.1
Re: [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic()
Quoted 5 lines · David Sterba
The use of
kmap()is being deprecated in favor ofkmap_local_page()where it is feasible. For kmap around a memcpy there's a convenience helpermemcpy_to_page, use it.CC Ira Weiny <[email protected]>
Typo in the subject: s/memcpy_to_page/memcpy_to_zero
Other than that.
Quoted 32 lines
CC Fabio M. De Francesco <[email protected]>Signed-off-by David Sterba <[email protected]>--- fs/affs/file.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)fs/affs/file.c +1
-4@@ -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;Signature · 1 line
2.36.1
Re: [PATCH v2] affs: use memcpy_to_zero and remove replace kmap_atomic()
Quoted 5 lines · Ira Weiny
Quoted 4 lines · David Sterba
The use of
kmap()is being deprecated in favor ofkmap_local_page()where it is feasible. For kmap around a memcpy there's a convenience helpermemcpy_to_page, use it.
Quoted 7 lines
Quoted 1 line
CC Ira Weiny <[email protected]>Typo in the subject: s/memcpy_to_page/memcpy_to_zero
Other than that.
Reviewed-by Ira Weiny <[email protected]>
Thanks, fixed.