* [PATCH] z3fold: fix wrong handling of headless pages
@ 2018-07-06 5:10 Jongseok Kim
2018-11-06 7:48 ` Vitaly Wool
0 siblings, 1 reply; 5+ messages in thread
From: Jongseok Kim @ 2018-07-06 5:10 UTC (permalink / raw)
To: Andrew Morton, Vitaly Wool; +Cc: linux-mm, linux-kernel, Jongseok Kim
During the processing of headless pages in z3fold_reclaim_page(),
there was a problem that the zhdr pointed to another page
or a page was already released in z3fold_free(). So, the wrong page
is encoded in headless, or test_bit does not work properly
in z3fold_reclaim_page(). This patch fixed these problems.
Signed-off-by: Jongseok Kim <ks77sj@gmail.com>
---
mm/z3fold.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 4b366d1..201a8ac 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -746,6 +746,9 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
}
if (bud == HEADLESS) {
+ if (test_bit(UNDER_RECLAIM, &page->private))
+ return;
+
spin_lock(&pool->lock);
list_del(&page->lru);
spin_unlock(&pool->lock);
@@ -836,20 +839,20 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
}
list_for_each_prev(pos, &pool->lru) {
page = list_entry(pos, struct page, lru);
+ zhdr = page_address(page);
if (test_bit(PAGE_HEADLESS, &page->private))
/* candidate found */
break;
- zhdr = page_address(page);
if (!z3fold_page_trylock(zhdr))
continue; /* can't evict at this point */
kref_get(&zhdr->refcount);
list_del_init(&zhdr->buddy);
zhdr->cpu = -1;
- set_bit(UNDER_RECLAIM, &page->private);
break;
}
+ set_bit(UNDER_RECLAIM, &page->private);
list_del_init(&page->lru);
spin_unlock(&pool->lock);
@@ -898,6 +901,7 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
if (test_bit(PAGE_HEADLESS, &page->private)) {
if (ret == 0) {
free_z3fold_page(page);
+ atomic64_dec(&pool->pages_nr);
return 0;
}
spin_lock(&pool->lock);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] z3fold: fix wrong handling of headless pages
2018-07-06 5:10 [PATCH] z3fold: fix wrong handling of headless pages Jongseok Kim
@ 2018-11-06 7:48 ` Vitaly Wool
[not found] ` <CALbL15bGHL_M=ofWy_VrDZU_7b2DOC7BnpqJ63gfQ_1gNcG_9A@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Wool @ 2018-11-06 7:48 UTC (permalink / raw)
To: 김종석; +Cc: Andrew Morton, Linux-MM, LKML
Hi Jongseok,
Den fre 6 juli 2018 kl 07:11 skrev Jongseok Kim <ks77sj@gmail.com>:
>
> During the processing of headless pages in z3fold_reclaim_page(),
> there was a problem that the zhdr pointed to another page
> or a page was already released in z3fold_free(). So, the wrong page
> is encoded in headless, or test_bit does not work properly
> in z3fold_reclaim_page(). This patch fixed these problems.
thank you for your work, we've now got a more comprehensive solution:
https://lkml.org/lkml/2018/11/5/726
Would you please confirm that it works for you? Also, would you be
okay with dropping your patch in favor of the new one?
~Vitaly
> Signed-off-by: Jongseok Kim <ks77sj@gmail.com>
> ---
> mm/z3fold.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 4b366d1..201a8ac 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -746,6 +746,9 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
> }
>
> if (bud == HEADLESS) {
> + if (test_bit(UNDER_RECLAIM, &page->private))
> + return;
> +
> spin_lock(&pool->lock);
> list_del(&page->lru);
> spin_unlock(&pool->lock);
> @@ -836,20 +839,20 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
> }
> list_for_each_prev(pos, &pool->lru) {
> page = list_entry(pos, struct page, lru);
> + zhdr = page_address(page);
> if (test_bit(PAGE_HEADLESS, &page->private))
> /* candidate found */
> break;
>
> - zhdr = page_address(page);
> if (!z3fold_page_trylock(zhdr))
> continue; /* can't evict at this point */
> kref_get(&zhdr->refcount);
> list_del_init(&zhdr->buddy);
> zhdr->cpu = -1;
> - set_bit(UNDER_RECLAIM, &page->private);
> break;
> }
>
> + set_bit(UNDER_RECLAIM, &page->private);
> list_del_init(&page->lru);
> spin_unlock(&pool->lock);
>
> @@ -898,6 +901,7 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
> if (test_bit(PAGE_HEADLESS, &page->private)) {
> if (ret == 0) {
> free_z3fold_page(page);
> + atomic64_dec(&pool->pages_nr);
> return 0;
> }
> spin_lock(&pool->lock);
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] z3fold: fix wrong handling of headless pages
[not found] ` <CALbL15bGHL_M=ofWy_VrDZU_7b2DOC7BnpqJ63gfQ_1gNcG_9A@mail.gmail.com>
@ 2018-11-08 12:57 ` Vitaly Wool
2018-11-08 13:45 ` Jongseok Kim
0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Wool @ 2018-11-08 12:57 UTC (permalink / raw)
To: 김종석; +Cc: Andrew Morton, Linux-MM, LKML
Den tors 8 nov. 2018 kl 13:34 skrev 김종석 <ks77sj@gmail.com>:
>
> Hi Vitaly,
> thank you for the reply.
>
> I agree your a new solution is more comprehensive and drop my patch is simple way.
> But, I think it's not fair.
> If my previous patch was not wrong, is (my patch -> your patch) the right way?
I could apply the new patch on top of yours but that would effectively
revert most of your changes.
Would it be ok for you if I add you to Signed-off-by for the new patch instead?
~Vitaly
> I'm sorry I sent reply twice.
>
> Best regards,
> Jongseok
>
>
> > On 6/11/2018 4:48 PM, Vitaly Wool wrote:
> > Hi Jongseok,
>
> > thank you for your work, we've now got a more comprehensive solution:
> > https://lkml.org/lkml/2018/11/5/726
>
> > Would you please confirm that it works for you? Also, would you be
> >okay with dropping your patch in favor of the new one?
>
> > ~Vitaly
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] z3fold: fix wrong handling of headless pages
2018-11-08 12:57 ` Vitaly Wool
@ 2018-11-08 13:45 ` Jongseok Kim
2018-11-08 22:23 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Jongseok Kim @ 2018-11-08 13:45 UTC (permalink / raw)
To: Vitaly Wool; +Cc: akpm, linux-mm, linux-kernel, Jongseok Kim
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 1035 bytes --]
Yes, you are right.
I think that's the best way to deal it.
Thank you.
Best regards,
Jongseok
> Den tors 8 nov. 2018 kl 13:34 skrev ±èÁ¾¼® <ks77sj@gmail.com>:
> >
> > Hi Vitaly,
> > thank you for the reply.
> >
> > I agree your a new solution is more comprehensive and drop my patch is simple way.
> > But, I think it's not fair.
> > If my previous patch was not wrong, is (my patch -> your patch) the right way?
> I could apply the new patch on top of yours but that would effectively
> revert most of your changes.
> Would it be ok for you if I add you to Signed-off-by for the new patch instead?
> ~Vitaly
> > I'm sorry I sent reply twice.
> >
> > Best regards,
> > Jongseok
> >
> >
> > > On 6/11/2018 4:48 PM, Vitaly Wool wrote:
> > > Hi Jongseok,
> >
> > > thank you for your work, we've now got a more comprehensive solution:
> > > https://lkml.org/lkml/2018/11/5/726
> >
> > > Would you please confirm that it works for you? Also, would you be
> > >okay with dropping your patch in favor of the new one?
> >
> > > ~Vitaly
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] z3fold: fix wrong handling of headless pages
2018-11-08 13:45 ` Jongseok Kim
@ 2018-11-08 22:23 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2018-11-08 22:23 UTC (permalink / raw)
To: Jongseok Kim; +Cc: Vitaly Wool, linux-mm, linux-kernel
On Thu, 8 Nov 2018 22:45:40 +0900 Jongseok Kim <ks77sj@gmail.com> wrote:
> Yes, you are right.
> I think that's the best way to deal it.
> Thank you.
I did this:
Link: http://lkml.kernel.org/r/20181105162225.74e8837d03583a9b707cf559@gmail.com
Signed-off-by: Vitaly Wool <vitaly.vul@sony.com>
Signed-off-by: Jongseok Kim <ks77sj@gmail.com>
Reported-by-by: Jongseok Kim <ks77sj@gmail.com>
Reviewed-by: Snild Dolkow <snild@sony.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-11-08 22:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 5:10 [PATCH] z3fold: fix wrong handling of headless pages Jongseok Kim
2018-11-06 7:48 ` Vitaly Wool
[not found] ` <CALbL15bGHL_M=ofWy_VrDZU_7b2DOC7BnpqJ63gfQ_1gNcG_9A@mail.gmail.com>
2018-11-08 12:57 ` Vitaly Wool
2018-11-08 13:45 ` Jongseok Kim
2018-11-08 22:23 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).