Re: [PATCH v2] lib: Replace kmap() with kmap_local_page()

From: Ira Weiny
Date: Tue Jun 13 2023 - 17:09:04 EST


Sumitra Sharma wrote:
> kmap() has been deprecated in favor of the kmap_local_page()
> due to high cost, restricted mapping space, the overhead of
> a global lock for synchronization, and making the process
> sleep in the absence of free slots.
>
> kmap_local_page() is faster than kmap() and offers thread-local
> and CPU-local mappings, take pagefaults in a local kmap region
> and preserves preemption by saving the mappings of outgoing
> tasks and restoring those of the incoming one during a context
> switch.
>
> The mappings are kept thread local in the functions
> “dmirror_do_read” and “dmirror_do_write” in test_hmm.c
>
> Therefore, replace kmap() with kmap_local_page() and use
> mempcy_from/to_page() to avoid open coding kmap_local_page()
> + memcpy() + kunmap_local().
>
> Remove the unused variable “tmp”.
>
>
> Suggested-by: Fabio M. De Francesco <fmdefrancesco@xxxxxxxxx>
>
> Signed-off-by: Sumitra Sharma <sumitraartsy@xxxxxxxxx>

LGTM

Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx>