Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp166221rwl; Fri, 24 Mar 2023 23:34:02 -0700 (PDT) X-Google-Smtp-Source: AKy350ZpKZ7Ppt/v5I4ZU+NvO5WBeX+OOBLFkw3yeI9dbDF99nSvlI3kNS+q+PlRI8oTw505DPB0 X-Received: by 2002:a17:906:cb98:b0:931:73d:4cc3 with SMTP id mf24-20020a170906cb9800b00931073d4cc3mr5558578ejb.11.1679726042455; Fri, 24 Mar 2023 23:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679726042; cv=none; d=google.com; s=arc-20160816; b=HsQ3pGeYQCSXtx9uOUzauFFla5PO/Q6k6DJ1DdaX/QFVNrKbWFQU7xuJfps6+E7Nmc ruFsFXJPQ406tLrA5VQIB/0BDbS/sQwCiwRHDdBY9rVFNYA3l8e3oqqnQT3niUQlOSkc XMbF4kPoJrO69ZMs7rOSxxDh4vmBadKyZvE77cobWyrxSp95Qf0zvG88gq25XyYIPW2S +mERlYuTSOpSpXDzogFQYYIYMwmsZuuYEoUMlFct7u2AnUgjyIBF+VrVq1YuXwl1TrtL ZihvvtDZOYhzWySzcp0JXG+MDMTmXPZQyXssrApndg7yvIUABSjnsQkgPOPPZYdHDky8 ZZGw== 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; bh=OS250J6TXvkToKRxclBAM04Jr9676l/aHHCd5o+9dwY=; b=YUgnGZlSCzFG7F7aXjnhl0Aegka972N8ZgcT23klMOIFhVR0WLUp2vJjeQ/Wu+CXnA qhRligJjPeyVVGc74CuMJBA8vpqBj/DLkzX2OFjdXAYHRJq5H7wCE61Qswr3NuSlhbQz 6ayjw8EM+7obZ8qqNBWso60Ya2jDVUZ3WGqOe0gU4vaA7l7GpTMWePUY3qDWFvCT6m3h yrEDRY5VQcg5i3Ce+wCtZXsjB41h6m9+eAlyvx3xs9eR54so9e5pXuGAXcxB6KTtGRm1 E+JuRjGBJS8kmVQ2/Aus9g+wuIJ0nbFXjb3mbWBSI7FlVzrLPQp2B5/5co5EYYBewS+C N9Ew== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a170906070900b0093117deb464si23919749ejb.88.2023.03.24.23.33.37; Fri, 24 Mar 2023 23:34:02 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232233AbjCYGYn (ORCPT + 99 others); Sat, 25 Mar 2023 02:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbjCYGYb (ORCPT ); Sat, 25 Mar 2023 02:24:31 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1FA1517B for ; Fri, 24 Mar 2023 23:24:26 -0700 (PDT) Received: from dggpemm100009.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Pk8941xq1znY0n; Sat, 25 Mar 2023 14:21:12 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Sat, 25 Mar 2023 14:24:22 +0800 From: Liu Shixin To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , Christoph Hellwig CC: , , Liu Shixin Subject: [PATCH -next v7 2/4] mm/zswap: skip invalid or unchanged parameter Date: Sat, 25 Mar 2023 15:14:18 +0800 Message-ID: <20230325071420.2246461-3-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230325071420.2246461-1-liushixin2@huawei.com> References: <20230325071420.2246461-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 If parameter is invalid or no change required, return directly. This can reduces unnecessary printing. Signed-off-by: Liu Shixin --- mm/zswap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 6d2b879f091e..d2adc1ffe47d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -761,15 +761,15 @@ static int __zswap_param_set(const char *val, const struct kernel_param *kp, char *s = strstrip((char *)val); int ret; + /* no change required */ + if (!strcmp(s, *(char **)kp->arg) && zswap_has_pool) + return 0; + if (zswap_init_failed) { pr_err("can't set param, initialization failed\n"); return -ENODEV; } - /* no change required */ - if (!strcmp(s, *(char **)kp->arg) && zswap_has_pool) - return 0; - /* if this is load-time (pre-init) param setting, * don't create a pool; that's done during init. */ @@ -864,6 +864,15 @@ static int zswap_zpool_param_set(const char *val, static int zswap_enabled_param_set(const char *val, const struct kernel_param *kp) { + bool res; + + if (kstrtobool(val, &res)) + return -EINVAL; + + /* no change required */ + if (res == *(bool *)kp->arg) + return 0; + if (zswap_init_failed) { pr_err("can't enable, initialization failed\n"); return -ENODEV; -- 2.25.1