From: Oscar Salvador <osalvador@suse.de>
To: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
Cc: "yaoaili126@163.com" <yaoaili126@163.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"YANGFENG1@kingsoft.com" <YANGFENG1@kingsoft.com>,
Aili Yao <yaoaili@kingsoft.com>,
"willy@infradead.org" <willy@infradead.org>
Subject: Re: [PATCH] Fix incorrect compound page flags store
Date: Fri, 18 Sep 2020 11:35:02 +0200 [thread overview]
Message-ID: <20200918093458.GA14286@linux> (raw)
In-Reply-To: <20200908090555.GA17382@hori.linux.bs1.fc.nec.co.jp>
On Tue, Sep 08, 2020 at 09:05:56AM +0000, HORIGUCHI NAOYA(堀口 直也) wrote:
> > > thp just after passing over the following block:
> >
> >
> >
> > >
> > > 1408 if (PageTransHuge(hpage)) {
> > > 1409 if (try_to_split_thp_page(p, "Memory Failure") < 0) {
> > > 1410 action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED);
> > > 1411 return -EBUSY;
> > > 1412 }
> > > 1413 VM_BUG_ON_PAGE(!page_count(p), p);
> > > 1414 }
> > >
> > > So I feel that some check might be added after holding page lock to avoid
> > > that case. Or acutally, it might better that moving the above block into
> > > page lock is more better for simpler code.
> >
> > I will have a look at this.
>
> Thank you!
Hi Naoya,
I have been taking a look at this, and unless I am missing something obvious I
do not think that a new THP (containing the page) can be collapsed under us:
We do take a refcount on the page by means of get_hwpoison_page.
We could only have done that if the page was mapped, so its refcount was already
above 0.
Then we split the THP, and the refcount/mapcount go to the page we are trying to
poison.
At this point the page should add least have refcount > 1 mapcount >= 1.
After that, let us assume that a new THP is trying to be collapsed by means of
khugepaged thread or madvise MADV_HUGEPAGE.
khugepaged_scan_pmd() scans all ptes from [pte#0..pte#511] to see if they can
be collapsed, and one of the things it does is checking the page's refcount/
mappcount by calling is_refcount_suitable().
expected_refcount = total_mapcount(page);
return page_count(page) == expected_refcount;
We do have an extra pin from memory_failure, so this is going to fail because
page: refcount = 2 , mapcount = 1
Beware that the page must sitll be mapped somehow, otherwise the PageLRU check
from above should have failed with the same result:
if (!PageLRU(page)) {
result = SCAN_PAGE_LRU;
goto out_unmap;
}
So, I do not think the page can be collapsed into a new THP after we have split
it here, but as I said, I might be missing something.
Thoughts?
--
Oscar Salvador
SUSE L3
next prev parent reply other threads:[~2020-09-18 9:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 3:44 yaoaili126
2020-09-08 7:02 ` HORIGUCHI NAOYA(堀口 直也)
2020-09-08 7:18 ` yaoaili [么爱利]
2020-09-08 7:26 ` Oscar Salvador
2020-09-08 8:02 ` yaoaili [么爱利]
2020-09-08 8:09 ` Oscar Salvador
2020-09-08 8:36 ` HORIGUCHI NAOYA(堀口 直也)
2020-09-08 8:48 ` yaoaili [么爱利]
2020-09-08 9:00 ` HORIGUCHI NAOYA(堀口 直也)
2020-09-08 9:10 ` yaoaili [么爱利]
2020-09-08 8:51 ` Oscar Salvador
2020-09-08 9:05 ` HORIGUCHI NAOYA(堀口 直也)
2020-09-18 9:35 ` Oscar Salvador [this message]
2020-09-25 1:18 ` HORIGUCHI NAOYA(堀口 直也)
2020-09-25 1:55 ` yaoaili [么爱利]
2020-09-25 4:35 ` HORIGUCHI NAOYA(堀口 直也)
2020-09-25 5:52 ` yaoaili [么爱利]
-- strict thread matches above, loose matches on Subject: below --
2020-09-02 11:24 [PATCH] fix " yaoaili [么爱利]
2020-09-02 11:35 ` Matthew Wilcox
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=20200918093458.GA14286@linux \
--to=osalvador@suse.de \
--cc=YANGFENG1@kingsoft.com \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=willy@infradead.org \
--cc=yaoaili126@163.com \
--cc=yaoaili@kingsoft.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