Re: [PATCH 3/3] zsmalloc: replace kmap_atomic with kmap_local_page

From: Sergey Senozhatsky
Date: Tue Oct 01 2024 - 23:19:03 EST


On (24/10/01 23:23), Pintu Kumar wrote:
> The use of kmap_atomic/kunmap_atomic is deprecated.
> Replace it will kmap_local_page/kunmap_local all over the place.
> Also fix SPDX missing license header.
>
> WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
>
> WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
> + vaddr = kmap_atomic(page);
>

Can you also update the comments (that mention kmap/kunmap atomic)?

---

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index d3ff10160a5f..5c3bb8a737b0 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -263,7 +263,7 @@ struct zspage {
struct mapping_area {
local_lock_t lock;
char *vm_buf; /* copy buffer for objects that span pages */
- char *vm_addr; /* address of kmap_atomic()'ed pages */
+ char *vm_addr; /* address of kmap_local() pages */
enum zs_mapmode vm_mm; /* mapping mode */
};

@@ -1050,7 +1050,7 @@ static void *__zs_map_object(struct mapping_area *area,
void *addr;
char *buf = area->vm_buf;

- /* disable page faults to match kmap_atomic() return conditions */
+ /* disable page faults to match kmap_local_page() return conditions */
pagefault_disable();

/* no read fastpath */
@@ -1099,7 +1099,7 @@ static void __zs_unmap_object(struct mapping_area *area,
kunmap_local(addr);

out:
- /* enable page faults to match kunmap_atomic() return conditions */
+ /* enable page faults to match kunmap_local() return conditions */
pagefault_enable();
}

@@ -1510,13 +1510,6 @@ static void zs_object_copy(struct size_class *class, unsigned long dst,
d_off += size;
d_size -= size;

- /*
- * Calling kunmap_atomic(d_addr) is necessary. kunmap_atomic()
- * calls must occurs in reverse order of calls to kmap_atomic().
- * So, to call kunmap_atomic(s_addr) we should first call
- * kunmap_atomic(d_addr). For more details see
- * Documentation/mm/highmem.rst.
- */
if (s_off >= PAGE_SIZE) {
kunmap_local(d_addr);
kunmap_local(s_addr);