linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Henry Burns <henryburns@google.com>
To: Vitaly Wool <vitalywool@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vitaly Vul <vitaly.vul@sony.com>,
	 Shakeel Butt <shakeelb@google.com>,
	Jonathan Adams <jwadams@google.com>,
	Linux MM <linux-mm@kvack.org>,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/z3fold.c: Reinitialize zhdr structs after migration
Date: Mon, 15 Jul 2019 12:56:38 -0700	[thread overview]
Message-ID: <CAGQXPTh-Z664T3Uxak-CiRn6Mc-s=esRzURLpwQaN+v0RgxFyg@mail.gmail.com> (raw)
In-Reply-To: <CAMJBoFMS2BiCdBFBEGE_p5fovDphGqjDjaBYnfGFWhNvCnAvdQ@mail.gmail.com>

>>
>> z3fold_page_migration() calls memcpy(new_zhdr, zhdr, PAGE_SIZE).
>> However, zhdr contains fields that can't be directly coppied over (ex:
>> list_head, a circular linked list). We only need to initialize the
>> linked lists in new_zhdr, as z3fold_isolate_page() already ensures
>> that these lists are empty.
>>
>> Additionally it is possible that zhdr->work has been placed in a
>> workqueue. In this case we shouldn't migrate the page, as zhdr->work
>> references zhdr as opposed to new_zhdr.
>>
>> Fixes: bba4c5f96ce4 ("mm/z3fold.c: support page migration")
>> Signed-off-by: Henry Burns <henryburns@google.com>
>> ---
>>  mm/z3fold.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/mm/z3fold.c b/mm/z3fold.c
>> index 42ef9955117c..9da471bcab93 100644
>> --- a/mm/z3fold.c
>> +++ b/mm/z3fold.c
>> @@ -1352,12 +1352,22 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
>>                 z3fold_page_unlock(zhdr);
>>                 return -EBUSY;
>>         }
>> +       if (work_pending(&zhdr->work)) {
>> +               z3fold_page_unlock(zhdr);
>> +               return -EAGAIN;
>> +       }
>>         new_zhdr = page_address(newpage);
>>         memcpy(new_zhdr, zhdr, PAGE_SIZE);
>>         newpage->private = page->private;
>>         page->private = 0;
>>         z3fold_page_unlock(zhdr);
>>         spin_lock_init(&new_zhdr->page_lock);
>> +       INIT_WORK(&new_zhdr->work, compact_page_work);
>> +       /*
>> +        * z3fold_page_isolate() ensures that this list is empty, so we only
>> +        * have to reinitialize it.
>> +        */
>
>
> On the nitpicking side, we seem to have ensured that directly in migrate :) Looks OK to me otherwise.
Ok, I see it happens in the call to do_compact_page(). Got it, new
patch coming out now.

>
> ~Vitaly
>
>> +       INIT_LIST_HEAD(&new_zhdr->buddy);
>>         new_mapping = page_mapping(page);
>>         __ClearPageMovable(page);
>>         ClearPagePrivate(page);
>> --
>> 2.22.0.510.g264f2c817a-goog
>>


  reply	other threads:[~2019-07-15 19:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 16:47 Henry Burns
2019-07-15 17:22 ` Shakeel Butt
2019-07-15 18:43 ` Vitaly Wool
2019-07-15 19:56   ` Henry Burns [this message]
2019-07-15 21:21     ` Henry Burns

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGQXPTh-Z664T3Uxak-CiRn6Mc-s=esRzURLpwQaN+v0RgxFyg@mail.gmail.com' \
    --to=henryburns@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=jwadams@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shakeelb@google.com \
    --cc=vitaly.vul@sony.com \
    --cc=vitalywool@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox