From: John Hubbard <jhubbard@nvidia.com>
To: Qiujun Huang <hqjagain@gmail.com>
Cc: <akpm@linux-foundation.org>, <ira.weiny@intel.com>,
<jgg@ziepe.ca>, <dan.j.williams@intel.com>, <rppt@linux.ibm.com>,
Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>,
<keith.busch@intel.com>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] mm:fix gup_pud_range
Date: Fri, 20 Sep 2019 18:19:07 -0700 [thread overview]
Message-ID: <ce863f5b-2337-1ac3-4d3d-d1d62acbba24@nvidia.com> (raw)
In-Reply-To: <CAJRQjodUajhYgQV7Z821qFwYzR0jSxJt54y=4XjqYW68mNMzTQ@mail.gmail.com>
On 9/20/19 5:33 PM, Qiujun Huang wrote:
>> On 9/20/19 8:51 AM, Qiujun Huang wrote:
...
>> It would be nice if this spelled out a little more clearly what's
>> wrong. I think you and Aneesh are saying that the entry is really
>> a swap entry, created by the MCE response to a bad page?
> do_machine_check->
> do_memory_failure->
> memory_failure->
> hwpoison_user_mappings
> will updated PUD level PTE entry as a swap entry.
>
> static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
> unsigned long address, void *arg)
> {
> ...
> if (PageHWPoison(page) && !(flags & TTU_IGNORE_HWPOISON)) {
> pteval = swp_entry_to_pte(make_hwpoison_entry(subpage));
OK, that helps. Let's add something approximately like this to the
commit description:
do_machine_check()
do_memory_failure()
memory_failure()
hw_poison_user_mappings()
try_to_unmap()
pteval = swp_entry_to_pte(make_hwpoison_entry(subpage));
...and now we have a swap entry that indicates that the page entry
refers to a bad (and poisoned) page of memory, but gup_fast() at this
level of the page table was ignoring swap entries, and incorrectly
assuming that "!pxd_none() == valid and present".
And this was not just a poisoned page problem, but a generaly swap entry
problem. So, any swap entry type (device memory migration, numa migration,
or just regular swapping) could lead to the same problem.
Fix this by checking for pxd_present(), instead of pxd_none().
> ...
>>
>>>
>>> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
>>> ---
>>> mm/gup.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/mm/gup.c b/mm/gup.c
>>> index 98f13ab..6157ed9 100644
>>> --- a/mm/gup.c
>>> +++ b/mm/gup.c
>>> @@ -2230,6 +2230,8 @@ static int gup_pud_range(p4d_t p4d, unsigned long addr, unsigned long end,
>>> next = pud_addr_end(addr, end);
>>> if (pud_none(pud))
>>> return 0;
>>> + if (unlikely(!pud_present(pud)))
>>> + return 0;
>>
>> If the MCE hwpoison behavior puts in swap entries, then it seems like all
>> page table walkers would need to check for p*d_present(), and maybe at all
>> levels too, right?
> I think so
>>
Should those changes be part of this fix, do you think?
thanks,
--
John Hubbard
NVIDIA
next prev parent reply other threads:[~2019-09-21 1:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-20 15:51 Qiujun Huang
2019-09-20 15:58 ` Aneesh Kumar K.V
2019-09-20 16:32 ` 黄秋钧
2019-09-20 19:37 ` John Hubbard
2019-09-21 0:20 ` 黄秋钧
2019-09-21 0:33 ` Qiujun Huang
2019-09-21 1:19 ` John Hubbard [this message]
2019-09-21 1:47 ` Qiujun Huang
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=ce863f5b-2337-1ac3-4d3d-d1d62acbba24@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=hqjagain@gmail.com \
--cc=ira.weiny@intel.com \
--cc=jgg@ziepe.ca \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@linux.ibm.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