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: 13187625 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC3D2C6FD20 for ; Sat, 25 Mar 2023 06:24:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0276F6B0088; Sat, 25 Mar 2023 02:24:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF23E900002; Sat, 25 Mar 2023 02:24:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6AC56B008A; Sat, 25 Mar 2023 02:24:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C678E6B0088 for ; Sat, 25 Mar 2023 02:24:33 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9DE8E1A00E9 for ; Sat, 25 Mar 2023 06:24:33 +0000 (UTC) X-FDA: 80606431626.29.97D8963 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf30.hostedemail.com (Postfix) with ESMTP id E0FA280002 for ; Sat, 25 Mar 2023 06:24:30 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679725471; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OS250J6TXvkToKRxclBAM04Jr9676l/aHHCd5o+9dwY=; b=yEAUaK8piA6Y8mzW4kK5nkOg/TxUczW7J4AUn6aMmE4jzOubGRlS66VvgU/1zTx8WY01rq 1GlJFMCssR3wuqie1AhILfhP5rY+oCVbRyhcUHmR1xbV7KezoqEEYiKYp/fwppxYN4lQV2 GcnFWyVB7ECMuwmQruTVRYT7Mgji184= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679725471; a=rsa-sha256; cv=none; b=sYbLIqt8bQ6ahD7Xd2CGWKDX8FsMujy3qA1WO32gkHSoDFpQS75CpBq+I63r1cqbCT/n8s N8nG9MbPNKfD4H3CuyxdlJV8XKsGMqWZ9yAcENLSVf3BU3ZwMDKH4uPWNrYbIjaFbWdF6K eclor32aXCoFQGZM5ePUaIy+Y7J4bGw= 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E0FA280002 X-Stat-Signature: uhc1j1gzwp81dxxuhm5tn83zsu9draz4 X-Rspam-User: X-HE-Tag: 1679725470-627801 X-HE-Meta: U2FsdGVkX1+D0Ccv00ZODqrZVpR9HMSQRZDhfYFr8tTiijabc2Eaff6ifAT+YMnfb6CPdooPCbHP90u2t9xzKPs6VK+el0QBU9uUoKiI1h3oIdSSLrgvvoGjXg4z+RHAwDp0DQmRN2LfxdU4zU0zudI7D9ELQ6O/Zsd5vGKWMUIsZBuNFRo75HeiJ5R8cBRG1KOIj0X31EcjoQI/9XewvK2XTXxxIAJwJu6Ma/0bS5JyO1ICnmxVR6Zz55fX+LwEGN1Kk+kK7sV3osydP7atCzN7rs2sVD/pramKzd/F+svlDf7YF0QmXY1JB4B2HiH2JqIsjmQAFhZZCrpTC8+SjjwnNDEYGaNUZj1ednfD1O6Z866B5UgqQAcoBhMz5/WxnzFbK2wsM1sSK+202uqF3ulxOp8LVlZlrOY0xS3hyfU2H017iXC6CpLx7fEpMOdcgTxIe0fUN/5TQ5QV9vneVVjGnfKsBuEw4XW+HaCGWaHRWDrKxsMhYx+0/zvUO+DZN/AzwzJjv/UIC4k0AhcUxCn+s+N5DoRN2awTGw6eeXkhMgLVb/tG+sFLpFog/0bsSrwXyFA2Vw5A4lfRTRW2+aqxhR69ve3u3hsrV+PwiPkgWxLa06JH+YI2lmibAkhGdxmArfZVlkAFl0eUz8KVdoyctRwScXuZ5QW7EVylUrWBXVg+ugenFdy3hH57VuY8PfAIidHF28B7dIbPzoq/CjOdo/7gemn7g5ZxlMKGdWiSQCqoxsrTI1Xx68KG3yQ72fzSO+cLXTlNQt6ZsH1gskxWedfwIPFi65cxsy0t9rAblb9jeP+LCI3GX6vWKRP90nkVN8COnEvUjwqcF4t/doH/WndlgPKVXOPPzLFqQYD5b8LxP250oF5SCVomyR0Z14SJtzcMKVlNB97UuqdJQtmcrEXiwszxW/4ArGWru1Lte7A0eBPQOXwjrHl+7fYRH41vwujqXSUPtFy/dW1 6oEG6mw3 /y86J0RtivBHhkP02XUyyHKt7zvVyzGUCitifk28Eg2zS9AJ+ltVKQj1occXMRt47ws5hJKai/XFZSGuhnmx+Fb1TERCuJ6qnpW0JAe3+J35a4O0dbvjCIKqNB7FYgSUg7Vkv2aejWP4tvfgdf+a9Phxbb01RN2d5V822 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;