From: Li Xinhai <lixinhai.lxh@gmail.com>
To: linux-mm@kvack.org, Zi Yan <ziy@nvidia.com>,
Huang Ying <ying.huang@intel.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: akpm@linux-foundation.org
Subject: Re: [PATCH V2] mm/gup.c: stricter check on THP migration entry during follow_pmd_mask
Date: Wed, 15 Dec 2021 20:47:47 +0800 [thread overview]
Message-ID: <e622a5b6-9ac3-e7c9-630b-364fee09601b@gmail.com> (raw)
In-Reply-To: <5c0f5b5c-7c22-a7ab-4add-fa6bd11f7af8@gmail.com>
On 12/11/21 11:16 PM, Li Xinhai wrote:
>
>
> On 12/11/21 11:10 PM, Li Xinhai wrote:
>> When BUG_ON check for THP migration entry, the exsiting code only check
>> thp_migration_supported case, but not for !thp_migration_supported case.
>> To make the BUG_ON check consistent, we need catch both cases.
>>
>> Move the BUG_ON check one step eariler, because if the bug happen we
>> should know it instead of depend on FOLL_MIGRATION been used by caller.
>>
>> Because pmdval instead of *pmd is read by the is_pmd_migration_entry()
>> check, the existing code don't help to avoid useless locking within
>> pmd_migration_entry_wait(), so remove that check.
>>
>> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
>> ---
> V1->V2:
> Move the BUG_ON() check before if(!(flags & FOLL_MIGRATION)); and add comments
> for it.
>
Yan, Ying and Kirill have been worked on this part of code, may help to review.
This change was based on my code review, no real bug has been observed.
>> mm/gup.c | 13 +++++++++----
>> 1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/gup.c b/mm/gup.c
>> index 2c51e9748a6a..94d0e586ca0b 100644
>> --- a/mm/gup.c
>> +++ b/mm/gup.c
>> @@ -642,12 +642,17 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma,
>> }
>> retry:
>> if (!pmd_present(pmdval)) {
>> + /*
>> + * Should never reach here, if thp migration is not supported;
>> + * Otherwise, it must be a thp miration entry.
>> + */
>> + VM_BUG_ON(!thp_migration_supported() ||
>> + !is_pmd_migration_entry(pmdval));
>> +
>> if (likely(!(flags & FOLL_MIGRATION)))
>> return no_page_table(vma, flags);
>> - VM_BUG_ON(thp_migration_supported() &&
>> - !is_pmd_migration_entry(pmdval));
>> - if (is_pmd_migration_entry(pmdval))
>> - pmd_migration_entry_wait(mm, pmd);
>> +
>> + pmd_migration_entry_wait(mm, pmd);
>> pmdval = READ_ONCE(*pmd);
>> /*
>> * MADV_DONTNEED may convert the pmd to null because
>>
next prev parent reply other threads:[~2021-12-15 12:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-11 15:10 [PATCH V2] mm/gup.c: stricter check on THP migration entry during follow_pmd_mask Li Xinhai
2021-12-11 15:16 ` Li Xinhai
2021-12-15 12:47 ` Li Xinhai [this message]
2021-12-15 14:46 ` Zi Yan
2021-12-16 2:00 ` Li Xinhai
2021-12-16 8:55 ` Huang, Ying
2021-12-16 13:16 ` Li Xinhai
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=e622a5b6-9ac3-e7c9-630b-364fee09601b@gmail.com \
--to=lixinhai.lxh@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=ying.huang@intel.com \
--cc=ziy@nvidia.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 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.