linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check
@ 2022-10-13 11:28 Alexey Romanov
  2022-10-13 12:34 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Romanov @ 2022-10-13 11:28 UTC (permalink / raw)
  To: minchan, senozhatsky, ngupta, akpm
  Cc: linux-mm, linux-kernel, kernel, Alexey Romanov

Inside the zs_destroy_pool() function, there can still
be NULL size_class pointers: if when the next size_class is
allocated, inside zs_create_pool() function, kzalloc will
return NULL and handling the error condition, zs_create_pool()
will call zs_destroy_pool().

Fixes: f24263a5a076 ("zsmalloc: remove unnecessary size_class NULL check")
Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
 mm/zsmalloc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 525758713a55..d03941cace2c 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2311,6 +2311,9 @@ 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.25.1


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

* Re: [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check
  2022-10-13 11:28 [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check Alexey Romanov
@ 2022-10-13 12:34 ` Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2022-10-13 12:34 UTC (permalink / raw)
  To: Andrew Morton, Alexey Romanov
  Cc: minchan, senozhatsky, ngupta, akpm, linux-mm, linux-kernel, kernel

On (22/10/13 14:28), Alexey Romanov wrote:
> Inside the zs_destroy_pool() function, there can still
> be NULL size_class pointers: if when the next size_class is
> allocated, inside zs_create_pool() function, kzalloc will
> return NULL and handling the error condition, zs_create_pool()
> will call zs_destroy_pool().
> 
> Fixes: f24263a5a076 ("zsmalloc: remove unnecessary size_class NULL check")
> Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
> ---
>  mm/zsmalloc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 525758713a55..d03941cace2c 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -2311,6 +2311,9 @@ 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;

Yeah, OK... And totally my fault! I think, I, personally, am done
with the "remove if" patches at this point, they are too painful.

Alexey, is there anything else we missed?

FWIW,
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>

Andrew,
The allocation in question should be of a "too small to fail"
size, below PAGE_ALLOC_COSTLY_ORDER. So unless that unspoken
rule has changed, we should be "fine", since that kmalloc()
simply should not fail. It still makes sense to have that
particular check in place, just in case. Can you please pull
this patch in? And, like I said, I'm going to NAK all future
micro-optimizations.

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

end of thread, other threads:[~2022-10-13 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13 11:28 [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check Alexey Romanov
2022-10-13 12:34 ` Sergey Senozhatsky

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).