Re: [PATCH 3/4] mm: unreserve highatomic free pages fully before OOM

From: Michal Hocko
Date: Tue Oct 11 2016 - 04:02:12 EST


On Tue 11-10-16 16:37:16, Minchan Kim wrote:
> On Tue, Oct 11, 2016 at 09:26:06AM +0200, Michal Hocko wrote:
> > On Tue 11-10-16 16:09:45, Minchan Kim wrote:
[...]
> > > @@ -2154,12 +2156,24 @@ static void unreserve_highatomic_pageblock(const struct alloc_context *ac)
> > > * may increase.
> > > */
> > > set_pageblock_migratetype(page, ac->migratetype);
> > > - move_freepages_block(zone, page, ac->migratetype);
> > > - spin_unlock_irqrestore(&zone->lock, flags);
> > > - return;
> > > + ret = move_freepages_block(zone, page,
> > > + ac->migratetype);
> > > + /*
> > > + * By race with page freeing functions, !highatomic
> > > + * pageblocks can have free pages in highatomic free
> > > + * list so if drain is true, try to unreserve every
> > > + * free pages in highatomic free list without bailing
> > > + * out.
> > > + */
> > > + if (!drain) {
> >
> > if (ret)
> > > + spin_unlock_irqrestore(&zone->lock, flags);
> > > + return ret;
> > > + }
> >
> > arguably this would work better also for !drain case which currently
> > tries to unreserve but in case of the race it would do nothing.
>
> I thought it but I was afraid if you say again it's over complicated.

Well, maybe there is even better/easier solution. Anyway, if
I were you I would just split it into two patches. The first
to unreserve from shoudl_reclaim_retry and the later to make
unreserve_highatomic_pageblock more reliable.

> I will do it with your SOB in next spin.

ok, thanks!
--
Michal Hocko
SUSE Labs