From: Yang Shi <shy828301@gmail.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>,
"Hugh Dickins" <hughd@google.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Oscar Salvador" <osalvador@suse.de>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linux MM" <linux-mm@kvack.org>,
"Linux FS-devel Mailing List" <linux-fsdevel@vger.kernel.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] mm: filemap: check if any subpage is hwpoisoned for PMD page fault
Date: Wed, 15 Sep 2021 10:28:38 -0700 [thread overview]
Message-ID: <CAHbLzkorHGOK-h5vxOYFuXVNWRBYBMARwYO_f2osSjFtvZCj8w@mail.gmail.com> (raw)
In-Reply-To: <20210915114613.lo26l64iqjz2qo6a@box.shutemov.name>
On Wed, Sep 15, 2021 at 4:46 AM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> On Tue, Sep 14, 2021 at 11:37:15AM -0700, Yang Shi wrote:
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 25fc46e87214..1765bf72ed16 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -3920,8 +3920,17 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
> > if (unlikely(!pmd_none(*vmf->pmd)))
> > goto out;
> >
> > - for (i = 0; i < HPAGE_PMD_NR; i++)
> > + for (i = 0; i < HPAGE_PMD_NR; i++) {
> > + /*
> > + * Just backoff if any subpage of a THP is corrupted otherwise
> > + * the corrupted page may mapped by PMD silently to escape the
> > + * check. This kind of THP just can be PTE mapped. Access to
> > + * the corrupted subpage should trigger SIGBUS as expected.
> > + */
> > + if (PageHWPoison(page + i))
> > + goto out;
> > flush_icache_page(vma, page + i);
> > + }
>
> This is somewhat costly.
>
> flush_icache_page() is empty on most archs so compiler makes the loop go
> away before the change. Also page->flags for most of the pages will not
> necessary be hot.
Yeah, good point.
>
> I wounder if we should consider making PG_hwpoison to cover full compound
> page. On marking page hwpoison we try to split it and mark relevant base
> page, if split fails -- mark full compound page.
We need extra bits to record exactly which subpage(s) are poisoned so
that the right page can be isolated when splitting.
>
> As alternative we can have one more flag that indicates that the compound
> page contains at least one hwpoisoned base page. We should have enough
> space in the first tail page.
Yes, actually I was thinking about the same thing too when debugging
this problem. I think this approach is more feasible. We could add a
new flag in the first tail page just like doublemap which indicates
there is/are poisoned subpage(s). It could be cleared when splitting.
I will try to implement this in the next version. Thanks a lot for the
suggestion.
>
> --
> Kirill A. Shutemov
next prev parent reply other threads:[~2021-09-15 17:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 18:37 [RFC PATCH 0/4] Solve silent data loss caused by poisoned page cache (shmem/tmpfs) Yang Shi
2021-09-14 18:37 ` [PATCH 1/4] mm: filemap: check if any subpage is hwpoisoned for PMD page fault Yang Shi
2021-09-15 11:46 ` Kirill A. Shutemov
2021-09-15 17:28 ` Yang Shi [this message]
2021-09-14 18:37 ` [PATCH 2/4] mm: khugepaged: check if file page is on LRU after locking page Yang Shi
2021-09-15 11:49 ` Kirill A. Shutemov
2021-09-15 17:48 ` Yang Shi
2021-09-15 23:00 ` Yang Shi
2021-09-15 23:10 ` Yang Shi
2021-09-14 18:37 ` [PATCH 3/4] mm: shmem: don't truncate page if memory failure happens Yang Shi
2021-09-21 9:49 ` Naoya Horiguchi
2021-09-21 19:34 ` Yang Shi
2021-09-14 18:37 ` [PATCH 4/4] mm: hwpoison: handle non-anonymous THP correctly Yang Shi
2021-09-21 9:50 ` Naoya Horiguchi
2021-09-21 19:46 ` Yang Shi
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=CAHbLzkorHGOK-h5vxOYFuXVNWRBYBMARwYO_f2osSjFtvZCj8w@mail.gmail.com \
--to=shy828301@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirill@shutemov.name \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=osalvador@suse.de \
--cc=willy@infradead.org \
/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).