zswap: re-check zswap_is_full after do zswap_shrink
Subsystems (2)
PATCH v2 1/1 zswap: re-check zswap_is_full after do zswap_shrink
The '/sys/../zswap/stored_pages:' keep raising in zswap test with "zswap.max_pool_percent=0" parameter. But theoretically, it should not compress or store pages any more since there is no space in 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 notThe root cause is:
When zswap_max_pool_percent is setting to 0 via kernel parameter, the zswap_is_full() will always return true to do zswap_shrink(). But if the shinking is able to reclain a page successful, then proceeds to compress/store another page, so the value of stored_pages will keep changing.
To solve the issue, this patch adds zswap_is_full() check again after zswap_shrink() to make sure it's now under the max_pool_percent, and not to compress/store if reach its limitaion.
--- mm/zswap.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/zswap.c +9 -0
@@ -1026,6 +1026,15 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, 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 */
Signature · 1 line
2.9.5
Quoted 20 lines · Li Wang
The '
/sys/../zswap/stored_pages:' keep raising in zswap test with "zswap.max_pool_percent=0" parameter. But theoretically, it should not compress or store pages any more since there is no space in compressed pool.Reproduce steps:
1. Boot kernel with "zswap.enabled=1"
2. Set themax_pool_percentto 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 notThe root cause is:
Whenzswap_max_pool_percentis setting to 0 via kernel parameter, thezswap_is_full()will always return true to dozswap_shrink(). But if the shinking is able to reclain a page successful, then proceeds to compress/store another page, so the value ofstored_pageswill keep changing.
Quoted 5 lines
To solve the issue, this patch adds
zswap_is_full()check again afterzswap_shrink()to make sure it's now under themax_pool_percent, and not to compress/store if reach its limitaion.Signed-off-by Li Wang <[email protected]>
Quoted 31 lines
Cc Seth Jennings <[email protected]>Cc Dan Streetman <[email protected]>Cc Huang Ying <[email protected]>Cc Yu Zhao <[email protected]>--- mm/zswap.c | 9 +++++++++ 1 file changed, 9 insertions(+)mm/zswap.c +9
-1@@ -1026,6 +1026,15 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, 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 */ --2.9.5
Quoted 21 lines · Dan Streetman
Quoted 20 lines · Li Wang
The '
/sys/../zswap/stored_pages:' keep raising in zswap test with "zswap.max_pool_percent=0" parameter. But theoretically, it should not compress or store pages any more since there is no space in compressed pool.Reproduce steps:
1. Boot kernel with "zswap.enabled=1"
2. Set themax_pool_percentto 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 notThe root cause is:
Whenzswap_max_pool_percentis setting to 0 via kernel parameter, thezswap_is_full()will always return true to dozswap_shrink(). But if the shinking is able to reclain a page successful, then proceeds to compress/store another page, so the value ofstored_pageswill keep changing.
Quoted 7 lines
Quoted 5 lines
To solve the issue, this patch adds
zswap_is_full()check again afterzswap_shrink()to make sure it's now under themax_pool_percent, and not to compress/store if reach its limitaion.Signed-off-by Li Wang <[email protected]>Acked-by Dan Streetman <[email protected]>
ping~
Any possible to merge this in kernel-4.18-rcX? My zswap test always fails on the upstream kernel.
Signature · 3 lines
Regards, Li Wang Email: [email protected]
Quoted 27 lines · Li Wang
Quoted 25 lines · Dan Streetman
Quoted 24 lines · Li Wang
The '
/sys/../zswap/stored_pages:' keep raising in zswap test with "zswap.max_pool_percent=0" parameter. But theoretically, it should not compress or store pages any more since there is no space in compressed pool.Reproduce steps:
1. Boot kernel with "zswap.enabled=1"
2. Set themax_pool_percentto 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 notThe root cause is:
Whenzswap_max_pool_percentis setting to 0 via kernel parameter, thezswap_is_full()will always return true to dozswap_shrink(). But if the shinking is able to reclain a page successful, then proceeds to compress/store another page, so the value ofstored_pageswill keep changing.To solve the issue, this patch adds
zswap_is_full()check again afterzswap_shrink()to make sure it's now under themax_pool_percent, and not to compress/store if reach its limitaion.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Li Wang <[email protected]>Acked-by Dan Streetman <[email protected]>ping~
Any possible to merge this in kernel-4.18-rcX? My zswap test always fails on the upstream kernel.
cc'ing Andrew as he may have missed this.
Quoted 6 lines
--
Regards,
Li Wang
Email: [email protected]