linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
To: Yang Shi <shy828301@gmail.com>
Cc: "osalvador@suse.de" <osalvador@suse.de>,
	"hughd@google.com" <hughd@google.com>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: hwpoison: deal with page cache THP
Date: Wed, 8 Sep 2021 04:25:47 +0000	[thread overview]
Message-ID: <20210908042547.GA11650@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <CAHbLzkptCkXdVdG9mr1BU8TEyEpW57go_Pj1uVopkxORqYi8aw@mail.gmail.com>

On Tue, Sep 07, 2021 at 08:14:26PM -0700, Yang Shi wrote:
...
> > > > > > > 5. We also could define a new FGP flag to return poisoned page, NULL
> > > > > > > or error pointer. This also should need significant code change since
> > > > > > > a lt callsites need to be contemplated.
> > > > > >
> > > > > > Could you explain a little more about which callers should use the flag?
> > > > >
> > > > > Just to solve the above invalidate/truncate problem and page fault
> > > > > doesn't expect an error pointer. But it seems the above
> > > > > invalidate/truncate paths don't matter. Page fault should be the only
> > > > > user since page fault may need unlock the page if poisoned page is
> > > > > returned.
> >
> > Orignally PG_hwpoison is detected in page fault handler for file-backed pages
> > like below,
> >
> >   static vm_fault_t __do_fault(struct vm_fault *vmf)
> >   ...
> >           ret = vma->vm_ops->fault(vmf);
> >           if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY |
> >                               VM_FAULT_DONE_COW)))
> >                   return ret;
> >
> >           if (unlikely(PageHWPoison(vmf->page))) {
> >                   if (ret & VM_FAULT_LOCKED)
> >                           unlock_page(vmf->page);
> >                   put_page(vmf->page);
> >                   vmf->page = NULL;
> >                   return VM_FAULT_HWPOISON;
> >           }
> >
> > so it seems to me that if a filesystem switches to the new scheme of keeping
> > error pages in page cache, ->fault() callback for the filesystem needs to be
> > aware of hwpoisoned pages inside it and returns VM_FAULT_HWPOISON when it
> > detects an error page (maybe by detecting pagecache_get_page() to return
> > PTR_ERR(-EIO or -EHWPOISON) or some other ways).  In the other filesystems
> > with the old scheme, fault() callback does not return VM_FAULT_HWPOISON so
> > that page fault handler falls back to the generic PageHWPoison check above.
> 
> Yes, exactly. If we return ERR_PTR we need modify the above code
> accordingly. But returning the page, no change is required.
> 
> >
> > > >
> > > > It seems page fault check IS_ERR(page) then just return
> > > > VM_FAULT_HWPOISON. But I found a couple of places in shmem which want
> > > > to return head page then handle subpage or just return the page but
> > > > don't care the content of the page. They should ignore hwpoison. So I
> > > > guess we'd better to have a FGP flag for such cases.
> >
> > At least currently thp are supposed to be split before error handling.
> 
> Not for file THP.
> 
> > We could loosen this assumption to support hwpoison on a subpage of thp,
> > but I'm not sure whether that has some benefit.
> 
> I don't quite get your point. Currently the hwpoison flag is set on
> specific subpage instead of head page.

Sorry, I miss the case when thp split fails, then the thp has hwpoison
flag set on any subpage.  I only thought of the successful case, where the
resulting error page is no longer a subpage.

> 
> > And also this discussion makes me aware that we need to have a way to
> > prevent hwpoisoned pages from being used to thp collapse operation.
> 
> Actually not. The refcount from hwpoison could prevent it from
> collapsing. But if we return ERR_PTR (#3) we need extra code in
> khugepaged to handle it.

OK, so we already prevent it.

Thanks,
Naoya Horiguchi

> 
> So I realized #1 would require fewer changes. And leaving the page
> state check to callers seem reasonable since the callers usually check
> other states, e.g. uptodate.

  reply	other threads:[~2021-09-08  4:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 22:13 [PATCH] mm: hwpoison: deal with page cache THP Yang Shi
2021-08-26  6:17 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-26 20:03   ` Yang Shi
2021-08-26 22:03     ` Yang Shi
2021-08-27  3:57       ` HORIGUCHI NAOYA(堀口 直也)
2021-08-27  5:02         ` Yang Shi
2021-08-30 23:44           ` Yang Shi
2021-09-02  3:07             ` HORIGUCHI NAOYA(堀口 直也)
2021-09-02 18:32               ` Yang Shi
2021-09-03 11:53                 ` HORIGUCHI NAOYA(堀口 直也)
2021-09-03 18:01                   ` Yang Shi
2021-09-04  0:03                     ` Yang Shi
2021-09-07 21:34                       ` Yang Shi
2021-09-08  2:50                         ` ##freemail## " HORIGUCHI NAOYA(堀口 直也)
2021-09-08  3:14                           ` Yang Shi
2021-09-08  4:25                             ` HORIGUCHI NAOYA(堀口 直也) [this message]
2021-09-09 23:07                               ` 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=20210908042547.GA11650@hori.linux.bs1.fc.nec.co.jp \
    --to=naoya.horiguchi@nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=shy828301@gmail.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).