Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2452913rwb; Mon, 15 Aug 2022 05:57:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR77yZFqfeOMPeZqFIJW4NVZBKkFRcTV/Ez3/BU6P7JdjEDXcR2EUqQVEtQiBcP0OfdwO6du X-Received: by 2002:a65:4381:0:b0:429:8c34:535e with SMTP id m1-20020a654381000000b004298c34535emr807821pgp.91.1660568230601; Mon, 15 Aug 2022 05:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660568230; cv=none; d=google.com; s=arc-20160816; b=fU17j6SEXZd0BRBl4tShrZ9xgMOi1wL+B8qGawrFag6bVRiB0kpk40Sgb1hQSgista 0GlsVOTbsWVt0e5mmUqYQX5vPFj20BHkZIpyVh5LLtiU9jNMsmiZhTgEOOux1i/PORSh GNjJKCia3CsoBYruz6noZ8eZbqgA4tsPnac8S+iWd0C9bZSQBBxHJzCtSco0UbvhWvxa gZrP96JKWCc9BhAuQDzsSJkTCCj1AEaAqP1lS382XlcVPdz1PMhLTNAd023JIWMHCR4P WX+uRyJG59VHN9csBssJZu5l019yzT/BC0AeDSsEja4/xoWo5c0r7fpN0eOS2mflL6i7 FuIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fBVh/aw8QffkdtBHi0zddHljlA6jQjejmkYNw6kN2NU=; b=O6KqZn6CYF6ERxn08nc+QEyzkSsHZWwS9ufbaoXs2j8riyZYO+sO/W26h/5hIDk5WV Lp4swR5kllso6WgBNMc3hiXBmtl9wDrS5qkzTrAE3MB0gcwXa0LCRLDT/jN6FI6XcgZ8 M5J3qS3o1UvYGTeoQmpZimpRFetopf9KoIyZlgheALeaXPeFtDF3vkAUfA2zdM96jFMP Fim9AhT96HLBfy8s3sIl3iT3UG/Q6O1VBv/d42E/8sWNHizXCGJcVnqncUZgA61+C/0Y Uur5ZwvfvCa8UlZ4u67u3a9lbIt4dMEjMERWsA0+XSjjDZw/x36ne5G7tQ75MGNoijfB Kx1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=W6VOknYi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3-20020a655ac3000000b0041d35693195si10686431pgt.67.2022.08.15.05.56.59; Mon, 15 Aug 2022 05:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=W6VOknYi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241837AbiHOMjx (ORCPT + 99 others); Mon, 15 Aug 2022 08:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241597AbiHOMjp (ORCPT ); Mon, 15 Aug 2022 08:39:45 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1DDA23BCF for ; Mon, 15 Aug 2022 05:39:44 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id ACC6F5FD0A; Mon, 15 Aug 2022 15:39:42 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1660567182; bh=fBVh/aw8QffkdtBHi0zddHljlA6jQjejmkYNw6kN2NU=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=W6VOknYiE5IYltYzNXgPI6YDTGjf9Pz4s+WTaXdrUJTeS6ZbTyo/KOrNPKf2cHqwl DvUEQKY5gsuzsnQiUpOs09qy0/gR/nldMGgYBTZPmm9Ba0BgbkEUVnsqzQJl/MkHqQ CjXx0CarpjLWka7xXPo2vzxaNJ5KSg67drV35clpl7W2u1S/98NNztTavbmkziLFKe qbdTK0juTk8JBmsgis8VNflZ8oLmyXly+ZZR+eeTfyAawwQtoOPklg8BBxzy72bCGF DBnJ7JakXmumIcgtniCCXbMsMGkEfHhrL79mWGQEdQp06Ftf3K4aNIdLy5jRMADms1 EEtnHBdv0XVag== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 15 Aug 2022 15:39:42 +0300 (MSK) From: Alexey Romanov To: , , , CC: , , , Alexey Romanov Subject: [PATCH v2 2/2] zsmalloc: remove unnecessary size_class NULL check Date: Mon, 15 Aug 2022 15:39:30 +0300 Message-ID: <20220815123930.37736-3-avromanov@sberdevices.ru> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220815123930.37736-1-avromanov@sberdevices.ru> References: <20220815123930.37736-1-avromanov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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/15 08:42:00 #20120161 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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