linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	Alexey Romanov <avromanov@sberdevices.ru>
Cc: minchan@kernel.org, senozhatsky@chromium.org, ngupta@vflare.org,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, kernel@sberdevices.ru
Subject: Re: [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check
Date: Thu, 13 Oct 2022 21:34:29 +0900	[thread overview]
Message-ID: <Y0gF1S4bjjNIE/68@google.com> (raw)
In-Reply-To: <20221013112825.61869-1-avromanov@sberdevices.ru>

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.


           reply	other threads:[~2022-10-13 12:34 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20221013112825.61869-1-avromanov@sberdevices.ru>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y0gF1S4bjjNIE/68@google.com \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=avromanov@sberdevices.ru \
    --cc=kernel@sberdevices.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox