linux/fs/ecryptfs
Fabio M. De Francesco 8b70deb8ca fs/ecryptfs: Replace kmap() with kmap_local_page()
kmap() has been deprecated in favor of kmap_local_page().

Therefore, replace kmap() with kmap_local_page() in fs/ecryptfs.

There are two main problems with kmap(): (1) It comes with an overhead as
the 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. The tasks can
be preempted and, when they are scheduled to run again, the kernel
virtual addresses are restored and still valid.

Obviously, thread locality implies that the kernel virtual addresses
returned by kmap_local_page() are only valid in the context of the
callers (i.e., they cannot be handed to other threads).

The use of kmap_local_page() in fs/ecryptfs does not break the
above-mentioned assumption, so it is allowed and preferred.

Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with
HIGHMEM64GB enabled.

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>
Message-Id: <20230426172223.8896-2-fmdefrancesco@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-07-10 14:36:10 +02:00
..
crypto.c fs/ecryptfs: Replace kmap() with kmap_local_page() 2023-07-10 14:36:10 +02:00
debug.c ecryptfs: debug: Demote a couple of kernel-doc abuses 2021-04-19 04:42:13 +00:00
dentry.c ecryptfs: dentry: File headers are not good candidates for kernel-doc 2021-04-19 04:42:13 +00:00
ecryptfs_kernel.h ecryptfs: constify path 2022-09-01 17:40:38 -04:00
file.c splice: Use filemap_splice_read() instead of generic_file_splice_read() 2023-05-24 08:42:17 -06:00
inode.c fs: drop unused posix acl handlers 2023-03-06 09:57:12 +01:00
Kconfig docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
keystore.c ecryptfs: keystore: Fix some kernel-doc issues and demote non-conformant headers 2021-04-19 04:42:13 +00:00
kthread.c ecryptfs: kthread: Demote file header and provide description for 'cred' 2021-04-19 04:42:13 +00:00
main.c ecryptfs: constify path 2022-09-01 17:40:38 -04:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
messaging.c eCryptfs: Use DEFINE_MUTEX() for mutex lock 2021-04-19 04:42:13 +00:00
miscdev.c ecryptfs: miscdev: File headers are not good kernel-doc candidates 2021-04-19 04:42:13 +00:00
mmap.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
read_write.c fs/ecryptfs: Replace kmap() with kmap_local_page() 2023-07-10 14:36:10 +02:00
super.c fs: allocate inode by using alloc_inode_sb() 2022-03-22 15:57:03 -07:00