linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jue Wang <juew@google.com>
To: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
Cc: Hugh Dickins <hughd@google.com>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Oscar Salvador <osalvador@suse.de>,
	Tony Luck <tony.luck@intel.com>,
	 Matthew Wilcox <willy@infradead.org>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	 Greg Thelen <gthelen@google.com>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH v1] mm, hwpoison: enable error handling on shmem thp
Date: Thu, 11 Mar 2021 11:32:12 -0800	[thread overview]
Message-ID: <CAPcxDJ6D5OS+XRYbqpr-7bhYCySX=jdPZdZvQL1ecSrQoDEieg@mail.gmail.com> (raw)
In-Reply-To: <20210311151446.GA28650@hori.linux.bs1.fc.nec.co.jp>

Huge thanks to Hugh for his expertise in shmem thps and forwarding this message!

Hi Naoya,

This is the first time I reply to an email in a Linux upstream thread,
apologies for any technical issues due to my email client. And my
apologies for the state of the whole patch not quite shareable with
upstream due to some kernel differences.

Some fyi comment inline.

Thanks,
-Jue





On Thu, Mar 11, 2021 at 7:14 AM HORIGUCHI NAOYA(堀口 直也)
<naoya.horiguchi@nec.com> wrote:
>
> On Wed, Mar 10, 2021 at 11:22:18PM -0800, Hugh Dickins wrote:
> > On Tue, 9 Feb 2021, Naoya Horiguchi wrote:
> >
> > > From: Naoya Horiguchi <naoya.horiguchi@nec.com>
> > >
> > > Currently hwpoison code checks PageAnon() for thp and refuses to handle
> > > errors on non-anonymous thps (just for historical reason).  We now
> > > support non-anonymou thp like shmem one, so this patch suggests to enable
> > > to handle shmem thps. Fortunately, we already have can_split_huge_page()
> > > to check if a give thp is splittable, so this patch relies on it.
> >
> > Fortunately? I don't understand. Why call can_split_huge_page()
> > at all, instead of simply trying split_huge_page() directly?
>
> The background of this change was that I've experienced triggering
> VM_BUG_ON_PAGE() at the beginning of split_huge_page_to_list() in the older
> kernel (I forgot specific condition of the BUG_ON).  I thought that that was
> caused by race between thp allocation and memory_failure.  So I wanted to
> have some rigid way to confirm that a given thp is splittable.  Then I found
> can_split_huge_page(), which sounds suitable to me because I expected the API
> to be maintained by thp subsystem.
>
> But I rethink that split_huge_page_to_list() seems to have different set of
> VM_BUG_ON_PAGE()s now, and anyway split_huge_page_to_list() calls
> can_split_huge_page() internally, so I might have wrongly read the code.
>
> > And could it do better than -EBUSY when split_huge_page() fails?
>
> Yes it could.
>
> >
> > >
> > > Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
> >
> > Thanks for trying to add shmem+file THP support, but I think this
> > does not work as intended - Andrew, if Naoya agrees, please drop from
> > mmotm for now, the fixup needed will be more than a line or two.
>
> I agree to drop it. I need research more to address the following comments.
>
> >
> > I'm not much into memory-failure myself, but Jue discovered that the
> > SIGBUS never arrives: because split_huge_page() on a shmem or file
> > THP unmaps all its pmds and ptes, and (unlike with anon) leaves them
> > unmapped - in normal circumstances, to be faulted back on demand.
> > So the page_mapped() check in hwpoison_user_mappings() fails,
> > and the intended SIGBUS is not delivered.
>
> Thanks for the information.  The split behaves quite differently between
> for anon thp and for shmem thp.  I saw some unexpected behavior in my
> testing, maybe that's due to the difference.
>
> >
> > (Or, is it acceptable that the SIGBUS is not delivered to those who
> > have the huge page mapped: should it get delivered later, to anyone
> > who faults back in the bad 4k?)
>
> Later access should report error in page fault, so the worst scenario
> of consuming corrupted data does not happen, but precautionary signal
> does not work so it's not acceptable.
In our experiment with SHMEM THPs, later accesses resulted in a zero
page allocated instead of a SIGBUS with BUS_MCEERR_AR reported by the
page fault handler. That part might be an opportunity to prevent some
silent data corruption just in case.
>
> >
> > We believe the tokill list has to be set up earlier, before
> > split_huge_page() is called, then passed in to hwpoison_user_mappings().
> >
> > Sorry, we don't have a proper patch for that right now, but I expect
> > you can see what needs to be done.  But something we found on the way,
> > we do have a patch for: add_to_kill() uses page_address_in_vma(), but
> > that has not been used on file THP tails before - fix appended at the
> > end below, so as not to waste your time on that bit.
> >
>
> Thank you very much, I'll work on top of it.
>
> Thanks,
> Naoya Horiguchi
>
> ...
> >
> > [PATCH] mm: fix page_address_in_vma() on file THP tails
> > From: Jue Wang <juew@google.com>
> >
> > Anon THP tails were already supported, but memory-failure now needs to use
> > page_address_in_vma() on file THP tails, which its page->mapping check did
> > not permit: fix it.
> >
> > Signed-off-by: Jue Wang <juew@google.com>
> > Signed-off-by: Hugh Dickins <hughd@google.com>
> > ---
> >
> >  mm/rmap.c |    8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > --- 5.12-rc2/mm/rmap.c        2021-02-28 16:58:57.950450151 -0800
> > +++ linux/mm/rmap.c   2021-03-10 20:29:21.591475177 -0800
> > @@ -717,11 +717,11 @@ unsigned long page_address_in_vma(struct
> >               if (!vma->anon_vma || !page__anon_vma ||
> >                   vma->anon_vma->root != page__anon_vma->root)
> >                       return -EFAULT;
> > -     } else if (page->mapping) {
> > -             if (!vma->vm_file || vma->vm_file->f_mapping != page->mapping)
> > -                     return -EFAULT;
> > -     } else
> > +     } else if (!vma->vm_file) {
> > +             return -EFAULT;
> > +     } else if (vma->vm_file->f_mapping != compound_head(page)->mapping) {
> >               return -EFAULT;
> > +     }
> >       address = __vma_address(page, vma);
> >       if (unlikely(address < vma->vm_start || address >= vma->vm_end))
> >               return -EFAULT;
> >


  reply	other threads:[~2021-03-11 19:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09  6:21 [PATCH v1] mm, hwpoison: enable error handling on shmem thp Naoya Horiguchi
2021-02-09 19:46 ` Andrew Morton
2021-02-09 23:51   ` Naoya Horiguchi
2021-02-11  8:06 ` Oscar Salvador
2021-03-11  7:22 ` Hugh Dickins
2021-03-11 14:45   ` Matthew Wilcox
2021-03-11 15:14   ` HORIGUCHI NAOYA(堀口 直也)
2021-03-11 19:32     ` Jue Wang [this message]
2021-03-11 22:00       ` Hugh Dickins
2021-03-18 18:33         ` 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='CAPcxDJ6D5OS+XRYbqpr-7bhYCySX=jdPZdZvQL1ecSrQoDEieg@mail.gmail.com' \
    --to=juew@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=gthelen@google.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=nao.horiguchi@gmail.com \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.de \
    --cc=tony.luck@intel.com \
    --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).