All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Liu Shixin <liushixin2@huawei.com>,
	Yang Shi <shy828301@gmail.com>,
	Oscar Salvador <osalvador@suse.de>,
	Muchun Song <songmuchun@bytedance.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH v1 5/5] mm, hwpoison: enable memory error handling on 1GB hugepage
Date: Wed, 8 Jun 2022 20:57:24 +0800	[thread overview]
Message-ID: <5743855d-8f22-0d82-56c0-1ab61ad431b7@huawei.com> (raw)
In-Reply-To: <20220608061635.GA1413099@hori.linux.bs1.fc.nec.co.jp>

On 2022/6/8 14:16, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Tue, Jun 07, 2022 at 10:11:24PM +0800, Miaohe Lin wrote:
>> On 2022/6/2 13:06, Naoya Horiguchi wrote:
>>> From: Naoya Horiguchi <naoya.horiguchi@nec.com>
>>>
>>> Now error handling code is prepared, so remove the blocking code and
>>> enable memory error handling on 1GB hugepage.
>>>
>>
>> I'm nervous about this change. It seems there are many code paths not awared of pud swap entry.
>> I browsed some of them:
>> apply_to_pud_range called from apply_to_page_range:
>>
>> apply_to_pud_range:
>> 	next = pud_addr_end(addr, end);
>> 	if (pud_none(*pud) && !create)
>> 		continue;
>> 	if (WARN_ON_ONCE(pud_leaf(*pud)))
>> 		return -EINVAL;
>> 	if (!pud_none(*pud) && WARN_ON_ONCE(pud_bad(*pud))) {
>> 		if (!create)
>> 			continue;
>> 		pud_clear_bad(pud);
>> 	}
>> 	err = apply_to_pmd_range(mm, pud, addr, next,
>> 				 fn, data, create, mask);
>>
>> For !pud_present case, it will mostly reach apply_to_pmd_range and call pmd_offset on it. And invalid
>> pointer will be de-referenced.
> 
> apply_to_pmd_range() has BUG_ON(pud_huge(*pud)) and apply_to_pte_range() has
> BUG_ON(pmd_huge(*pmd)), so this page table walking code seems to not expect
> to handle pmd/pud level mapping.

Yes, you're right. These functions are not intended to handle pmd/pud level mapping.

> 
>>
>> Another example might be copy_pud_range and so on. So I think it might not be prepared to enable the
>> 1GB hugepage or all of these places should be fixed?
> 
> I think that most of page table walker for user address space should first
> check is_vm_hugetlb_page() and call hugetlb specific walking code for vma
> with VM_HUGETLB.
> copy_page_range() is a good example.  It calls copy_hugetlb_page_range()
> for vma with VM_HUGETLB and the function should support hwpoison entry.
> But I feel that I need testing for confirmation.

Sorry, I missed it should be called from hugetlb variants.

> 
> And I'm not sure that all other are prepared for non-present pud-mapping,
> so I'll need somehow code inspection and testing for each.

I browsed the code again, there still might be some problematic code paths:

1.For follow_pud_mask, !pud_present will mostly reach follow_pmd_mask(). This can be
called for hugetlb page. (Note gup_pud_range is fixed at 15494520b776 ("mm: fix gup_pud_range"))

2.Even for huge_pte_alloc, pud_offset will be called in pud_alloc. So pudp will be an invalid pointer.
And it will be de-referenced later.

I hope I'm not miss something again this time. ;)

> 
> Thanks,
> Naoya Horiguchi

Thanks!

> 


  reply	other threads:[~2022-06-08 12:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  5:06 [PATCH v1 0/5] mm, hwpoison: enable 1GB hugepage support Naoya Horiguchi
2022-06-02  5:06 ` [PATCH v1 1/5] mm, hwpoison, hugetlb: introduce SUBPAGE_INDEX_HWPOISON to save raw error page Naoya Horiguchi
2022-06-07 12:45   ` Miaohe Lin
2022-06-07 13:04   ` David Hildenbrand
2022-06-08  1:31     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-08  9:19       ` David Hildenbrand
2022-06-02  5:06 ` [PATCH v1 2/5] mm,hwpoison: set PG_hwpoison for busy hugetlb pages Naoya Horiguchi
2022-06-07 12:50   ` Miaohe Lin
2022-06-02  5:06 ` [PATCH v1 3/5] mm, hwpoison: make __page_handle_poison returns int Naoya Horiguchi
2022-06-07 12:54   ` Miaohe Lin
2022-06-08  1:40     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-02  5:06 ` [PATCH v1 4/5] mm, hwpoison: skip raw hwpoison page in freeing 1GB hugepage Naoya Horiguchi
2022-06-07 13:56   ` Miaohe Lin
2022-06-02  5:06 ` [PATCH v1 5/5] mm, hwpoison: enable memory error handling on " Naoya Horiguchi
2022-06-07 14:11   ` Miaohe Lin
2022-06-08  6:16     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-08 12:57       ` Miaohe Lin [this message]
2022-06-09  8:45         ` HORIGUCHI NAOYA(堀口 直也)
2022-06-09 11:28           ` Miaohe Lin

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=5743855d-8f22-0d82-56c0-1ab61ad431b7@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liushixin2@huawei.com \
    --cc=mike.kravetz@oracle.com \
    --cc=naoya.horiguchi@linux.dev \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.de \
    --cc=shy828301@gmail.com \
    --cc=songmuchun@bytedance.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.