Skip to content

Commit a9e9c93

Browse files
xp4ns3akpm00
authored andcommitted
Documentation/mm: add details about kmap_local_page() and preemption
What happens if a thread is preempted after mapping pages with kmap_local_page() was questioned recently.[1] Commit f3ba3c7 ("mm/highmem: Provide kmap_local*") from Thomas Gleixner explains clearly that on context switch, the maps of an outgoing task are removed and the map of the incoming task are restored and that kmap_local_page() can be invoked from both preemptible and atomic contexts.[2] Therefore, for the purpose to make it clearer that users can call kmap_local_page() from contexts that allow preemption, rework a couple of sentences and add further information in highmem.rst. [1] https://lore.kernel.org/lkml/5303077.Sb9uPGUboI@opensuse/ [2] https://lore.kernel.org/all/20201118204007.468533059@linutronix.de/ Link: https://lkml.kernel.org/r/20220728154844.10874-8-fmdefrancesco@gmail.com Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Suggested-by: Ira Weiny <ira.weiny@intel.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Mike Rapoport <rppt@linux.ibm.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Peter Collingbourne <pcc@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 72f1c55 commit a9e9c93

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Documentation/mm/highmem.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ list shows them in order of preference of use.
6060
This function should be preferred, where feasible, over all the others.
6161

6262
These mappings are thread-local and CPU-local, meaning that the mapping
63-
can only be accessed from within this thread and the thread is bound the
64-
CPU while the mapping is active. Even if the thread is preempted (since
65-
preemption is never disabled by the function) the CPU can not be
66-
unplugged from the system via CPU-hotplug until the mapping is disposed.
63+
can only be accessed from within this thread and the thread is bound to the
64+
CPU while the mapping is active. Although preemption is never disabled by
65+
this function, the CPU can not be unplugged from the system via
66+
CPU-hotplug until the mapping is disposed.
6767

6868
It's valid to take pagefaults in a local kmap region, unless the context
6969
in which the local mapping is acquired does not allow it for other reasons.
7070

71+
As said, pagefaults and preemption are never disabled. There is no need to
72+
disable preemption because, when context switches to a different task, the
73+
maps of the outgoing task are saved and those of the incoming one are
74+
restored.
75+
7176
kmap_local_page() always returns a valid virtual address and it is assumed
7277
that kunmap_local() will never fail.
7378

0 commit comments

Comments
 (0)