z3fold: fix wrong handling of headless pages
PATCH 1/1 z3fold: fix wrong handling of headless pages
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.
--- mm/z3fold.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
mm/z3fold.c +6 -2
@@ -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);
Signature · 1 line
2.7.4
Hi Jongseok,
Den fre 6 juli 2018 kl 07:11 skrev Jongseok Kim <[email protected]>:
Quoted 6 lines
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 inz3fold_free(). So, the wrong page is encoded in headless, ortest_bitdoes not work properly inz3fold_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
Quoted 53 lines
Signed-off-by Jongseok Kim <[email protected]>--- mm/z3fold.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)mm/z3fold.c +6
-3@@ -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
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?
Best regards,
Jongseok
Quoted 10 lines
2018년 11월 6일 (화) 오후 4:48, Vitaly Wool <[email protected]>님이 작성:
Hi Jongseok,thank you for your work, we've now got a more comprehensive solution:
https://lkml.org/lkml/2018/11/5/726Would you please confirm that it works for you? Also, would you be okay with dropping your patch in favor of the new one?
~Vitaly
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'm sorry I sent reply twice.
Best regards,
Jongseok
Quoted 10 lines · Vitaly Wool
Hi Jongseok,
thank you for your work, we've now got a more comprehensive solution:
https://lkml.org/lkml/2018/11/5/726Would you please confirm that it works for you? Also, would you be okay with dropping your patch in favor of the new one?
~Vitaly
Den tors 8 nov. 2018 kl 13:34 skrev 김종석 <[email protected]>:
Quoted 7 lines
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
Quoted 16 lines
I'm sorry I sent reply twice.
Best regards,
JongseokQuoted 10 lines · Vitaly Wool
Hi Jongseok,
thank you for your work, we've now got a more comprehensive solution:
https://lkml.org/lkml/2018/11/5/726Would you please confirm that it works for you? Also, would you be okay with dropping your patch in favor of the new one?
~Vitaly
Yes, you are right.
I think that's the best way to deal it.
Thank you.
Best regards,
Jongseok
Quoted 32 lines
Den tors 8 nov. 2018 kl 13:34 skrev +-eA 3/4 1/4 (R) <[email protected]>:
Quoted 7 lines
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
Quoted 16 lines
I'm sorry I sent reply twice.
Best regards,
JongseokQuoted 10 lines · Vitaly Wool
Hi Jongseok,
thank you for your work, we've now got a more comprehensive solution:
https://lkml.org/lkml/2018/11/5/726Would you please confirm that it works for you? Also, would you be okay with dropping your patch in favor of the new one?
~Vitaly
Quoted 3 lines · On Thu, 8 Nov 2018 22:45:40 +0900 Jongseok Kim <[email protected]> wrote:
Yes, you are right.
I think that's the best way to deal it.
Thank you.
I did this:
Quoted 7 lines · On Thu, Nov 8, 2018, 11:23 PM Andrew Morton <[email protected] wrote:
Quoted 3 lines · On Thu, 8 Nov 2018 22:45:40 +0900 Jongseok Kim <[email protected]> wrote:
Yes, you are right.
I think that's the best way to deal it.
Thank you.
Quoted 9 lines
I did this:
Link:
http://lkml.kernel.org/r/[email protected]Signed-off-by Vitaly Wool <[email protected]>Signed-off-by Jongseok Kim <[email protected]>Reported-by-by Jongseok Kim <[email protected]>Reviewed-by Snild Dolkow <[email protected]>
Thanks!
~Vitaly