checkpatch: Add kmap and kmap_atomic to the deprecated list
Subsystems (27)
PATCH 1/1 checkpatch: Add kmap and kmap_atomic to the deprecated list
From: Ira Weiny <[email protected]>
kmap() and kmap_atomic() are being deprecated in favor of kmap_local_page().
There are 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.
kmap_local_page() is safe from any context and is therefore redundant with kmap_atomic() with the exception of any pagefault or preemption disable requirements. However, using kmap_atomic() for these side effects makes the code less clear. So any requirement for pagefault or preemption disable should be made explicitly.
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.
---
Suggested by credits.
Thomas: Idea to keep from growing more kmap/kmap_atomic calls.
Fabio: Stole some of his boiler plate commit message.
Notes on tree-wide conversions:
I've cc'ed mailing lists for subsystems which currently contains either kmap() or kmap_atomic() calls. As some of you already know Fabio and I have been working through converting kmap() calls to kmap_local_page(). But there is a lot more work to be done. Help from the community is always welcome, especially with kmap_atomic() conversions. To keep from stepping on each others toes I've created a spreadsheet of the current calls[1]. Please let me or Fabio know if you plan on tacking one of the conversions so we can mark it off the list.
--- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
@@ -807,6 +807,8 @@ our %deprecated_apis = ( "rcu_barrier_sched" => "rcu_barrier", "get_state_synchronize_sched" => "get_state_synchronize_rcu", "cond_synchronize_sched" => "cond_synchronize_rcu", + "kmap" => "kmap_local_page", + "kmap_atomic" => "kmap_local_page", ); #Create a search pattern for all these strings to speed up a loop below
base-commit: 4a9350597aff50bbd0f4b80ccf49d2e02d1111f5
Signature · 6 lines
2.35.3 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 43 lines · On 8/13/22 15:00, [email protected] wrote:
From: Ira Weiny <[email protected]>
kmap()andkmap_atomic()are being deprecated in favor ofkmap_local_page().There are 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.
kmap_local_page()is safe from any context and is therefore redundant withkmap_atomic()with the exception of any pagefault or preemption disable requirements. However, usingkmap_atomic()for these side effects makes the code less clear. So any requirement for pagefault or preemption disable should be made explicitly.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 thankmap()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.Suggested-by Thomas Gleixner <[email protected]>Suggested-by Fabio M. De Francesco <[email protected]>Signed-off-by Ira Weiny <[email protected]>---
Suggested by credits.
Thomas: Idea to keep from growing more kmap/kmap_atomic calls.
Fabio: Stole some of his boiler plate commit message.Notes on tree-wide conversions:
I've cc'ed mailing lists for subsystems which currently contains either
kmap()orkmap_atomic()calls. As some of you already know Fabio and I have been working through convertingkmap()calls tokmap_local_page(). But there is a lot more work to be done. Help from the community is always welcome, especially withkmap_atomic()conversions. To keep from stepping on each others toes I've created a spreadsheet of the current calls[1]. Please let me or Fabio know if you plan on tacking one of the conversions so we can mark it off the list.
Quoted 2 lines
Looks good.