* [PATCH] highmem: Document kunmap_local()
@ 2022-01-24 1:30 ira.weiny
2022-01-24 12:28 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: ira.weiny @ 2022-01-24 1:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ira Weiny, linux-kernel
From: Ira Weiny <ira.weiny@intel.com>
Some users of kmap() add an offset to the kmap() address to be used
during the mapping.
When converting to kmap_local_page() the base address does not
need to be stored because any address within the page can be used in
kunmap_local(). However, this was not clear from the documentation and
caused some questions.[1]
Document that any address in the page can be used in kunmap_local() to
clarify this for future users.
[1] https://lore.kernel.org/lkml/20211213154543.GM3538886@iweiny-DESK2.sc.intel.com/
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
include/linux/highmem-internal.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
index 0a0b2b09b1b8..fb2d3e033c01 100644
--- a/include/linux/highmem-internal.h
+++ b/include/linux/highmem-internal.h
@@ -246,6 +246,17 @@ do { \
__kunmap_atomic(__addr); \
} while (0)
+/**
+ * kunmap_local - Unmap a page mapped via kmap_local_page().
+ * @__addr: An address within the page mapped
+ *
+ * __addr is often an address returned from kmap_local_page(). However,
+ * this address can be any address within the mapped page. It does not need to
+ * be the exact address returned from kmap_local_page()
+ *
+ * Unmapping should be done in the reverse order of the mapping. See
+ * kmap_local_page() for details.
+ */
#define kunmap_local(__addr) \
do { \
BUILD_BUG_ON(__same_type((__addr), struct page *)); \
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] highmem: Document kunmap_local()
2022-01-24 1:30 [PATCH] highmem: Document kunmap_local() ira.weiny
@ 2022-01-24 12:28 ` Christoph Hellwig
2022-01-24 18:21 ` [PATCH V2] " ira.weiny
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-01-24 12:28 UTC (permalink / raw)
To: ira.weiny; +Cc: Andrew Morton, linux-kernel
On Sun, Jan 23, 2022 at 05:30:44PM -0800, ira.weiny@intel.com wrote:
> + * __addr is often an address returned from kmap_local_page(). However,
> + * this address can be any address within the mapped page. It does not need to
> + * be the exact address returned from kmap_local_page()
> + */
I'd word this a little different:
> + * __addr is often an address returned from kmap_local_page(). However,
> + * this address can be any address within the mapped page. It does not need to
> + * be the exact address returned from kmap_local_page()
> + */
* @__addr can be any address within the mapped page. Commonly it is the
* address return from kmap_local_page(), but it can also include offsets.
But documenting this definitively is a good idea!
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH V2] highmem: Document kunmap_local()
2022-01-24 12:28 ` Christoph Hellwig
@ 2022-01-24 18:21 ` ira.weiny
0 siblings, 0 replies; 3+ messages in thread
From: ira.weiny @ 2022-01-24 18:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ira Weiny, Christoph Hellwig, linux-kernel
From: Ira Weiny <ira.weiny@intel.com>
Some users of kmap() add an offset to the kmap() address to be used
during the mapping.
When converting to kmap_local_page() the base address does not
need to be stored because any address within the page can be used in
kunmap_local(). However, this was not clear from the documentation and
cause some questions.[1]
Document that any address in the page can be used in kunmap_local() to
clarify this for future users.
[1] https://lore.kernel.org/lkml/20211213154543.GM3538886@iweiny-DESK2.sc.intel.com/
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes for V2
Use suggested verbiage from Christoph Hellwig
---
include/linux/highmem-internal.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
index 0a0b2b09b1b8..a77be5630209 100644
--- a/include/linux/highmem-internal.h
+++ b/include/linux/highmem-internal.h
@@ -246,6 +246,16 @@ do { \
__kunmap_atomic(__addr); \
} while (0)
+/**
+ * kunmap_local - Unmap a page mapped via kmap_local_page().
+ * @__addr: An address within the page mapped
+ *
+ * @__addr can be any address within the mapped page. Commonly it is the
+ * address return from kmap_local_page(), but it can also include offsets.
+ *
+ * Unmapping should be done in the reverse order of the mapping. See
+ * kmap_local_page() for details.
+ */
#define kunmap_local(__addr) \
do { \
BUILD_BUG_ON(__same_type((__addr), struct page *)); \
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-24 18:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 1:30 [PATCH] highmem: Document kunmap_local() ira.weiny
2022-01-24 12:28 ` Christoph Hellwig
2022-01-24 18:21 ` [PATCH V2] " ira.weiny
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.