Re: [PATCH] [8/16] POISON: Add various poison checks in mm/memory.c

Johannes Weiner
2009-04-07T20:17:22Z

On Tue, Apr 07, 2009 at 09:31:45PM +0200, Andi Kleen wrote:
> On Tue, Apr 07, 2009 at 09:03:30PM +0200, Johannes Weiner wrote:
> > On Tue, Apr 07, 2009 at 05:10:05PM +0200, Andi Kleen wrote:
> > >
> > > Bail out early when poisoned pages are found in page fault handling.
> > > Since they are poisoned they should not be mapped freshly
> > > into processes.
> > >
> > > This is generally handled in the same way as OOM, just a different
> > > error code is returned to the architecture code.
> > >
> > > Signed-off-by: Andi Kleen <ak@linux.intel.com>
> > >
> > > ---
> > > mm/memory.c | 7 +++++++
> > > 1 file changed, 7 insertions(+)
> > >
> > > Index: linux/mm/memory.c
> > > ===================================================================
> > > --- linux.orig/mm/memory.c 2009-04-07 16:39:39.000000000 +0200
> > > +++ linux/mm/memory.c 2009-04-07 16:39:39.000000000 +0200
> > > @@ -2560,6 +2560,10 @@
> > > goto oom;
> > > __SetPageUptodate(page);
> > >
> > > + /* Kludge for now until we take poisoned pages out of the free lists */
> > > + if (unlikely(PagePoison(page)))
> > > + return VM_FAULT_POISON;
> > > +
> >
> > When memory_failure() hits a page still on the free list
>
> It won't free it then. Later on it will take it out of the free lists,
> but that code is not written yet.
>
> > (!page_count()) then the get_page() in memory_failure() will trigger a
> > VM_BUG. So either this check is unneeded or it should be
>
> So no bug
> > get_page_unless_zero() in memory_failure()?
>
> That's not what this is handling. The issue is that sometimes
> the process can still freeing it and we need to make sure it
> never hits the free lists.

I think we missed each other here. I wasn't talking about _why_ you
take that reference -- that is clear. But I see these two
possibilities:

a) memory_failure() is called on a page on the free list, the
get_page() will trigger a bug because the refcount is 0

b) if that is not possible, the above check is not needed