All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: zswap: add runtime enable/disable
@ 2013-07-22 19:34 ` Seth Jennings
  0 siblings, 0 replies; 10+ messages in thread
From: Seth Jennings @ 2013-07-22 19:34 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Seth Jennings, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

Right now, zswap can only be enabled at boot time.  This patch
modifies zswap so that it can be dynamically enabled or disabled
at runtime.

In order to allow this ability, zswap unconditionally registers as a
frontswap backend regardless of whether or not zswap.enabled=1 is passed
in the boot parameters or not.  This introduces a very small overhead
for systems that have zswap disabled as calls to frontswap_store() will
call zswap_frontswap_store(), but there is a fast path to immediately
return if zswap is disabled.

Disabling zswap does not unregister zswap from frontswap.  It simply
blocks all future stores.

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 Documentation/vm/zswap.txt | 18 ++++++++++++++++--
 mm/zswap.c                 |  9 +++------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
index 7e492d8..d588477 100644
--- a/Documentation/vm/zswap.txt
+++ b/Documentation/vm/zswap.txt
@@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
 device when the compressed pool reaches it size limit.  This requirement had
 been identified in prior community discussions.
 
-To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
-zswap.enabled=1
+Zswap is disabled by default but can be enabled at boot time by setting
+the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
+can also be enabled and disabled at runtime using the sysfs interface.
+An exmaple command to enable zswap at runtime, assuming sysfs is mounted
+at /sys, is:
+
+echo 1 > /sys/modules/zswap/parameters/enabled
+
+When zswap is disabled at runtime, it will stop storing pages that are
+being swapped out.  However, it will _not_ immediately write out or
+fault back into memory all of the pages stored in the compressed pool.
+The pages stored in zswap will continue to remain in the compressed pool
+until they are either invalidated or faulted back into memory.  In order
+to force all pages out of the compressed pool, a swapoff on the swap
+device(s) will fault all swapped out pages, included those in the
+compressed pool, back into memory.
 
 Design:
 
diff --git a/mm/zswap.c b/mm/zswap.c
index deda2b6..199b1b0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -75,9 +75,9 @@ static u64 zswap_duplicate_entry;
 /*********************************
 * tunables
 **********************************/
-/* Enable/disable zswap (disabled by default, fixed at boot for now) */
+/* Enable/disable zswap (disabled by default) */
 static bool zswap_enabled __read_mostly;
-module_param_named(enabled, zswap_enabled, bool, 0);
+module_param_named(enabled, zswap_enabled, bool, 0644);
 
 /* Compressor to be used by zswap (fixed at boot for now) */
 #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
@@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
 	u8 *src, *dst;
 	struct zswap_header *zhdr;
 
-	if (!tree) {
+	if (!zswap_enabled || !tree) {
 		ret = -ENODEV;
 		goto reject;
 	}
@@ -908,9 +908,6 @@ static void __exit zswap_debugfs_exit(void) { }
 **********************************/
 static int __init init_zswap(void)
 {
-	if (!zswap_enabled)
-		return 0;
-
 	pr_info("loading zswap\n");
 	if (zswap_entry_cache_create()) {
 		pr_err("entry cache creation failed\n");
-- 
1.8.1.2


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

* [PATCH] mm: zswap: add runtime enable/disable
@ 2013-07-22 19:34 ` Seth Jennings
  0 siblings, 0 replies; 10+ messages in thread
From: Seth Jennings @ 2013-07-22 19:34 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Seth Jennings, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

Right now, zswap can only be enabled at boot time.  This patch
modifies zswap so that it can be dynamically enabled or disabled
at runtime.

In order to allow this ability, zswap unconditionally registers as a
frontswap backend regardless of whether or not zswap.enabled=1 is passed
in the boot parameters or not.  This introduces a very small overhead
for systems that have zswap disabled as calls to frontswap_store() will
call zswap_frontswap_store(), but there is a fast path to immediately
return if zswap is disabled.

Disabling zswap does not unregister zswap from frontswap.  It simply
blocks all future stores.

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 Documentation/vm/zswap.txt | 18 ++++++++++++++++--
 mm/zswap.c                 |  9 +++------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
index 7e492d8..d588477 100644
--- a/Documentation/vm/zswap.txt
+++ b/Documentation/vm/zswap.txt
@@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
 device when the compressed pool reaches it size limit.  This requirement had
 been identified in prior community discussions.
 
-To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
-zswap.enabled=1
+Zswap is disabled by default but can be enabled at boot time by setting
+the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
+can also be enabled and disabled at runtime using the sysfs interface.
+An exmaple command to enable zswap at runtime, assuming sysfs is mounted
+at /sys, is:
+
+echo 1 > /sys/modules/zswap/parameters/enabled
+
+When zswap is disabled at runtime, it will stop storing pages that are
+being swapped out.  However, it will _not_ immediately write out or
+fault back into memory all of the pages stored in the compressed pool.
+The pages stored in zswap will continue to remain in the compressed pool
+until they are either invalidated or faulted back into memory.  In order
+to force all pages out of the compressed pool, a swapoff on the swap
+device(s) will fault all swapped out pages, included those in the
+compressed pool, back into memory.
 
 Design:
 
diff --git a/mm/zswap.c b/mm/zswap.c
index deda2b6..199b1b0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -75,9 +75,9 @@ static u64 zswap_duplicate_entry;
 /*********************************
 * tunables
 **********************************/
-/* Enable/disable zswap (disabled by default, fixed at boot for now) */
+/* Enable/disable zswap (disabled by default) */
 static bool zswap_enabled __read_mostly;
-module_param_named(enabled, zswap_enabled, bool, 0);
+module_param_named(enabled, zswap_enabled, bool, 0644);
 
 /* Compressor to be used by zswap (fixed at boot for now) */
 #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
@@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
 	u8 *src, *dst;
 	struct zswap_header *zhdr;
 
-	if (!tree) {
+	if (!zswap_enabled || !tree) {
 		ret = -ENODEV;
 		goto reject;
 	}
@@ -908,9 +908,6 @@ static void __exit zswap_debugfs_exit(void) { }
 **********************************/
 static int __init init_zswap(void)
 {
-	if (!zswap_enabled)
-		return 0;
-
 	pr_info("loading zswap\n");
 	if (zswap_entry_cache_create()) {
 		pr_err("entry cache creation failed\n");
-- 
1.8.1.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
  2013-07-22 19:34 ` Seth Jennings
  (?)
@ 2013-07-22 23:25 ` Wanpeng Li
  2013-07-23 17:22   ` Seth Jennings
  -1 siblings, 1 reply; 10+ messages in thread
From: Wanpeng Li @ 2013-07-22 23:25 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Andrew Morton, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On Mon, Jul 22, 2013 at 02:34:02PM -0500, Seth Jennings wrote:
>Right now, zswap can only be enabled at boot time.  This patch
>modifies zswap so that it can be dynamically enabled or disabled
>at runtime.
>
>In order to allow this ability, zswap unconditionally registers as a
>frontswap backend regardless of whether or not zswap.enabled=1 is passed
>in the boot parameters or not.  This introduces a very small overhead
>for systems that have zswap disabled as calls to frontswap_store() will
>call zswap_frontswap_store(), but there is a fast path to immediately
>return if zswap is disabled.
>
>Disabling zswap does not unregister zswap from frontswap.  It simply
>blocks all future stores.
>
>Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
>---
> Documentation/vm/zswap.txt | 18 ++++++++++++++++--
> mm/zswap.c                 |  9 +++------
> 2 files changed, 19 insertions(+), 8 deletions(-)
>
>diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
>index 7e492d8..d588477 100644
>--- a/Documentation/vm/zswap.txt
>+++ b/Documentation/vm/zswap.txt
>@@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
> device when the compressed pool reaches it size limit.  This requirement had
> been identified in prior community discussions.
>
>-To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
>-zswap.enabled=1
>+Zswap is disabled by default but can be enabled at boot time by setting
>+the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
>+can also be enabled and disabled at runtime using the sysfs interface.
>+An exmaple command to enable zswap at runtime, assuming sysfs is mounted
>+at /sys, is:
>+
>+echo 1 > /sys/modules/zswap/parameters/enabled
>+
>+When zswap is disabled at runtime, it will stop storing pages that are
>+being swapped out.  However, it will _not_ immediately write out or
>+fault back into memory all of the pages stored in the compressed pool.
>+The pages stored in zswap will continue to remain in the compressed pool
>+until they are either invalidated or faulted back into memory.  In order
>+to force all pages out of the compressed pool, a swapoff on the swap
>+device(s) will fault all swapped out pages, included those in the
>+compressed pool, back into memory.
>
> Design:
>
>diff --git a/mm/zswap.c b/mm/zswap.c
>index deda2b6..199b1b0 100644
>--- a/mm/zswap.c
>+++ b/mm/zswap.c
>@@ -75,9 +75,9 @@ static u64 zswap_duplicate_entry;
> /*********************************
> * tunables
> **********************************/
>-/* Enable/disable zswap (disabled by default, fixed at boot for now) */
>+/* Enable/disable zswap (disabled by default) */
> static bool zswap_enabled __read_mostly;
>-module_param_named(enabled, zswap_enabled, bool, 0);
>+module_param_named(enabled, zswap_enabled, bool, 0644);
>
> /* Compressor to be used by zswap (fixed at boot for now) */
> #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
>@@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
> 	u8 *src, *dst;
> 	struct zswap_header *zhdr;
>
>-	if (!tree) {
>+	if (!zswap_enabled || !tree) {

If this check should be added to all hooks in zswap?

> 		ret = -ENODEV;
> 		goto reject;
> 	}
>@@ -908,9 +908,6 @@ static void __exit zswap_debugfs_exit(void) { }
> **********************************/
> static int __init init_zswap(void)
> {
>-	if (!zswap_enabled)
>-		return 0;
>-
> 	pr_info("loading zswap\n");
> 	if (zswap_entry_cache_create()) {
> 		pr_err("entry cache creation failed\n");
>-- 
>1.8.1.2
>
>--
>To unsubscribe, send a message with 'unsubscribe linux-mm' in
>the body to majordomo@kvack.org.  For more info on Linux MM,
>see: http://www.linux-mm.org/ .
>Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
  2013-07-22 19:34 ` Seth Jennings
  (?)
  (?)
@ 2013-07-22 23:25 ` Wanpeng Li
  -1 siblings, 0 replies; 10+ messages in thread
From: Wanpeng Li @ 2013-07-22 23:25 UTC (permalink / raw)
  Cc: Andrew Morton, Seth Jennings, Dave Hansen, Bob Liu, Minchan Kim,
	linux-mm, linux-kernel

On Mon, Jul 22, 2013 at 02:34:02PM -0500, Seth Jennings wrote:
>Right now, zswap can only be enabled at boot time.  This patch
>modifies zswap so that it can be dynamically enabled or disabled
>at runtime.
>
>In order to allow this ability, zswap unconditionally registers as a
>frontswap backend regardless of whether or not zswap.enabled=1 is passed
>in the boot parameters or not.  This introduces a very small overhead
>for systems that have zswap disabled as calls to frontswap_store() will
>call zswap_frontswap_store(), but there is a fast path to immediately
>return if zswap is disabled.
>
>Disabling zswap does not unregister zswap from frontswap.  It simply
>blocks all future stores.
>
>Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
>---
> Documentation/vm/zswap.txt | 18 ++++++++++++++++--
> mm/zswap.c                 |  9 +++------
> 2 files changed, 19 insertions(+), 8 deletions(-)
>
>diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
>index 7e492d8..d588477 100644
>--- a/Documentation/vm/zswap.txt
>+++ b/Documentation/vm/zswap.txt
>@@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
> device when the compressed pool reaches it size limit.  This requirement had
> been identified in prior community discussions.
>
>-To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
>-zswap.enabled=1
>+Zswap is disabled by default but can be enabled at boot time by setting
>+the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
>+can also be enabled and disabled at runtime using the sysfs interface.
>+An exmaple command to enable zswap at runtime, assuming sysfs is mounted
>+at /sys, is:
>+
>+echo 1 > /sys/modules/zswap/parameters/enabled
>+
>+When zswap is disabled at runtime, it will stop storing pages that are
>+being swapped out.  However, it will _not_ immediately write out or
>+fault back into memory all of the pages stored in the compressed pool.
>+The pages stored in zswap will continue to remain in the compressed pool
>+until they are either invalidated or faulted back into memory.  In order
>+to force all pages out of the compressed pool, a swapoff on the swap
>+device(s) will fault all swapped out pages, included those in the
>+compressed pool, back into memory.
>
> Design:
>
>diff --git a/mm/zswap.c b/mm/zswap.c
>index deda2b6..199b1b0 100644
>--- a/mm/zswap.c
>+++ b/mm/zswap.c
>@@ -75,9 +75,9 @@ static u64 zswap_duplicate_entry;
> /*********************************
> * tunables
> **********************************/
>-/* Enable/disable zswap (disabled by default, fixed at boot for now) */
>+/* Enable/disable zswap (disabled by default) */
> static bool zswap_enabled __read_mostly;
>-module_param_named(enabled, zswap_enabled, bool, 0);
>+module_param_named(enabled, zswap_enabled, bool, 0644);
>
> /* Compressor to be used by zswap (fixed at boot for now) */
> #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
>@@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
> 	u8 *src, *dst;
> 	struct zswap_header *zhdr;
>
>-	if (!tree) {
>+	if (!zswap_enabled || !tree) {

If this check should be added to all hooks in zswap?

> 		ret = -ENODEV;
> 		goto reject;
> 	}
>@@ -908,9 +908,6 @@ static void __exit zswap_debugfs_exit(void) { }
> **********************************/
> static int __init init_zswap(void)
> {
>-	if (!zswap_enabled)
>-		return 0;
>-
> 	pr_info("loading zswap\n");
> 	if (zswap_entry_cache_create()) {
> 		pr_err("entry cache creation failed\n");
>-- 
>1.8.1.2
>
>--
>To unsubscribe, send a message with 'unsubscribe linux-mm' in
>the body to majordomo@kvack.org.  For more info on Linux MM,
>see: http://www.linux-mm.org/ .
>Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
  2013-07-22 19:34 ` Seth Jennings
@ 2013-07-23  9:16   ` Bob Liu
  -1 siblings, 0 replies; 10+ messages in thread
From: Bob Liu @ 2013-07-23  9:16 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Andrew Morton, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On 07/23/2013 03:34 AM, Seth Jennings wrote:
> Right now, zswap can only be enabled at boot time.  This patch
> modifies zswap so that it can be dynamically enabled or disabled
> at runtime.
> 
> In order to allow this ability, zswap unconditionally registers as a
> frontswap backend regardless of whether or not zswap.enabled=1 is passed
> in the boot parameters or not.  This introduces a very small overhead
> for systems that have zswap disabled as calls to frontswap_store() will
> call zswap_frontswap_store(), but there is a fast path to immediately
> return if zswap is disabled.

There is also overhead in frontswap_load() after all pages are faulted
back into memory.

> 
> Disabling zswap does not unregister zswap from frontswap.  It simply
> blocks all future stores.
> 
> Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
> ---
>  Documentation/vm/zswap.txt | 18 ++++++++++++++++--
>  mm/zswap.c                 |  9 +++------
>  2 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
> index 7e492d8..d588477 100644
> --- a/Documentation/vm/zswap.txt
> +++ b/Documentation/vm/zswap.txt
> @@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
>  device when the compressed pool reaches it size limit.  This requirement had
>  been identified in prior community discussions.
>  
> -To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
> -zswap.enabled=1
> +Zswap is disabled by default but can be enabled at boot time by setting
> +the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
> +can also be enabled and disabled at runtime using the sysfs interface.
> +An exmaple command to enable zswap at runtime, assuming sysfs is mounted
> +at /sys, is:
> +
> +echo 1 > /sys/modules/zswap/parameters/enabled
> +
> +When zswap is disabled at runtime, it will stop storing pages that are
> +being swapped out.  However, it will _not_ immediately write out or
> +fault back into memory all of the pages stored in the compressed pool.

I don't know what's you use case of adding this feature.
In my opinion I'd perfer to flush all the pages stored in zswap when
disabled it, so that I can run testing without rebooting the machine.

> +The pages stored in zswap will continue to remain in the compressed pool
> +until they are either invalidated or faulted back into memory.  In order
> +to force all pages out of the compressed pool, a swapoff on the swap
> +device(s) will fault all swapped out pages, included those in the
> +compressed pool, back into memory.
>  
>  Design:
>  
> diff --git a/mm/zswap.c b/mm/zswap.c
> index deda2b6..199b1b0 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -75,9 +75,9 @@ static u64 zswap_duplicate_entry;
>  /*********************************
>  * tunables
>  **********************************/
> -/* Enable/disable zswap (disabled by default, fixed at boot for now) */
> +/* Enable/disable zswap (disabled by default) */
>  static bool zswap_enabled __read_mostly;
> -module_param_named(enabled, zswap_enabled, bool, 0);
> +module_param_named(enabled, zswap_enabled, bool, 0644);
>  
>  /* Compressor to be used by zswap (fixed at boot for now) */
>  #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
> @@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
>  	u8 *src, *dst;
>  	struct zswap_header *zhdr;
>  
> -	if (!tree) {
> +	if (!zswap_enabled || !tree) {
>  		ret = -ENODEV;
>  		goto reject;
>  	}
> @@ -908,9 +908,6 @@ static void __exit zswap_debugfs_exit(void) { }
>  **********************************/
>  static int __init init_zswap(void)
>  {
> -	if (!zswap_enabled)
> -		return 0;
> -
>  	pr_info("loading zswap\n");
>  	if (zswap_entry_cache_create()) {
>  		pr_err("entry cache creation failed\n");
> 

-- 
Regards,
-Bob

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
@ 2013-07-23  9:16   ` Bob Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bob Liu @ 2013-07-23  9:16 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Andrew Morton, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On 07/23/2013 03:34 AM, Seth Jennings wrote:
> Right now, zswap can only be enabled at boot time.  This patch
> modifies zswap so that it can be dynamically enabled or disabled
> at runtime.
> 
> In order to allow this ability, zswap unconditionally registers as a
> frontswap backend regardless of whether or not zswap.enabled=1 is passed
> in the boot parameters or not.  This introduces a very small overhead
> for systems that have zswap disabled as calls to frontswap_store() will
> call zswap_frontswap_store(), but there is a fast path to immediately
> return if zswap is disabled.

There is also overhead in frontswap_load() after all pages are faulted
back into memory.

> 
> Disabling zswap does not unregister zswap from frontswap.  It simply
> blocks all future stores.
> 
> Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
> ---
>  Documentation/vm/zswap.txt | 18 ++++++++++++++++--
>  mm/zswap.c                 |  9 +++------
>  2 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
> index 7e492d8..d588477 100644
> --- a/Documentation/vm/zswap.txt
> +++ b/Documentation/vm/zswap.txt
> @@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
>  device when the compressed pool reaches it size limit.  This requirement had
>  been identified in prior community discussions.
>  
> -To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
> -zswap.enabled=1
> +Zswap is disabled by default but can be enabled at boot time by setting
> +the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
> +can also be enabled and disabled at runtime using the sysfs interface.
> +An exmaple command to enable zswap at runtime, assuming sysfs is mounted
> +at /sys, is:
> +
> +echo 1 > /sys/modules/zswap/parameters/enabled
> +
> +When zswap is disabled at runtime, it will stop storing pages that are
> +being swapped out.  However, it will _not_ immediately write out or
> +fault back into memory all of the pages stored in the compressed pool.

I don't know what's you use case of adding this feature.
In my opinion I'd perfer to flush all the pages stored in zswap when
disabled it, so that I can run testing without rebooting the machine.

> +The pages stored in zswap will continue to remain in the compressed pool
> +until they are either invalidated or faulted back into memory.  In order
> +to force all pages out of the compressed pool, a swapoff on the swap
> +device(s) will fault all swapped out pages, included those in the
> +compressed pool, back into memory.
>  
>  Design:
>  
> diff --git a/mm/zswap.c b/mm/zswap.c
> index deda2b6..199b1b0 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -75,9 +75,9 @@ static u64 zswap_duplicate_entry;
>  /*********************************
>  * tunables
>  **********************************/
> -/* Enable/disable zswap (disabled by default, fixed at boot for now) */
> +/* Enable/disable zswap (disabled by default) */
>  static bool zswap_enabled __read_mostly;
> -module_param_named(enabled, zswap_enabled, bool, 0);
> +module_param_named(enabled, zswap_enabled, bool, 0644);
>  
>  /* Compressor to be used by zswap (fixed at boot for now) */
>  #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
> @@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
>  	u8 *src, *dst;
>  	struct zswap_header *zhdr;
>  
> -	if (!tree) {
> +	if (!zswap_enabled || !tree) {
>  		ret = -ENODEV;
>  		goto reject;
>  	}
> @@ -908,9 +908,6 @@ static void __exit zswap_debugfs_exit(void) { }
>  **********************************/
>  static int __init init_zswap(void)
>  {
> -	if (!zswap_enabled)
> -		return 0;
> -
>  	pr_info("loading zswap\n");
>  	if (zswap_entry_cache_create()) {
>  		pr_err("entry cache creation failed\n");
> 

-- 
Regards,
-Bob

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
  2013-07-22 23:25 ` Wanpeng Li
@ 2013-07-23 17:22   ` Seth Jennings
  0 siblings, 0 replies; 10+ messages in thread
From: Seth Jennings @ 2013-07-23 17:22 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: Andrew Morton, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On Tue, Jul 23, 2013 at 07:25:29AM +0800, Wanpeng Li wrote:
> On Mon, Jul 22, 2013 at 02:34:02PM -0500, Seth Jennings wrote:
> >@@ -612,7 +612,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
> > 	u8 *src, *dst;
> > 	struct zswap_header *zhdr;
> >
> >-	if (!tree) {
> >+	if (!zswap_enabled || !tree) {
> 
> If this check should be added to all hooks in zswap?

No.  We want to continue to allow loads and invalidates since zswap will
still have pages stored it in.  It just won't accept any new pages.

Seth

> 
> > 		ret = -ENODEV;
> > 		goto reject;
> > 	}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
  2013-07-23  9:16   ` Bob Liu
  (?)
@ 2013-07-23 17:32   ` Seth Jennings
  2013-07-23 20:08       ` Dave Hansen
  -1 siblings, 1 reply; 10+ messages in thread
From: Seth Jennings @ 2013-07-23 17:32 UTC (permalink / raw)
  To: Bob Liu
  Cc: Andrew Morton, Dave Hansen, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On Tue, Jul 23, 2013 at 05:16:07PM +0800, Bob Liu wrote:
> On 07/23/2013 03:34 AM, Seth Jennings wrote:
> > Right now, zswap can only be enabled at boot time.  This patch
> > modifies zswap so that it can be dynamically enabled or disabled
> > at runtime.
> > 
> > In order to allow this ability, zswap unconditionally registers as a
> > frontswap backend regardless of whether or not zswap.enabled=1 is passed
> > in the boot parameters or not.  This introduces a very small overhead
> > for systems that have zswap disabled as calls to frontswap_store() will
> > call zswap_frontswap_store(), but there is a fast path to immediately
> > return if zswap is disabled.
> 
> There is also overhead in frontswap_load() after all pages are faulted
> back into memory.

This is true.  However frontswap_load() (__frontswap_load() to be more
precise) will not call into the backend since the bit in the
frontswap_map will not be set.  But there is the overhead of checking
that bit, you're right.

> 
> > 
> > Disabling zswap does not unregister zswap from frontswap.  It simply
> > blocks all future stores.
> > 
> > Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
> > ---
> >  Documentation/vm/zswap.txt | 18 ++++++++++++++++--
> >  mm/zswap.c                 |  9 +++------
> >  2 files changed, 19 insertions(+), 8 deletions(-)
> > 
> > diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
> > index 7e492d8..d588477 100644
> > --- a/Documentation/vm/zswap.txt
> > +++ b/Documentation/vm/zswap.txt
> > @@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache on an LRU basis to the backing swap
> >  device when the compressed pool reaches it size limit.  This requirement had
> >  been identified in prior community discussions.
> >  
> > -To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
> > -zswap.enabled=1
> > +Zswap is disabled by default but can be enabled at boot time by setting
> > +the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
> > +can also be enabled and disabled at runtime using the sysfs interface.
> > +An exmaple command to enable zswap at runtime, assuming sysfs is mounted
> > +at /sys, is:
> > +
> > +echo 1 > /sys/modules/zswap/parameters/enabled
> > +
> > +When zswap is disabled at runtime, it will stop storing pages that are
> > +being swapped out.  However, it will _not_ immediately write out or
> > +fault back into memory all of the pages stored in the compressed pool.
> 
> I don't know what's you use case of adding this feature.

Dave expressed interest in having it, useful for testing, and I can see
people that just wanting to try it out enabling it manually at runtime.

> In my opinion I'd perfer to flush all the pages stored in zswap when
> disabled it, so that I can run testing without rebooting the machine.

Why would you have to reboot your machine?  If you want to force all
the pages out of the compressed pool, a swapoff should do it as now
noted in the Documentation file (below).

Seth 

> 
> > +The pages stored in zswap will continue to remain in the compressed pool
> > +until they are either invalidated or faulted back into memory.  In order
> > +to force all pages out of the compressed pool, a swapoff on the swap
> > +device(s) will fault all swapped out pages, included those in the
> > +compressed pool, back into memory.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
  2013-07-23 17:32   ` Seth Jennings
@ 2013-07-23 20:08       ` Dave Hansen
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Hansen @ 2013-07-23 20:08 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Bob Liu, Andrew Morton, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On 07/23/2013 10:32 AM, Seth Jennings wrote:
> On Tue, Jul 23, 2013 at 05:16:07PM +0800, Bob Liu wrote:
>> On 07/23/2013 03:34 AM, Seth Jennings wrote:
>>> -To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
>>> -zswap.enabled=1
>>> +Zswap is disabled by default but can be enabled at boot time by setting
>>> +the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
>>> +can also be enabled and disabled at runtime using the sysfs interface.
>>> +An exmaple command to enable zswap at runtime, assuming sysfs is mounted
>>> +at /sys, is:
>>> +
>>> +echo 1 > /sys/modules/zswap/parameters/enabled
>>> +
>>> +When zswap is disabled at runtime, it will stop storing pages that are
>>> +being swapped out.  However, it will _not_ immediately write out or
>>> +fault back into memory all of the pages stored in the compressed pool.
>>
>> I don't know what's you use case of adding this feature.
> 
> Dave expressed interest in having it, useful for testing, and I can see
> people that just wanting to try it out enabling it manually at runtime.

The distributions are going to have to make a decision about whether or
not they turn this on.  If it is 100% selected at compile-time and has
all of the potential performance implications (zswap *can* hurt with
certain workloads), I would not expect a distribution to enable it at all.

The only sane thing to do here is to compile it in, runtime-default it
to off, and let folks enable it who want to use it on their workload.

>> In my opinion I'd perfer to flush all the pages stored in zswap when
>> disabled it, so that I can run testing without rebooting the machine.
> 
> Why would you have to reboot your machine?  If you want to force all
> the pages out of the compressed pool, a swapoff should do it as now
> noted in the Documentation file (below).

It is kinda crummy that it won't be flushed, but considering the size
and simplicity of the patch as it stands, I'm not going to whinge about
it too much.

Seth, it'd be nice to have you at least see if it is worth flushing all
the pages when zswap is disabled, or whether it's too much code to go to
the trouble.

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

* Re: [PATCH] mm: zswap: add runtime enable/disable
@ 2013-07-23 20:08       ` Dave Hansen
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Hansen @ 2013-07-23 20:08 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Bob Liu, Andrew Morton, Bob Liu, Minchan Kim, linux-mm, linux-kernel

On 07/23/2013 10:32 AM, Seth Jennings wrote:
> On Tue, Jul 23, 2013 at 05:16:07PM +0800, Bob Liu wrote:
>> On 07/23/2013 03:34 AM, Seth Jennings wrote:
>>> -To enabled zswap, the "enabled" attribute must be set to 1 at boot time.  e.g.
>>> -zswap.enabled=1
>>> +Zswap is disabled by default but can be enabled at boot time by setting
>>> +the "enabled" attribute to 1 at boot time. e.g. zswap.enabled=1.  Zswap
>>> +can also be enabled and disabled at runtime using the sysfs interface.
>>> +An exmaple command to enable zswap at runtime, assuming sysfs is mounted
>>> +at /sys, is:
>>> +
>>> +echo 1 > /sys/modules/zswap/parameters/enabled
>>> +
>>> +When zswap is disabled at runtime, it will stop storing pages that are
>>> +being swapped out.  However, it will _not_ immediately write out or
>>> +fault back into memory all of the pages stored in the compressed pool.
>>
>> I don't know what's you use case of adding this feature.
> 
> Dave expressed interest in having it, useful for testing, and I can see
> people that just wanting to try it out enabling it manually at runtime.

The distributions are going to have to make a decision about whether or
not they turn this on.  If it is 100% selected at compile-time and has
all of the potential performance implications (zswap *can* hurt with
certain workloads), I would not expect a distribution to enable it at all.

The only sane thing to do here is to compile it in, runtime-default it
to off, and let folks enable it who want to use it on their workload.

>> In my opinion I'd perfer to flush all the pages stored in zswap when
>> disabled it, so that I can run testing without rebooting the machine.
> 
> Why would you have to reboot your machine?  If you want to force all
> the pages out of the compressed pool, a swapoff should do it as now
> noted in the Documentation file (below).

It is kinda crummy that it won't be flushed, but considering the size
and simplicity of the patch as it stands, I'm not going to whinge about
it too much.

Seth, it'd be nice to have you at least see if it is worth flushing all
the pages when zswap is disabled, or whether it's too much code to go to
the trouble.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-07-23 20:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22 19:34 [PATCH] mm: zswap: add runtime enable/disable Seth Jennings
2013-07-22 19:34 ` Seth Jennings
2013-07-22 23:25 ` Wanpeng Li
2013-07-23 17:22   ` Seth Jennings
2013-07-22 23:25 ` Wanpeng Li
2013-07-23  9:16 ` Bob Liu
2013-07-23  9:16   ` Bob Liu
2013-07-23 17:32   ` Seth Jennings
2013-07-23 20:08     ` Dave Hansen
2013-07-23 20:08       ` Dave Hansen

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.