The patch titled Subject: zswap: runtime enable/disable has been added to the -mm tree. Its filename is zswap-runtime-enable-disable.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/zswap-runtime-enable-disable.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/zswap-runtime-enable-disable.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Dan Streetman <ddstreet@xxxxxxxx> Subject: 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 Signed-off-by: Dan Streetman <ddstreet@xxxxxxxx> Suggested-by: Seth Jennings <sjennings@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/vm/zswap.txt | 18 ++++++++++++++++-- mm/zswap.c | 12 +++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff -puN Documentation/vm/zswap.txt~zswap-runtime-enable-disable Documentation/vm/zswap.txt --- a/Documentation/vm/zswap.txt~zswap-runtime-enable-disable +++ a/Documentation/vm/zswap.txt @@ -26,8 +26,22 @@ Zswap evicts pages from compressed cache device when the compressed pool reaches its 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 -puN mm/zswap.c~zswap-runtime-enable-disable mm/zswap.c --- a/mm/zswap.c~zswap-runtime-enable-disable +++ a/mm/zswap.c @@ -75,9 +75,10 @@ static u64 zswap_duplicate_entry; /********************************* * tunables **********************************/ -/* Enable/disable zswap (disabled by default, fixed at boot for now) */ -static bool zswap_enabled __read_mostly; -module_param_named(enabled, zswap_enabled, bool, 0444); + +/* Enable/disable zswap (disabled by default) */ +static bool zswap_enabled; +module_param_named(enabled, zswap_enabled, bool, 0644); /* Compressor to be used by zswap (fixed at boot for now) */ #define ZSWAP_COMPRESSOR_DEFAULT "lzo" @@ -648,7 +649,7 @@ static int zswap_frontswap_store(unsigne u8 *src, *dst; struct zswap_header *zhdr; - if (!tree) { + if (!zswap_enabled || !tree) { ret = -ENODEV; goto reject; } @@ -901,9 +902,6 @@ static int __init init_zswap(void) { gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; - if (!zswap_enabled) - return 0; - pr_info("loading zswap\n"); zswap_pool = zpool_create_pool(zswap_zpool_type, "zswap", gfp, _ Patches currently in -mm which might be from ddstreet@xxxxxxxx are mm-vmscan-do-not-throttle-based-on-pfmemalloc-reserves-if-node-has-no-reclaimable-pages.patch frontswap-allow-multiple-backends.patch zswap-runtime-enable-disable.patch zswap-runtime-enable-disable-fix.patch zpool-change-pr_info-to-pr_debug.patch zpool-remove-zpool_evict.patch maintainers-add-zpool.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html