linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: zhong jiang <zhongjiang@huawei.com>
Cc: akpm@linux-foundation.org, vbabka@suse.cz, rientjes@google.com,
	qiuxishi@huawei.com, linux-mm@kvack.org
Subject: Re: [PATCH] mm/hugetlb: fix race when migrate pages.
Date: Tue, 19 Jul 2016 13:10:03 +0200	[thread overview]
Message-ID: <20160719111003.GG9486@dhcp22.suse.cz> (raw)
In-Reply-To: <578DF872.3050507@huawei.com>

On Tue 19-07-16 17:52:50, zhong jiang wrote:
> On 2016/7/19 17:17, Michal Hocko wrote:
[...]
> > OK, so this states the problem. Although it would be helpful to be
> > specific about which BUG has triggered because the above line doesn't
> > match any in the current code. I assume this is 
> >
> > BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte))
> >
> > in huge_pte_alloc. Now the changelog is silent about what the actual
> > problem is and what is the fix. Could you add this information please?
>   Yes, it hit this BUG_ON() you had mentioned.  The pmd share function enable,  when
>   I run online-offline memory , That will lead to pte_huge() return false.  beacuse
>  it refer to the pmd may be ongoing  migration.

OK, I see. But is the proposed fix correct? AFAIU you are retrying the
VMA walk and nothing really prevents huge_pte_offset returning the same
spte, right?

>  Thanks
>  zhong jiang
> >> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> >> ---
> >>  mm/hugetlb.c | 9 ++++++++-
> >>  1 file changed, 8 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> >> index 6384dfd..1b54d7a 100644
> >> --- a/mm/hugetlb.c
> >> +++ b/mm/hugetlb.c
> >> @@ -4213,13 +4213,14 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
> >>  	struct vm_area_struct *svma;
> >>  	unsigned long saddr;
> >>  	pte_t *spte = NULL;
> >> -	pte_t *pte;
> >> +	pte_t *pte, entry;
> >>  	spinlock_t *ptl;
> >>  
> >>  	if (!vma_shareable(vma, addr))
> >>  		return (pte_t *)pmd_alloc(mm, pud, addr);
> >>  
> >>  	i_mmap_lock_write(mapping);
> >> +retry:
> >>  	vma_interval_tree_foreach(svma, &mapping->i_mmap, idx, idx) {
> >>  		if (svma == vma)
> >>  			continue;
> >> @@ -4240,6 +4241,12 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
> >>  
> >>  	ptl = huge_pte_lockptr(hstate_vma(vma), mm, spte);
> >>  	spin_lock(ptl);
> >> +	entry = huge_ptep_get(spte);
> >> + 	if (is_hugetlb_entry_migration(entry) || 
> >> +			is_hugetlb_entry_hwpoisoned(entry)) {
> >> +		spin_unlock(ptl);
> >> +		goto retry;
> >> +	}	
> >>  	if (pud_none(*pud)) {
> >>  		pud_populate(mm, pud,
> >>  				(pmd_t *)((unsigned long)spte & PAGE_MASK));
> >> -- 
> >> 1.8.3.1
> >>
> >> --
> >> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> >> the body to majordomo@kvack.org.  For more info on Linux MM,
> >> see: http://www.linux-mm.org/ .
> >> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> 

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-07-19 11:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19  2:59 [PATCH] mm/hugetlb: fix race when migrate pages zhongjiang
2016-07-19  9:17 ` Michal Hocko
2016-07-19  9:52   ` zhong jiang
2016-07-19 11:10     ` Michal Hocko [this message]
2016-07-19 11:31       ` zhong jiang
2016-07-19 11:43       ` zhong jiang
2016-07-19 11:59         ` Michal Hocko
2016-07-19 12:04           ` zhong jiang

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=20160719111003.GG9486@dhcp22.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=qiuxishi@huawei.com \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    --cc=zhongjiang@huawei.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;
as well as URLs for NNTP newsgroup(s).