From: Mike Kravetz <mike.kravetz@oracle.com>
To: Michal Hocko <mhocko@suse.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Li Wang <liwang@redhat.com>, Linux-MM <linux-mm@kvack.org>,
LTP List <ltp@lists.linux.it>,
"xishi.qiuxishi@alibaba-inc.com" <xishi.qiuxishi@alibaba-inc.com>,
Cyril Hrubis <chrubis@suse.cz>
Subject: Re: [MM Bug?] mmap() triggers SIGBUS while doing the numa_move_pages() for offlined hugepage in background
Date: Wed, 7 Aug 2019 08:10:27 -0700 [thread overview]
Message-ID: <d2bb2c10-a08c-dfde-a51b-827a85b50946@oracle.com> (raw)
In-Reply-To: <20190807073909.GL11812@dhcp22.suse.cz>
On 8/7/19 12:39 AM, Michal Hocko wrote:
> On Tue 06-08-19 17:07:25, Mike Kravetz wrote:
>> On 8/5/19 10:36 AM, Mike Kravetz wrote:
>>>>>>> Can you try this patch in your environment? I am not sure if it will
>>>>>>> be the final fix, but just wanted to see if it addresses issue for you.
>>>>>>>
>>>>>>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>>>>>>> index ede7e7f5d1ab..f3156c5432e3 100644
>>>>>>> --- a/mm/hugetlb.c
>>>>>>> +++ b/mm/hugetlb.c
>>>>>>> @@ -3856,6 +3856,20 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
>>>>>>>
>>>>>>> page = alloc_huge_page(vma, haddr, 0);
>>>>>>> if (IS_ERR(page)) {
>>>>>>> + /*
>>>>>>> + * We could race with page migration (try_to_unmap_one)
>>>>>>> + * which is modifying page table with lock. However,
>>>>>>> + * we are not holding lock here. Before returning
>>>>>>> + * error that will SIGBUS caller, get ptl and make
>>>>>>> + * sure there really is no entry.
>>>>>>> + */
>>>>>>> + ptl = huge_pte_lock(h, mm, ptep);
>>>>>>> + if (!huge_pte_none(huge_ptep_get(ptep))) {
>>>>>>> + ret = 0;
>>>>>>> + spin_unlock(ptl);
>>>>>>> + goto out;
>>>>>>> + }
>>>>>>> + spin_unlock(ptl);
>>>>>>
>>>>>> Thanks you for investigation, Mike.
>>>>>> I tried this change and found no SIGBUS, so it works well.
>>
>> Here is another way to address the issue. Take the hugetlb fault mutex in
>> the migration code when modifying the page tables. IIUC, the fault mutex
>> was introduced to prevent this same issue when there were two page faults
>> on the same page (and we were unable to allocate an 'extra' page). The
>> downside to such an approach is that we add more hugetlbfs specific code
>> to try_to_unmap_one.
>
> I would rather go with the hugetlb_no_page which is better isolated.
Sounds good.
And, after more thought modifying try_to_unmap_one will not work. Why?
It violates lock ordering. Current ordering is hugetlb_mutex, page lock
then page table lock. The page lock is taken before calling try_to_unmap_one.
In addition, try_to_unmap is unmapping from multiple vmas so we can not
know the values for hugetlb hash before taking page lock as the hash values
are vma specific. So, without many modifications we can not add hugetlb
fault mutex to this code path.
--
Mike Kravetz
next prev parent reply other threads:[~2019-08-07 15:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 5:17 [MM Bug?] mmap() triggers SIGBUS while doing the numa_move_pages() for offlined hugepage in background Li Wang
2019-07-29 19:00 ` Mike Kravetz
2019-07-30 6:29 ` Li Wang
2019-07-31 0:44 ` Mike Kravetz
2019-08-02 0:19 ` Mike Kravetz
2019-08-02 4:15 ` Naoya Horiguchi
2019-08-02 17:42 ` Mike Kravetz
2019-08-05 0:40 ` Naoya Horiguchi
2019-08-05 8:57 ` Michal Hocko
2019-08-05 17:36 ` Mike Kravetz
2019-08-07 0:07 ` Mike Kravetz
2019-08-07 7:39 ` Michal Hocko
2019-08-07 15:10 ` Mike Kravetz [this message]
2019-08-02 9:59 ` Li Wang
2019-07-30 6:38 ` Li Wang
2019-08-02 3:48 ` Naoya Horiguchi
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=d2bb2c10-a08c-dfde-a51b-827a85b50946@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=chrubis@suse.cz \
--cc=linux-mm@kvack.org \
--cc=liwang@redhat.com \
--cc=ltp@lists.linux.it \
--cc=mhocko@suse.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=xishi.qiuxishi@alibaba-inc.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).