]> git.ipfire.org Git - thirdparty/linux.git/commit
fs/sysv: Replace kmap() with kmap_local_page()
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Thu, 19 Jan 2023 15:32:32 +0000 (16:32 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 20 Jan 2023 04:24:35 +0000 (23:24 -0500)
commit83005276d383387fec7e18c7a36daade579a23a7
tree854063585b9186556e6ce1c280a7deb81ab9dd90
parentc26ddc49c9080975cc03cf3bd6917c3fb37d808b
fs/sysv: Replace kmap() with kmap_local_page()

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

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. Furthermore,
the tasks can be preempted and, when they are scheduled to run again, the
kernel virtual addresses are restored and still valid.

Since kmap_local_page() would not break the strict rules of local mappings
(i.e., the thread locality and the stack based nesting), this function can
be easily and safely replace the deprecated API.

Therefore, replace kmap() with kmap_local_page() in fs/sysv. kunmap_local()
requires the mapping address, so return that address from dir_get_page()
to be used in dir_put_page().

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/sysv/dir.c
fs/sysv/namei.c
fs/sysv/sysv.h