[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230325071420.2246461-3-liushixin2@huawei.com>
Date: Sat, 25 Mar 2023 15:14:18 +0800
From: Liu Shixin <liushixin2@...wei.com>
To: Seth Jennings <sjenning@...hat.com>,
Dan Streetman <ddstreet@...e.org>,
Vitaly Wool <vitaly.wool@...sulko.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Nathan Chancellor <nathan@...nel.org>,
Christoph Hellwig <hch@....de>
CC: <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
Liu Shixin <liushixin2@...wei.com>
Subject: [PATCH -next v7 2/4] mm/zswap: skip invalid or unchanged parameter
If parameter is invalid or no change required, return directly. This can
reduces unnecessary printing.
Signed-off-by: Liu Shixin <liushixin2@...wei.com>
---
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
Powered by blists - more mailing lists