Skip to content

Commit

Permalink
zsmalloc: zs_object_copy: add clarifying comment
Browse files Browse the repository at this point in the history
Patch series "tidy up zsmalloc implementation"

This patchset remove some unnecessary checks and adds a clarifying
comment.  While analysing zs_object_copy() function code, I spent some
time to understand what the call kunmap_atomic(d_addr) is for.  It seems
that this point is not trivial and it is worth adding a comment.


This patch (of 2):

It's not obvious why kunmap_atomic(d_addr) call is needed.

[akpm@linux-foundation.org: tweak comment layout]
Link: https://lkml.kernel.org/r/20220811153755.16102-1-avromanov@sberdevices.ru
Link: https://lkml.kernel.org/r/20220811153755.16102-2-avromanov@sberdevices.ru
Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Alexey Romanov authored and Andrew Morton committed Sep 12, 2022
1 parent e9c2dbc commit 050a388
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,13 @@ 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
* https://lore.kernel.org/linux-mm/5512421D.4000603@samsung.com/
*/
if (s_off >= PAGE_SIZE) {
kunmap_atomic(d_addr);
kunmap_atomic(s_addr);
Expand Down

0 comments on commit 050a388

Please sign in to comment.