From nobody Sat Apr 11 12:46:21 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84807C19F2A for ; Thu, 11 Aug 2022 15:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236484AbiHKPnz (ORCPT ); Thu, 11 Aug 2022 11:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236385AbiHKPnl (ORCPT ); Thu, 11 Aug 2022 11:43:41 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AFC9F194 for ; Thu, 11 Aug 2022 08:38:09 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id BB5535FD07; Thu, 11 Aug 2022 18:38:07 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1660232287; bh=0ZPDUCDYt8cTM0IRDWEirHqaXpS1VqLDEtitynBVmKI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=NleaxToKuULRFvBgPvAtWzSeyDWx7rdHhn5tNxtUwAdMrJnm/hM9t65IeF9pgqkEc fWQucu+KVWt7bsECOLUzUDX7RnEqWpaz+BiLUac/KzfaQq/QQlC/9NS5EDkPu964m6 S4ViXrD4Bg6o1tenEnDT9Sueuk33ypMFhXEiNB6j/SwNRp5lC7mkY9fSlNS3/KqKy8 TArDFAvt3GEyihgu4iQjVaYbcSRhoBAwSeJ8Ajn6BAV2ygakX4Y5d4HUzwtTQKatPJ XJYoxWnTOhV8hh9pQbCuYZdeoDTTijPEiaDcURL4qvMMUbUQFKXCj9ruSjZOMj4971 itHl/wKsqktXA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Thu, 11 Aug 2022 18:38:07 +0300 (MSK) From: Alexey Romanov To: , , , CC: , , , Alexey Romanov Subject: [PATCH v1 2/2] zsmalloc: remove unnecessary size_class NULL check Date: Thu, 11 Aug 2022 18:37:55 +0300 Message-ID: <20220811153755.16102-3-avromanov@sberdevices.ru> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220811153755.16102-1-avromanov@sberdevices.ru> References: <20220811153755.16102-1-avromanov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH01.sberdevices.ru (172.16.1.4) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/08/11 13:20:00 #20096813 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- mm/zsmalloc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 5efa8c592193..f3cf0d0925a3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2154,8 +2154,6 @@ unsigned long zs_compact(struct zs_pool *pool) =20 for (i =3D ZS_SIZE_CLASSES - 1; i >=3D 0; i--) { class =3D pool->size_class[i]; - if (!class) - continue; if (class->index !=3D i) continue; pages_freed +=3D __zs_compact(pool, class); @@ -2200,8 +2198,6 @@ static unsigned long zs_shrinker_count(struct shrinke= r *shrinker, =20 for (i =3D ZS_SIZE_CLASSES - 1; i >=3D 0; i--) { class =3D pool->size_class[i]; - if (!class) - continue; if (class->index !=3D i) continue; =20 @@ -2361,9 +2357,6 @@ void zs_destroy_pool(struct zs_pool *pool) int fg; struct size_class *class =3D pool->size_class[i]; =20 - if (!class) - continue; - if (class->index !=3D i) continue; =20 --=20 2.30.1