• Fabio M. De Francesco's avatar
    fs/ecryptfs: Replace kmap() with kmap_local_page() · 8b70deb8
    Fabio M. De Francesco authored
    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: default avatarIra Weiny <ira.weiny@intel.com>
    Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
    Signed-off-by: default avatar"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
    Message-Id: <20230426172223.8896-2-fmdefrancesco@gmail.com>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    8b70deb8
read_write.c 7.9 KB