The patch titled Subject: zswap: re-check zswap_is_full() after do zswap_shrink() has been added to the -mm tree. Its filename is zswap-re-check-zswap_is_full-after-do-zswap_shrink.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/zswap-re-check-zswap_is_full-after-do-zswap_shrink.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/zswap-re-check-zswap_is_full-after-do-zswap_shrink.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/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Li Wang <liwang@xxxxxxxxxx> Subject: zswap: re-check zswap_is_full() after do zswap_shrink() /sys/../zswap/stored_pages keeps rising in a zswap test with "zswap.max_pool_percent=0" parameter. But it should not compress or store pages any more since there is no space in the compressed pool. Reproduce steps: 1. Boot kernel with "zswap.enabled=1" 2. Set the max_pool_percent to 0 # echo 0 > /sys/module/zswap/parameters/max_pool_percent 3. Do memory stress test to see if some pages have been compressed # stress --vm 1 --vm-bytes $mem_available"M" --timeout 60s 4. Watching the 'stored_pages' number increasing or not The root cause is: When zswap_max_pool_percent is set to 0 via kernel parameter, zswap_is_full() will always return true due to zswap_shrink(). But if the shinking is able to reclain a page successfully the code then proceeds to compressing/storing another page, so the value of stored_pages will keep changing. To solve the issue, this patch adds a zswap_is_full() check again after zswap_shrink() to make sure it's now under the max_pool_percent, and to not compress/store if we reached the limit. Link: http://lkml.kernel.org/r/20180530103936.17812-1-liwang@xxxxxxxxxx Signed-off-by: Li Wang <liwang@xxxxxxxxxx> Acked-by: Dan Streetman <ddstreet@xxxxxxxx> Cc: Seth Jennings <sjenning@xxxxxxxxxx> Cc: Huang Ying <huang.ying.caritas@xxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN mm/zswap.c~zswap-re-check-zswap_is_full-after-do-zswap_shrink mm/zswap.c --- a/mm/zswap.c~zswap-re-check-zswap_is_full-after-do-zswap_shrink +++ a/mm/zswap.c @@ -1026,6 +1026,15 @@ static int zswap_frontswap_store(unsigne ret = -ENOMEM; goto reject; } + + /* A second zswap_is_full() check after + * zswap_shrink() to make sure it's now + * under the max_pool_percent + */ + if (zswap_is_full()) { + ret = -ENOMEM; + goto reject; + } } /* allocate entry */ _ Patches currently in -mm which might be from liwang@xxxxxxxxxx are zswap-re-check-zswap_is_full-after-do-zswap_shrink.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