diff mbox series

[-next,v6,1/2] mm/zswap: skip invalid or unchanged parameter

Message ID 20230322102006.780624-2-liushixin2@huawei.com (mailing list archive)
State New
Headers show
Series Delay the initialization of zswap | expand

Commit Message

Liu Shixin March 22, 2023, 10:20 a.m. UTC
If parameter is invalid or no change required, return directly. This can
reduces unnecessary printing.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/zswap.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/mm/zswap.c b/mm/zswap.c
index 2f0ebd8bc620..09fa956920fa 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -875,6 +875,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;