@@ -145,6 +145,37 @@ static inline void *kmap_local_folio(struct folio *folio, size_t offset);
145
145
* Mappings should always be released by kunmap_atomic().
146
146
*
147
147
* Do not use in new code. Use kmap_local_page() instead.
148
+ *
149
+ * It is used in atomic context when code wants to access the contents of a
150
+ * page that might be allocated from high memory (see __GFP_HIGHMEM), for
151
+ * example a page in the pagecache. The API has two functions, and they
152
+ * can be used in a manner similar to the following:
153
+ *
154
+ * -- Find the page of interest. --
155
+ * struct page *page = find_get_page(mapping, offset);
156
+ *
157
+ * -- Gain access to the contents of that page. --
158
+ * void *vaddr = kmap_atomic(page);
159
+ *
160
+ * -- Do something to the contents of that page. --
161
+ * memset(vaddr, 0, PAGE_SIZE);
162
+ *
163
+ * -- Unmap that page. --
164
+ * kunmap_atomic(vaddr);
165
+ *
166
+ * Note that the kunmap_atomic() call takes the result of the kmap_atomic()
167
+ * call, not the argument.
168
+ *
169
+ * If you need to map two pages because you want to copy from one page to
170
+ * another you need to keep the kmap_atomic calls strictly nested, like:
171
+ *
172
+ * vaddr1 = kmap_atomic(page1);
173
+ * vaddr2 = kmap_atomic(page2);
174
+ *
175
+ * memcpy(vaddr1, vaddr2, PAGE_SIZE);
176
+ *
177
+ * kunmap_atomic(vaddr2);
178
+ * kunmap_atomic(vaddr1);
148
179
*/
149
180
static inline void * kmap_atomic (struct page * page );
150
181
0 commit comments