diff options
author | Dan Streetman <ddstreet@ieee.org> | 2015-06-25 18:00:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-25 20:00:37 -0400 |
commit | c00ed16a9eb98a7fc076e227bdd95c1451ca1e6e (patch) | |
tree | 5755f0f5b8cb5bf27b86d4a8b183722442475095 /mm/zswap.c | |
parent | d93435c3fba4a47b773693b0c8992470d38510d5 (diff) |
zswap: runtime enable/disable
Change the "enabled" parameter to be configurable at runtime. Remove the
enabled check from init(), and move it to the frontswap store() function;
when enabled, pages will be stored, and when disabled, pages won't be
stored.
This is almost identical to Seth's patch from 2 years ago:
http://lkml.iu.edu/hypermail/linux/kernel/1307.2/04289.html
[akpm@linux-foundation.org: tweak documentation]
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Suggested-by: Seth Jennings <sjennings@variantweb.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/zswap.c')
-rw-r--r-- | mm/zswap.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/mm/zswap.c b/mm/zswap.c index 4249e82ff934..2d5727baed59 100644 --- a/mm/zswap.c +++ b/mm/zswap.c | |||
@@ -75,9 +75,10 @@ static u64 zswap_duplicate_entry; | |||
75 | /********************************* | 75 | /********************************* |
76 | * tunables | 76 | * tunables |
77 | **********************************/ | 77 | **********************************/ |
78 | /* Enable/disable zswap (disabled by default, fixed at boot for now) */ | 78 | |
79 | static bool zswap_enabled __read_mostly; | 79 | /* Enable/disable zswap (disabled by default) */ |
80 | module_param_named(enabled, zswap_enabled, bool, 0444); | 80 | static bool zswap_enabled; |
81 | module_param_named(enabled, zswap_enabled, bool, 0644); | ||
81 | 82 | ||
82 | /* Compressor to be used by zswap (fixed at boot for now) */ | 83 | /* Compressor to be used by zswap (fixed at boot for now) */ |
83 | #define ZSWAP_COMPRESSOR_DEFAULT "lzo" | 84 | #define ZSWAP_COMPRESSOR_DEFAULT "lzo" |
@@ -648,7 +649,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, | |||
648 | u8 *src, *dst; | 649 | u8 *src, *dst; |
649 | struct zswap_header *zhdr; | 650 | struct zswap_header *zhdr; |
650 | 651 | ||
651 | if (!tree) { | 652 | if (!zswap_enabled || !tree) { |
652 | ret = -ENODEV; | 653 | ret = -ENODEV; |
653 | goto reject; | 654 | goto reject; |
654 | } | 655 | } |
@@ -901,9 +902,6 @@ static int __init init_zswap(void) | |||
901 | { | 902 | { |
902 | gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; | 903 | gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; |
903 | 904 | ||
904 | if (!zswap_enabled) | ||
905 | return 0; | ||
906 | |||
907 | pr_info("loading zswap\n"); | 905 | pr_info("loading zswap\n"); |
908 | 906 | ||
909 | zswap_pool = zpool_create_pool(zswap_zpool_type, "zswap", gfp, | 907 | zswap_pool = zpool_create_pool(zswap_zpool_type, "zswap", gfp, |