* [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink
@ 2018-05-30 10:39 Li Wang
2018-05-30 12:53 ` Dan Streetman
0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2018-05-30 10:39 UTC (permalink / raw)
To: ddstreet; +Cc: linux-mm, linux-kernel, Seth Jennings, Huang Ying, Yu Zhao
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 not
The 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.
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Huang Ying <huang.ying.caritas@gmail.com>
Cc: Yu Zhao <yuzhao@google.com>
---
mm/zswap.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/mm/zswap.c b/mm/zswap.c
index 61a5c41..fd320c3 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink
2018-05-30 10:39 [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink Li Wang
@ 2018-05-30 12:53 ` Dan Streetman
2018-06-25 8:08 ` Li Wang
0 siblings, 1 reply; 4+ messages in thread
From: Dan Streetman @ 2018-05-30 12:53 UTC (permalink / raw)
To: Li Wang; +Cc: Linux-MM, linux-kernel, Seth Jennings, Huang Ying, Yu Zhao
On Wed, May 30, 2018 at 6:39 AM, Li Wang <liwang@redhat.com> wrote:
> 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 not
>
> The 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.
>
> Signed-off-by: Li Wang <liwang@redhat.com>
Acked-by: Dan Streetman <ddstreet@ieee.org>
> Cc: Seth Jennings <sjenning@redhat.com>
> Cc: Dan Streetman <ddstreet@ieee.org>
> Cc: Huang Ying <huang.ying.caritas@gmail.com>
> Cc: Yu Zhao <yuzhao@google.com>
> ---
> mm/zswap.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 61a5c41..fd320c3 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink
2018-05-30 12:53 ` Dan Streetman
@ 2018-06-25 8:08 ` Li Wang
2018-07-25 11:29 ` Dan Streetman
0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2018-06-25 8:08 UTC (permalink / raw)
To: Dan Streetman
Cc: Li Wang, Linux-MM, linux-kernel, Seth Jennings, Huang Ying, Yu Zhao
On 30 May 2018 at 20:53, Dan Streetman <ddstreet@ieee.org> wrote:
> On Wed, May 30, 2018 at 6:39 AM, Li Wang <liwang@redhat.com> wrote:
>> 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 not
>>
>> The 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.
>>
>> Signed-off-by: Li Wang <liwang@redhat.com>
>
> Acked-by: Dan Streetman <ddstreet@ieee.org>
ping~
Any possible to merge this in kernel-4.18-rcX? My zswap test always
fails on the upstream kernel.
--
Regards,
Li Wang
Email: wangli.ahau@gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink
2018-06-25 8:08 ` Li Wang
@ 2018-07-25 11:29 ` Dan Streetman
0 siblings, 0 replies; 4+ messages in thread
From: Dan Streetman @ 2018-07-25 11:29 UTC (permalink / raw)
To: wangli.ahau, Andrew Morton
Cc: Li Wang, Linux-MM, linux-kernel, Seth Jennings, huang ying, Yu Zhao
On Mon, Jun 25, 2018 at 4:08 AM Li Wang <wangli.ahau@gmail.com> wrote:
>
> On 30 May 2018 at 20:53, Dan Streetman <ddstreet@ieee.org> wrote:
> > On Wed, May 30, 2018 at 6:39 AM, Li Wang <liwang@redhat.com> wrote:
> >> 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 not
> >>
> >> The 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.
> >>
> >> Signed-off-by: Li Wang <liwang@redhat.com>
> >
> > Acked-by: Dan Streetman <ddstreet@ieee.org>
>
> 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.
>
>
> --
> Regards,
> Li Wang
> Email: wangli.ahau@gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-25 11:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-30 10:39 [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink Li Wang
2018-05-30 12:53 ` Dan Streetman
2018-06-25 8:08 ` Li Wang
2018-07-25 11:29 ` Dan Streetman
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.