linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] tidy up zsmalloc implementation
@ 2022-08-15 12:39 Alexey Romanov
  2022-08-15 12:39 ` [PATCH v2 1/2] zsmalloc: zs_object_copy: add clarifying comment Alexey Romanov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexey Romanov @ 2022-08-15 12:39 UTC (permalink / raw)
  To: minchan, senozhatsky, ngupta, akpm
  Cc: linux-mm, linux-kernel, kernel, Alexey Romanov

Hello!

This patchset remove some unnecessary checks and adds clarifying 
comment. While analysis 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.

Alexey Romanov (2):
  zsmalloc: zs_object_copy: add clarifying comment
  zsmalloc: remove unnecessary size_class NULL check

 mm/zsmalloc.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

-- 
2.30.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] zsmalloc: zs_object_copy: add clarifying comment
  2022-08-15 12:39 [PATCH v2 0/2] tidy up zsmalloc implementation Alexey Romanov
@ 2022-08-15 12:39 ` Alexey Romanov
  2022-08-15 12:39 ` [PATCH v2 2/2] zsmalloc: remove unnecessary size_class NULL check Alexey Romanov
  2022-08-15 14:56 ` [PATCH v2 0/2] tidy up zsmalloc implementation Aleksey Romanov
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Romanov @ 2022-08-15 12:39 UTC (permalink / raw)
  To: minchan, senozhatsky, ngupta, akpm
  Cc: linux-mm, linux-kernel, kernel, Alexey Romanov

Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
 mm/zsmalloc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 5d5fc04385b8..df381ba891ea 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1564,6 +1564,12 @@ 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
+		 */
 		if (s_off >= PAGE_SIZE) {
 			kunmap_atomic(d_addr);
 			kunmap_atomic(s_addr);
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] zsmalloc: remove unnecessary size_class NULL check
  2022-08-15 12:39 [PATCH v2 0/2] tidy up zsmalloc implementation Alexey Romanov
  2022-08-15 12:39 ` [PATCH v2 1/2] zsmalloc: zs_object_copy: add clarifying comment Alexey Romanov
@ 2022-08-15 12:39 ` Alexey Romanov
  2022-08-15 14:56 ` [PATCH v2 0/2] tidy up zsmalloc implementation Aleksey Romanov
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Romanov @ 2022-08-15 12:39 UTC (permalink / raw)
  To: minchan, senozhatsky, ngupta, akpm
  Cc: linux-mm, linux-kernel, kernel, Alexey Romanov

pool->size_class array elements can't be NULL, so this check
is not needed.

In the whole code, we assign pool->size_class[i] values that are
not NULL. Releasing memory for these values occurs in the
zs_destroy_pool() function, which also releases and destroys the pool.

In addition, in the zs_stats_size_show() and async_free_zspage(),
with similar iterations over the array, we don't check it for NULL
pointer.

Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
 mm/zsmalloc.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index df381ba891ea..d064ce32e7b9 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2154,8 +2154,6 @@ unsigned long zs_compact(struct zs_pool *pool)
 
 	for (i = ZS_SIZE_CLASSES - 1; i >= 0; i--) {
 		class = pool->size_class[i];
-		if (!class)
-			continue;
 		if (class->index != i)
 			continue;
 		pages_freed += __zs_compact(pool, class);
@@ -2200,8 +2198,6 @@ static unsigned long zs_shrinker_count(struct shrinker *shrinker,
 
 	for (i = ZS_SIZE_CLASSES - 1; i >= 0; i--) {
 		class = pool->size_class[i];
-		if (!class)
-			continue;
 		if (class->index != i)
 			continue;
 
@@ -2361,9 +2357,6 @@ void zs_destroy_pool(struct zs_pool *pool)
 		int fg;
 		struct size_class *class = pool->size_class[i];
 
-		if (!class)
-			continue;
-
 		if (class->index != i)
 			continue;
 
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] tidy up zsmalloc implementation
  2022-08-15 12:39 [PATCH v2 0/2] tidy up zsmalloc implementation Alexey Romanov
  2022-08-15 12:39 ` [PATCH v2 1/2] zsmalloc: zs_object_copy: add clarifying comment Alexey Romanov
  2022-08-15 12:39 ` [PATCH v2 2/2] zsmalloc: remove unnecessary size_class NULL check Alexey Romanov
@ 2022-08-15 14:56 ` Aleksey Romanov
  2 siblings, 0 replies; 4+ messages in thread
From: Aleksey Romanov @ 2022-08-15 14:56 UTC (permalink / raw)
  To: minchan, senozhatsky, ngupta, akpm; +Cc: linux-mm, linux-kernel, kernel

Hello! 

I accidientally send v2 patchset instead of send a single change 
from 1/2 patch based on linux-next tree. Please, ignore this patchset
and see the change I send in a separate email.

Sorry for the noise.

-- 
Thank you,
Alexey

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-15 14:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 12:39 [PATCH v2 0/2] tidy up zsmalloc implementation Alexey Romanov
2022-08-15 12:39 ` [PATCH v2 1/2] zsmalloc: zs_object_copy: add clarifying comment Alexey Romanov
2022-08-15 12:39 ` [PATCH v2 2/2] zsmalloc: remove unnecessary size_class NULL check Alexey Romanov
2022-08-15 14:56 ` [PATCH v2 0/2] tidy up zsmalloc implementation Aleksey Romanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).