Documentation/highmem: Add information about kmap_local_folio()
Subsystems (3)
PATCH v3 1/1 Documentation/highmem: Add information about kmap_local_folio()
The differences between kmap_local_page() and kmap_local_folio() consist only in the first taking a pointer to a page and the second taking two arguments, a pointer to a folio and the byte offset within the folio which identifies the page.
The two API's can be explained at the same time in the "Temporary Virtual Mappings" section of the Highmem's documentation.
Add information about kmap_local_folio() in the same subsection that explains kmap_local_page().
---
v2->v3: Replaced "request" with "create". Noticed by Randy (thanks),
fixed by Matthew (again thanks). https://lore.kernel.org/lkml/[email protected]/
v1-v2: I had Cc'ed everybody but Andrew :-( Sorry, it's now fixed.
In the meantime, I collected the review tags by Ira and Mike (thanks to both of you). All entries are listed using a simple ascending lexycographycal order based on first names.
Documentation/mm/highmem.rst | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
Documentation/mm/highmem.rst +15 -12
@@ -51,11 +51,14 @@ Temporary Virtual Mappings The kernel contains several ways of creating temporary mappings. The following list shows them in order of preference of use. -* kmap_local_page(). This function is used to require short term mappings. - It can be invoked from any context (including interrupts) but the mappings - can only be used in the context which acquired them. - - This function should always be used, whereas kmap_atomic() and kmap() have +* kmap_local_page(), kmap_local_folio() - These functions are used to create + short term mappings. They can be invoked from any context (including + interrupts) but the mappings can only be used in the context which acquired + them. The only differences between them consist in the first taking a pointer + to a struct page and the second taking a pointer to struct folio and the byte + offset within the folio which identifies the page. + + These functions should always be used, whereas kmap_atomic() and kmap() have been deprecated. These mappings are thread-local and CPU-local, meaning that the mapping
@@ -72,17 +75,17 @@ list shows them in order of preference of use. maps of the outgoing task are saved and those of the incoming one are restored. - kmap_local_page() always returns a valid virtual address and it is assumed - that kunmap_local() will never fail. + kmap_local_page(), as well as kmap_local_folio() always returns valid virtual + kernel addresses and it is assumed that kunmap_local() will never fail. - On CONFIG_HIGHMEM=n kernels and for low memory pages this returns the + On CONFIG_HIGHMEM=n kernels and for low memory pages they return the virtual address of the direct mapping. Only real highmem pages are temporarily mapped. Therefore, users may call a plain page_address() for pages which are known to not come from ZONE_HIGHMEM. However, it is - always safe to use kmap_local_page() / kunmap_local(). + always safe to use kmap_local_{page,folio}() / kunmap_local(). - While it is significantly faster than kmap(), for the highmem case it - comes with restrictions about the pointers validity. Contrary to kmap() + While they are significantly faster than kmap(), for the highmem case they + come with restrictions about the pointers validity. Contrary to kmap() mappings, the local mappings are only valid in the context of the caller and cannot be handed to other contexts. This implies that users must be absolutely sure to keep the use of the return address local to the
@@ -91,7 +94,7 @@ list shows them in order of preference of use. Most code can be designed to use thread local mappings. User should therefore try to design their code to avoid the use of kmap() by mapping pages in the same thread the address will be used and prefer - kmap_local_page(). + kmap_local_page() or kmap_local_folio(). Nesting kmap_local_page() and kmap_atomic() mappings is allowed to a certain extent (up to KMAP_TYPE_NR) but their invocations have to be strictly ordered
Signature · 1 line
2.41.0
Quoted 33 lines · Fabio M. De Francesco
The differences between
kmap_local_page()andkmap_local_folio()consist only in the first taking a pointer to a page and the second taking two arguments, a pointer to a folio and the byte offset within the folio which identifies the page.The two API's can be explained at the same time in the "Temporary Virtual Mappings" section of the Highmem's documentation.
Add information about
kmap_local_folio()in the same subsection that explainskmap_local_page().Cc Andrew Morton <[email protected]>Cc Catalin Marinas <[email protected]>Cc Ira Weiny <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Matthew Wilcox (Oracle) <[email protected]>Cc Mike Rapoport <[email protected]>Cc Peter Collingbourne <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Randy Dunlap <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Will Deacon <[email protected]>Reviewed-by Ira Weiny <[email protected]>Reviewed-by Mike Rapoport (IBM) <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>---
v2->v3: Replaced "request" with "create". Noticed by Randy (thanks),fixed by Matthew (again thanks). https://lore.kernel.org/lkml/[email protected]/
Quoted 7 lines
v1-v2: I had Cc'ed everybody but Andrew :-( Sorry, it's now fixed.
In the meantime, I collected the review tags by Ira and Mike (thanks to both of you). All entries are listed using a simple ascending lexycographycal order based on first names.Documentation/mm/highmem.rst | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
Applied, thanks.
jon
Quoted 13 lines · On venerdì 14 luglio 2023 21:45:09 CEST Jonathan Corbet wrote:
Quoted 11 lines · Fabio M. De Francesco
The differences between
kmap_local_page()andkmap_local_folio()consist only in the first taking a pointer to a page and the second taking two arguments, a pointer to a folio and the byte offset within the folio which identifies the page.The two API's can be explained at the same time in the "Temporary Virtual Mappings" section of the Highmem's documentation.
Add information about
kmap_local_folio()in the same subsection that explainskmap_local_page().
[snip]
Quoted 4 lines
Applied, thanks.
jon
Jonathan,
Can you please tell me which release is this patch for? I see that it has not yet reached upstream.
Thanks,
Fabio
Jonathan Corbet
maintainerQuoted 16 lines · Fabio M. De Francesco
Quoted 13 lines · On venerdì 14 luglio 2023 21:45:09 CEST Jonathan Corbet wrote:
Quoted 11 lines · Fabio M. De Francesco
The differences between
kmap_local_page()andkmap_local_folio()consist only in the first taking a pointer to a page and the second taking two arguments, a pointer to a folio and the byte offset within the folio which identifies the page.The two API's can be explained at the same time in the "Temporary Virtual Mappings" section of the Highmem's documentation.
Add information about
kmap_local_folio()in the same subsection that explainskmap_local_page().[snip]
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Applied, thanks.
jon
Jonathan,
Can you please tell me which release is this patch for? I see that it has not yet reached upstream.
It's in docs-next and will go to Linus during the merge window.
Thanks,
jon