]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
f2fs: Delete f2fs_copy_page() and replace with memcpy_page()
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Sun, 17 Jul 2022 08:36:13 +0000 (10:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:39:34 +0000 (13:39 +0200)
commitaaac91468f5b6757f72f30464bcf4489a75846e6
treeb905fa16541b2a6065ef2eea8f0e58fbf37acde6
parent330f6bcdcef03f70f81db5f2ed6747af656a09f2
f2fs: Delete f2fs_copy_page() and replace with memcpy_page()

[ Upstream commit 1dd55358efc4f74e49fa9e1e97a03804852a4c20 ]

f2fs_copy_page() is a wrapper around two kmap() + one memcpy() from/to
the mapped pages. It unnecessarily duplicates a kernel API and it makes
use of kmap(), which 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.

With kmap_local_page() the mappings are per thread, CPU local, can take
page faults, and can be called from any context (including interrupts).
It is faster than kmap() in kernels with HIGHMEM enabled. Therefore, its
use in __clone_blkaddrs() is safe and should be preferred.

Delete f2fs_copy_page() and use a plain memcpy_page() in the only one
site calling the removed function. memcpy_page() avoids open coding two
kmap_local_page() + one memcpy() between the two kernel virtual addresses.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Stable-dep-of: d3876e34e7e7 ("f2fs: fix to wait on page writeback in __clone_blkaddrs()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c