linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Li Xinhai <lixinhai.lxh@gmail.com>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH] mm/gup.c: stricter check on THP migration entry during follow_pmd_mask
Date: Wed, 8 Dec 2021 15:35:23 -0800	[thread overview]
Message-ID: <20211208153523.bc1810ff2049fae53b4749c2@linux-foundation.org> (raw)
In-Reply-To: <20211208133930.599253-1-lixinhai.lxh@gmail.com>

On Wed,  8 Dec 2021 21:39:30 +0800 Li Xinhai <lixinhai.lxh@gmail.com> wrote:

> When BUG_ON check for THP migration entry, we need also consider
> !thp_migration_supported() case, becaouse it is invalid at the code
> context. Now, make this check been covered without adding extra cost.
> 
> Because pmdval instead of *pmd is read, so just call
> pmd_migration_entry_wait().
> 
> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
> ---
>  mm/gup.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 2c51e9748a6a..49f490bae030 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -644,10 +644,9 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma,
>  	if (!pmd_present(pmdval)) {
>  		if (likely(!(flags & FOLL_MIGRATION)))
>  			return no_page_table(vma, flags);
> -		VM_BUG_ON(thp_migration_supported() &&
> +		VM_BUG_ON(!thp_migration_supported() ||

I don't get this.  thp_migration_supported() evaluates to a
compile-time constant.  What is the point in doing a runtime BUG based
on a thing which is known at compile-time?

>  				  !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



  reply	other threads:[~2021-12-08 23:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 13:39 Li Xinhai
2021-12-08 23:35 ` Andrew Morton [this message]
2021-12-09  1:40   ` 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=20211208153523.bc1810ff2049fae53b4749c2@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=lixinhai.lxh@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