From patchwork Sat Mar 25 07:14:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 74830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp237438vqo; Fri, 24 Mar 2023 23:36:08 -0700 (PDT) X-Google-Smtp-Source: AK7set9k55PjmGa77kSo6GGx7WQ4X5EE5GBa0zsTsJE1Bv6RB99HAEiSUA8oF5oO48Og83mRIW09 X-Received: by 2002:a05:6a20:7a92:b0:dd:b941:5d99 with SMTP id u18-20020a056a207a9200b000ddb9415d99mr5080979pzh.51.1679726168462; Fri, 24 Mar 2023 23:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679726168; cv=none; d=google.com; s=arc-20160816; b=cUR8iSeQYmaPYBcqUCvUB9sMhSD3Ny4y9NCdaQqEUIsYfQZ8tjVvd99G9N6IxBunB1 DQZlzc6kFDW/pTjAQe+WChD3GAUanyZ8B/jqgfcV/7UGs0XaPt0aI4O7M6dbnBa9mAFd DEELoLyM26LPtunLX599l3mD6HdK2lvcN3lItOWxYUQORjordJC1c8vH1nZqErCNlVLz ivRpkUC+jWGsjjLBNOTdVzhCB3KBGiP3FqpMDaS8fcru/pfff327GKrkRij9CHf38Qqe +Hpy02EZuD2a+4XhpklBybEtK1Ux5Ny7QH6ym9xmA1Fn6U+C8xTf+K3fATEpZn1mbQa+ T2zA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f204-20020a6238d5000000b0062a4fb857easi5360053pfa.366.2023.03.24.23.35.56; Fri, 24 Mar 2023 23:36:08 -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 S232240AbjCYGYn (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761320546652496667?= X-GMAIL-MSGID: =?utf-8?q?1761320546652496667?= 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;