All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/5] Delay the initializaton of zswap
@ 2022-09-15  3:49 Liu Shixin
  2022-09-15  3:49 ` [PATCH v5 1/5] Revert "mm: mark swap_lock and swap_active_head static" Liu Shixin
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-15  3:49 UTC (permalink / raw)
  To: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

In the initialization of zswap, about 18MB memory will be allocated for       
zswap_pool. Since not all users use zswap, the memory may be wasted. Save  
the memory for these users by delaying the initialization of zswap to         
first enablement.                                                             

v4->v5: Rebase on next-20220913, the previous first patch is superseded
by patch ("frontswap: don't call ->init if no ops are registered").
v3->v4: Revert three patches to replace previous patch[1-2] suggested by
Vitaly.
v2->v3: Fix frontswap_ops NULL reported by Nathan and add init for online
swap device in backend register.
v1->v2: Change init_zswap to zswap_init suggested by Andrew.

Liu Shixin (5):
  Revert "mm: mark swap_lock and swap_active_head static"
  Revert "frontswap: simplify frontswap_register_ops"
  mm/zswap: replace zswap_init_{started/failed} with zswap_init_state
  mm/zswap: delay the initializaton of zswap until the first enablement
  mm/zswap: skip confusing print info

 include/linux/swapfile.h |  2 ++
 mm/frontswap.c           | 42 ++++++++++++++++++++++
 mm/swapfile.c            |  4 +--
 mm/zswap.c               | 77 ++++++++++++++++++++++++++++++----------
 4 files changed, 104 insertions(+), 21 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v5 1/5] Revert "mm: mark swap_lock and swap_active_head static"
  2022-09-15  3:49 [PATCH v5 0/5] Delay the initializaton of zswap Liu Shixin
@ 2022-09-15  3:49 ` Liu Shixin
  2022-09-15  3:50 ` [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops" Liu Shixin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-15  3:49 UTC (permalink / raw)
  To: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

This reverts commit 633423a09cb5cfe61438283e1ce49c23cf4a0611.

swap_lock and swap_active_head will be used in next patch, so export it
again.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 include/linux/swapfile.h | 2 ++
 mm/swapfile.c            | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/swapfile.h b/include/linux/swapfile.h
index 7ed529a77c5b..a2540b8396e2 100644
--- a/include/linux/swapfile.h
+++ b/include/linux/swapfile.h
@@ -6,6 +6,8 @@
  * these were static in swapfile.c but frontswap.c needs them and we don't
  * want to expose them to the dozens of source files that include swap.h
  */
+extern spinlock_t swap_lock;
+extern struct plist_head swap_active_head;
 extern struct swap_info_struct *swap_info[];
 extern unsigned long generic_max_swapfile_size(void);
 unsigned long arch_max_swapfile_size(void);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 4efcfe34e45b..6cdb34c01dd3 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -51,7 +51,7 @@ static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
 				 unsigned char);
 static void free_swap_count_continuations(struct swap_info_struct *);
 
-static DEFINE_SPINLOCK(swap_lock);
+DEFINE_SPINLOCK(swap_lock);
 static unsigned int nr_swapfiles;
 atomic_long_t nr_swap_pages;
 /*
@@ -77,7 +77,7 @@ static const char Unused_offset[] = "Unused swap offset entry ";
  * all active swap_info_structs
  * protected with swap_lock, and ordered by priority.
  */
-static PLIST_HEAD(swap_active_head);
+PLIST_HEAD(swap_active_head);
 
 /*
  * all available (active, not full) swap_info_structs
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops"
  2022-09-15  3:49 [PATCH v5 0/5] Delay the initializaton of zswap Liu Shixin
  2022-09-15  3:49 ` [PATCH v5 1/5] Revert "mm: mark swap_lock and swap_active_head static" Liu Shixin
@ 2022-09-15  3:50 ` Liu Shixin
  2022-09-20 12:13   ` Christoph Hellwig
  2022-09-15  3:50 ` [PATCH v5 3/5] mm/zswap: replace zswap_init_{started/failed} with zswap_init_state Liu Shixin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Liu Shixin @ 2022-09-15  3:50 UTC (permalink / raw)
  To: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

This reverts commit f328c1d16e4c764992895ac9c9425cea861b2ca0.

Since we are supported to delay zswap initializaton, we need to invoke
ops->init for the swap device which is already online when register
backend.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/frontswap.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/mm/frontswap.c b/mm/frontswap.c
index 279e55b4ed87..aa3a1e3ddf91 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -96,11 +96,53 @@ static inline void inc_frontswap_invalidates(void) { }
  */
 int frontswap_register_ops(const struct frontswap_ops *ops)
 {
+	DECLARE_BITMAP(a, MAX_SWAPFILES);
+	DECLARE_BITMAP(b, MAX_SWAPFILES);
+	struct swap_info_struct *si;
+	unsigned int i;
+
 	if (frontswap_ops)
 		return -EINVAL;
 
+	bitmap_zero(a, MAX_SWAPFILES);
+	bitmap_zero(b, MAX_SWAPFILES);
+
+	spin_lock(&swap_lock);
+	plist_for_each_entry(si, &swap_active_head, list) {
+		if (!WARN_ON(!si->frontswap_map))
+			__set_bit(si->type, a);
+	}
+	spin_unlock(&swap_lock);
+
+	/* the new ops needs to know the currently active swap devices */
+	for_each_set_bit(i, a, MAX_SWAPFILES)
+		ops->init(i);
+
 	frontswap_ops = ops;
 	static_branch_inc(&frontswap_enabled_key);
+
+	spin_lock(&swap_lock);
+	plist_for_each_entry(si, &swap_active_head, list) {
+		if (si->frontswap_map)
+			__set_bit(si->type, b);
+	}
+	spin_unlock(&swap_lock);
+
+	/*
+	 * On the very unlikely chance that a swap device was added or
+	 * removed between setting the "a" list bits and the ops init
+	 * calls, we re-check and do init or invalidate for any changed
+	 * bits.
+	 */
+	if (unlikely(!bitmap_equal(a, b, MAX_SWAPFILES))) {
+		for (i = 0; i < MAX_SWAPFILES; i++) {
+			if (!test_bit(i, a) && test_bit(i, b))
+				ops->init(i);
+			else if (test_bit(i, a) && !test_bit(i, b))
+				ops->invalidate_area(i);
+		}
+	}
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 3/5] mm/zswap: replace zswap_init_{started/failed} with zswap_init_state
  2022-09-15  3:49 [PATCH v5 0/5] Delay the initializaton of zswap Liu Shixin
  2022-09-15  3:49 ` [PATCH v5 1/5] Revert "mm: mark swap_lock and swap_active_head static" Liu Shixin
  2022-09-15  3:50 ` [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops" Liu Shixin
@ 2022-09-15  3:50 ` Liu Shixin
  2022-09-15  3:50 ` [PATCH v5 4/5] mm/zswap: delay the initializaton of zswap until the first enablement Liu Shixin
  2022-09-15  3:50 ` [PATCH v5 5/5] mm/zswap: skip confusing print info Liu Shixin
  4 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-15  3:50 UTC (permalink / raw)
  To: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

zswap_init_started indicates that the initialization is started. And
zswap_init_failed indicates that the initialization is failed. As we will
support to init zswap after system startup, it's necessary to add a state
to indicate the initialization is complete and succeed to avoid
concurrency issues. Since we don't care about the difference between
init started with init completion. We only need three states:
uninitialized, initial failed, initial succeed.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/zswap.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index 2d48fd59cc7a..84e38300f571 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -214,11 +214,12 @@ static DEFINE_SPINLOCK(zswap_pools_lock);
 /* pool counter to provide unique names to zpool */
 static atomic_t zswap_pools_count = ATOMIC_INIT(0);
 
-/* used by param callback function */
-static bool zswap_init_started;
+#define ZSWAP_UNINIT		0
+#define ZSWAP_INIT_SUCCEED	1
+#define ZSWAP_INIT_FAILED	2
 
-/* fatal error during init */
-static bool zswap_init_failed;
+/* init state */
+static int zswap_init_state;
 
 /* init completed, but couldn't create the initial pool */
 static bool zswap_has_pool;
@@ -772,7 +773,7 @@ static int __zswap_param_set(const char *val, const struct kernel_param *kp,
 	char *s = strstrip((char *)val);
 	int ret;
 
-	if (zswap_init_failed) {
+	if (zswap_init_state == ZSWAP_INIT_FAILED) {
 		pr_err("can't set param, initialization failed\n");
 		return -ENODEV;
 	}
@@ -784,7 +785,7 @@ static int __zswap_param_set(const char *val, const struct kernel_param *kp,
 	/* if this is load-time (pre-init) param setting,
 	 * don't create a pool; that's done during init.
 	 */
-	if (!zswap_init_started)
+	if (zswap_init_state == ZSWAP_UNINIT)
 		return param_set_charp(s, kp);
 
 	if (!type) {
@@ -875,11 +876,11 @@ static int zswap_zpool_param_set(const char *val,
 static int zswap_enabled_param_set(const char *val,
 				   const struct kernel_param *kp)
 {
-	if (zswap_init_failed) {
+	if (zswap_init_state == ZSWAP_INIT_FAILED) {
 		pr_err("can't enable, initialization failed\n");
 		return -ENODEV;
 	}
-	if (!zswap_has_pool && zswap_init_started) {
+	if (!zswap_has_pool && zswap_init_state == ZSWAP_INIT_SUCCEED) {
 		pr_err("can't enable, no pool configured\n");
 		return -ENODEV;
 	}
@@ -1476,8 +1477,6 @@ static int __init init_zswap(void)
 	struct zswap_pool *pool;
 	int ret;
 
-	zswap_init_started = true;
-
 	if (zswap_entry_cache_create()) {
 		pr_err("entry cache creation failed\n");
 		goto cache_fail;
@@ -1517,6 +1516,7 @@ static int __init init_zswap(void)
 		goto destroy_wq;
 	if (zswap_debugfs_init())
 		pr_warn("debugfs initialization failed\n");
+	zswap_init_state = ZSWAP_INIT_SUCCEED;
 	return 0;
 
 destroy_wq:
@@ -1530,7 +1530,7 @@ static int __init init_zswap(void)
 	zswap_entry_cache_destroy();
 cache_fail:
 	/* if built-in, we aren't unloaded on failure; don't allow use */
-	zswap_init_failed = true;
+	zswap_init_state = ZSWAP_INIT_FAILED;
 	zswap_enabled = false;
 	return -ENOMEM;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 4/5] mm/zswap: delay the initializaton of zswap until the first enablement
  2022-09-15  3:49 [PATCH v5 0/5] Delay the initializaton of zswap Liu Shixin
                   ` (2 preceding siblings ...)
  2022-09-15  3:50 ` [PATCH v5 3/5] mm/zswap: replace zswap_init_{started/failed} with zswap_init_state Liu Shixin
@ 2022-09-15  3:50 ` Liu Shixin
  2022-09-15  3:50 ` [PATCH v5 5/5] mm/zswap: skip confusing print info Liu Shixin
  4 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-15  3:50 UTC (permalink / raw)
  To: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

In the initialization of zswap, about 18MB memory will be allocated for
zswap_pool in my machine. Since not all users use zswap, the memory may be
wasted. Save the memory for these users by delaying the initialization of
zswap to first enablement.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/zswap.c | 50 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index 84e38300f571..4c476c463035 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -81,6 +81,8 @@ static bool zswap_pool_reached_full;
 
 #define ZSWAP_PARAM_UNSET ""
 
+static int zswap_setup(void);
+
 /* Enable/disable zswap */
 static bool zswap_enabled = IS_ENABLED(CONFIG_ZSWAP_DEFAULT_ON);
 static int zswap_enabled_param_set(const char *,
@@ -220,6 +222,8 @@ static atomic_t zswap_pools_count = ATOMIC_INIT(0);
 
 /* init state */
 static int zswap_init_state;
+/* used to ensure the integrity of initialization */
+static DEFINE_MUTEX(zswap_init_lock);
 
 /* init completed, but couldn't create the initial pool */
 static bool zswap_has_pool;
@@ -273,13 +277,13 @@ static void zswap_update_total_size(void)
 **********************************/
 static struct kmem_cache *zswap_entry_cache;
 
-static int __init zswap_entry_cache_create(void)
+static int zswap_entry_cache_create(void)
 {
 	zswap_entry_cache = KMEM_CACHE(zswap_entry, 0);
 	return zswap_entry_cache == NULL;
 }
 
-static void __init zswap_entry_cache_destroy(void)
+static void zswap_entry_cache_destroy(void)
 {
 	kmem_cache_destroy(zswap_entry_cache);
 }
@@ -664,7 +668,7 @@ static struct zswap_pool *zswap_pool_create(char *type, char *compressor)
 	return NULL;
 }
 
-static __init struct zswap_pool *__zswap_pool_create_fallback(void)
+static struct zswap_pool *__zswap_pool_create_fallback(void)
 {
 	bool has_comp, has_zpool;
 
@@ -782,11 +786,17 @@ static int __zswap_param_set(const char *val, const struct kernel_param *kp,
 	if (!strcmp(s, *(char **)kp->arg) && zswap_has_pool)
 		return 0;
 
-	/* if this is load-time (pre-init) param setting,
+	/*
+	 * if zswap has not been initialized,
 	 * don't create a pool; that's done during init.
 	 */
-	if (zswap_init_state == ZSWAP_UNINIT)
-		return param_set_charp(s, kp);
+	mutex_lock(&zswap_init_lock);
+	if (zswap_init_state == ZSWAP_UNINIT) {
+		ret = param_set_charp(s, kp);
+		mutex_unlock(&zswap_init_lock);
+		return ret;
+	}
+	mutex_unlock(&zswap_init_lock);
 
 	if (!type) {
 		if (!zpool_has_pool(s)) {
@@ -876,6 +886,14 @@ static int zswap_zpool_param_set(const char *val,
 static int zswap_enabled_param_set(const char *val,
 				   const struct kernel_param *kp)
 {
+	if (system_state == SYSTEM_RUNNING) {
+		mutex_lock(&zswap_init_lock);
+		if (zswap_setup()) {
+			mutex_unlock(&zswap_init_lock);
+			return -ENODEV;
+		}
+		mutex_unlock(&zswap_init_lock);
+	}
 	if (zswap_init_state == ZSWAP_INIT_FAILED) {
 		pr_err("can't enable, initialization failed\n");
 		return -ENODEV;
@@ -1432,7 +1450,7 @@ static const struct frontswap_ops zswap_frontswap_ops = {
 
 static struct dentry *zswap_debugfs_root;
 
-static int __init zswap_debugfs_init(void)
+static int zswap_debugfs_init(void)
 {
 	if (!debugfs_initialized())
 		return -ENODEV;
@@ -1463,7 +1481,7 @@ static int __init zswap_debugfs_init(void)
 	return 0;
 }
 #else
-static int __init zswap_debugfs_init(void)
+static int zswap_debugfs_init(void)
 {
 	return 0;
 }
@@ -1472,11 +1490,14 @@ static int __init zswap_debugfs_init(void)
 /*********************************
 * module init and exit
 **********************************/
-static int __init init_zswap(void)
+static int zswap_setup(void)
 {
 	struct zswap_pool *pool;
 	int ret;
 
+	if (zswap_init_state != ZSWAP_UNINIT)
+		return 0;
+
 	if (zswap_entry_cache_create()) {
 		pr_err("entry cache creation failed\n");
 		goto cache_fail;
@@ -1534,8 +1555,17 @@ static int __init init_zswap(void)
 	zswap_enabled = false;
 	return -ENOMEM;
 }
+
+static int __init zswap_init(void)
+{
+	/* skip init if zswap is disabled when system startup */
+	if (!zswap_enabled)
+		return 0;
+	return zswap_setup();
+}
+
 /* must be late so crypto has time to come up */
-late_initcall(init_zswap);
+late_initcall(zswap_init);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Seth Jennings <sjennings@variantweb.net>");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 5/5] mm/zswap: skip confusing print info
  2022-09-15  3:49 [PATCH v5 0/5] Delay the initializaton of zswap Liu Shixin
                   ` (3 preceding siblings ...)
  2022-09-15  3:50 ` [PATCH v5 4/5] mm/zswap: delay the initializaton of zswap until the first enablement Liu Shixin
@ 2022-09-15  3:50 ` Liu Shixin
  4 siblings, 0 replies; 11+ messages in thread
From: Liu Shixin @ 2022-09-15  3:50 UTC (permalink / raw)
  To: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig
  Cc: linux-mm, linux-kernel, Liu Shixin, Kefeng Wang

It's confusing when we disable zswap while zswap is init failed or has no
pool. If no change required, just return directly.

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

diff --git a/mm/zswap.c b/mm/zswap.c
index 4c476c463035..ef7463550e49 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -886,6 +886,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 (system_state == SYSTEM_RUNNING) {
 		mutex_lock(&zswap_init_lock);
 		if (zswap_setup()) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops"
  2022-09-15  3:50 ` [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops" Liu Shixin
@ 2022-09-20 12:13   ` Christoph Hellwig
  2022-09-21  1:42     ` Liu Shixin
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2022-09-20 12:13 UTC (permalink / raw)
  To: Liu Shixin
  Cc: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, Christoph Hellwig, linux-mm, linux-kernel,
	Kefeng Wang

On Thu, Sep 15, 2022 at 11:50:00AM +0800, Liu Shixin wrote:
> This reverts commit f328c1d16e4c764992895ac9c9425cea861b2ca0.
> 
> Since we are supported to delay zswap initializaton, we need to invoke
> ops->init for the swap device which is already online when register
> backend.

Why do we "have" to do it.  Retroactively supporting functionality on
previously enabled swap devices seems rather odd, and the amount of
cruft added for it here absolutely does not seem to be worth it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops"
  2022-09-20 12:13   ` Christoph Hellwig
@ 2022-09-21  1:42     ` Liu Shixin
  2022-09-27  7:27       ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Liu Shixin @ 2022-09-21  1:42 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, linux-mm, linux-kernel, Kefeng Wang

On 2022/9/20 20:13, Christoph Hellwig wrote:

> On Thu, Sep 15, 2022 at 11:50:00AM +0800, Liu Shixin wrote:
>> This reverts commit f328c1d16e4c764992895ac9c9425cea861b2ca0.
>>
>> Since we are supported to delay zswap initializaton, we need to invoke
>> ops->init for the swap device which is already online when register
>> backend.
> Why do we "have" to do it.  Retroactively supporting functionality on
> previously enabled swap devices seems rather odd, and the amount of
> cruft added for it here absolutely does not seem to be worth it.
Hi Christoph,

This revert makes code complicated, but I think it's necessary. When enable zswap,
I expect it to work for all swap devices as much as possible. In this way, user can enable
zswap and swap device in any order. Since we can enable zswap on previously swap
devices, why not support it to get such benifit?

Thanks,
> .
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops"
  2022-09-21  1:42     ` Liu Shixin
@ 2022-09-27  7:27       ` Christoph Hellwig
  2022-09-27 11:12         ` Liu Shixin
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2022-09-27  7:27 UTC (permalink / raw)
  To: Liu Shixin
  Cc: Christoph Hellwig, Seth Jennings, Dan Streetman, Vitaly Wool,
	Andrew Morton, Nathan Chancellor, linux-mm, linux-kernel,
	Kefeng Wang

On Wed, Sep 21, 2022 at 09:42:41AM +0800, Liu Shixin wrote:
> This revert makes code complicated, but I think it's necessary. When
> enable zswap, I expect it to work for all swap devices as much as
> possible.

But why would expect something to work on a device that has been
swapped on before?  That's not usually how things work.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops"
  2022-09-27  7:27       ` Christoph Hellwig
@ 2022-09-27 11:12         ` Liu Shixin
  2022-09-27 12:31           ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Liu Shixin @ 2022-09-27 11:12 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Seth Jennings, Dan Streetman, Vitaly Wool, Andrew Morton,
	Nathan Chancellor, linux-mm, linux-kernel, Kefeng Wang



On 2022/9/27 15:27, Christoph Hellwig wrote:
> On Wed, Sep 21, 2022 at 09:42:41AM +0800, Liu Shixin wrote:
>> This revert makes code complicated, but I think it's necessary. When
>> enable zswap, I expect it to work for all swap devices as much as
>> possible.
> But why would expect something to work on a device that has been
> swapped on before?  That's not usually how things work.
>
> .
If not do this, while some user enable swap device first and then enable zswap,
zswap will not take effect. The user need to re-enable the swap device which is
inconvenient.
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops"
  2022-09-27 11:12         ` Liu Shixin
@ 2022-09-27 12:31           ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2022-09-27 12:31 UTC (permalink / raw)
  To: Liu Shixin
  Cc: Christoph Hellwig, Seth Jennings, Dan Streetman, Vitaly Wool,
	Andrew Morton, Nathan Chancellor, linux-mm, linux-kernel,
	Kefeng Wang

On Tue, Sep 27, 2022 at 07:12:58PM +0800, Liu Shixin wrote:
> If not do this, while some user enable swap device first and then enable zswap,
> zswap will not take effect. The user need to re-enable the swap device which is
> inconvenient.

So load the module before swapping on, just like you'd load any driver
before you expect to use it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-27 12:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  3:49 [PATCH v5 0/5] Delay the initializaton of zswap Liu Shixin
2022-09-15  3:49 ` [PATCH v5 1/5] Revert "mm: mark swap_lock and swap_active_head static" Liu Shixin
2022-09-15  3:50 ` [PATCH v5 2/5] Revert "frontswap: simplify frontswap_register_ops" Liu Shixin
2022-09-20 12:13   ` Christoph Hellwig
2022-09-21  1:42     ` Liu Shixin
2022-09-27  7:27       ` Christoph Hellwig
2022-09-27 11:12         ` Liu Shixin
2022-09-27 12:31           ` Christoph Hellwig
2022-09-15  3:50 ` [PATCH v5 3/5] mm/zswap: replace zswap_init_{started/failed} with zswap_init_state Liu Shixin
2022-09-15  3:50 ` [PATCH v5 4/5] mm/zswap: delay the initializaton of zswap until the first enablement Liu Shixin
2022-09-15  3:50 ` [PATCH v5 5/5] mm/zswap: skip confusing print info Liu Shixin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.