linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: David Rientjes <rientjes@google.com>
Cc: Frans Pop <elendil@planet.nl>, Jiri Kosina <jkosina@suse.cz>,
	Sven Geggus <lists@fuchsschwanzdomain.de>,
	Karol Lewandowski <karol.k.lewandowski@gmail.com>,
	Tobias Oetiker <tobi@oetiker.ch>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	David Miller <davem@davemloft.net>,
	Reinette Chatre <reinette.chatre@intel.com>,
	Kalle Valo <kalle.valo@iki.fi>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Mohamed Abbas <mohamed.abbas@intel.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Stephan von Krawczynski <skraw@ithnet.com>,
	Kernel Testers List <kernel-testers@vger.kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 4/5] page allocator: Pre-emptively wake kswapd when high-order watermarks are hit
Date: Fri, 23 Oct 2009 10:13:34 +0100	[thread overview]
Message-ID: <20091023091334.GV11778@csn.ul.ie> (raw)
In-Reply-To: <alpine.DEB.2.00.0910221227010.21601@chino.kir.corp.google.com>

On Thu, Oct 22, 2009 at 12:41:42PM -0700, David Rientjes wrote:
> On Thu, 22 Oct 2009, Mel Gorman wrote:
> 
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 7f2aa3e..851df40 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -1596,6 +1596,17 @@ try_next_zone:
> >  	return page;
> >  }
> >  
> > +static inline
> > +void wake_all_kswapd(unsigned int order, struct zonelist *zonelist,
> > +						enum zone_type high_zoneidx)
> > +{
> > +	struct zoneref *z;
> > +	struct zone *zone;
> > +
> > +	for_each_zone_zonelist(zone, z, zonelist, high_zoneidx)
> > +		wakeup_kswapd(zone, order);
> > +}
> > +
> >  static inline int
> >  should_alloc_retry(gfp_t gfp_mask, unsigned int order,
> >  				unsigned long pages_reclaimed)
> > @@ -1730,18 +1741,18 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
> >  			congestion_wait(BLK_RW_ASYNC, HZ/50);
> >  	} while (!page && (gfp_mask & __GFP_NOFAIL));
> >  
> > -	return page;
> > -}
> > -
> > -static inline
> > -void wake_all_kswapd(unsigned int order, struct zonelist *zonelist,
> > -						enum zone_type high_zoneidx)
> > -{
> > -	struct zoneref *z;
> > -	struct zone *zone;
> > +	/*
> > +	 * If after a high-order allocation we are now below watermarks,
> > +	 * pre-emptively kick kswapd rather than having the next allocation
> > +	 * fail and have to wake up kswapd, potentially failing GFP_ATOMIC
> > +	 * allocations or entering direct reclaim
> > +	 */
> > +	if (unlikely(order) && page && !zone_watermark_ok(preferred_zone, order,
> > +				preferred_zone->watermark[ALLOC_WMARK_LOW],
> > +				zone_idx(preferred_zone), ALLOC_WMARK_LOW))
> > +		wake_all_kswapd(order, zonelist, high_zoneidx);
> >  
> > -	for_each_zone_zonelist(zone, z, zonelist, high_zoneidx)
> > -		wakeup_kswapd(zone, order);
> > +	return page;
> >  }
> >  
> >  static inline int
> 
> Hmm, is this really supposed to be added to __alloc_pages_high_priority()?  
> By the patch description I was expecting kswapd to be woken up 
> preemptively whenever the preferred zone is below ALLOC_WMARK_LOW and 
> we're known to have just allocated at a higher order, not just when 
> current was oom killed (when we should already be freeing a _lot_ of 
> memory soon) or is doing a higher order allocation during direct reclaim.
> 

It was a somewhat arbitrary choice to have it trigger in the event high
priority allocations were happening frequently.

> For the best coverage, it would have to be add the branch to the fastpath.  

Agreed - specifically at the end of __alloc_pages_nodemask()

> That seems fine for a debugging aid and to see if progress is being made 
> on the GFP_ATOMIC allocation issues, but doesn't seem like it should make 
> its way to mainline, the subsequent GFP_ATOMIC allocation could already be 
> happening and in the page allocator's slowpath at this point that this 
> wakeup becomes unnecessary.
> 
> If this is moved to the fastpath, why is this wake_all_kswapd() and not
> wakeup_kswapd(preferred_zone, order)?  Do we need to kick kswapd in all 
> zones even though they may be free just because preferred_zone is now 
> below the watermark?
> 

It probably makes no difference as zones are checked for their watermarks
before any real work happens. However, even if this patch makes a difference,
I don't want to see it merged.  At best, it is an extremely heavy-handed
hack which is why I asked for it to be tested in isolation. It shouldn't
be necessary at all because sort of pre-emptive waking of kswapd was never
necessary before.

> Wouldn't it be better to do this on page_zone(page) instead of 
> preferred_zone anyway?
> 

No. The preferred_zone is the zone we should be allocating from. If we
failed to allocate from it, it implies the watermarks are not being met
so we want to wake it.

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-10-23  9:13 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22 14:22 [PATCH 0/5] Candidate fix for increased number of GFP_ATOMIC failures V2 Mel Gorman
2009-10-22 14:22 ` [PATCH 1/5] page allocator: Always wake kswapd when restarting an allocation attempt after direct reclaim failed Mel Gorman
2009-10-22 14:24   ` [PATCH 1/5 Against 2.6.31.4] " Mel Gorman
2009-10-22 14:41   ` [PATCH 1/5] " Pekka Enberg
2009-10-22 15:49     ` Mel Gorman
2009-10-26  1:11   ` KOSAKI Motohiro
2009-10-26  7:10     ` David Rientjes
2009-10-27  2:42       ` KOSAKI Motohiro
2009-10-27 12:27         ` Mel Gorman
2009-10-22 14:22 ` [PATCH 2/5] page allocator: Do not allow interrupts to use ALLOC_HARDER Mel Gorman
2009-10-22 16:33   ` Stephan von Krawczynski
2009-10-22 16:37     ` Mel Gorman
2009-10-23  9:57       ` Stephan von Krawczynski
2009-10-24  2:03       ` Christoph Lameter
2009-10-27 15:19         ` Mel Gorman
2009-10-25 12:57       ` Stephan von Krawczynski
2009-10-26  1:15   ` KOSAKI Motohiro
2009-10-22 14:22 ` [PATCH 3/5] vmscan: Force kswapd to take notice faster when high-order watermarks are being hit Mel Gorman
2009-10-23 17:52   ` Vincent Li
2009-10-23 22:12     ` Vincent Li
2009-10-27 10:38     ` Mel Gorman
2009-10-27  2:42   ` KOSAKI Motohiro
2009-10-22 14:22 ` [PATCH 4/5] page allocator: Pre-emptively wake kswapd when high-order watermarks are hit Mel Gorman
2009-10-22 19:41   ` David Rientjes
2009-10-23  9:13     ` Mel Gorman [this message]
2009-10-23  9:36       ` David Rientjes
2009-10-23 11:25         ` Mel Gorman
2009-10-23 11:31           ` Tobias Oetiker
2009-10-23 13:39             ` Mel Gorman
2009-10-27  2:42   ` KOSAKI Motohiro
2009-10-27 15:26     ` Mel Gorman
2009-10-22 14:22 ` [PATCH 5/5] ONLY-APPLY-IF-STILL-FAILING Revert 373c0a7e, 8aa7e847: Fix congestion_wait() sync/async vs read/write confusion Mel Gorman
2009-10-22 14:25   ` Against 2.6.31.4 [PATCH 5/5] " Mel Gorman
2009-10-22 21:49   ` [PATCH 5/5] ONLY-APPLY-IF-STILL-FAILING " Jens Axboe
2009-10-27  2:42   ` KOSAKI Motohiro
2009-10-27 10:29     ` Frans Pop
2009-10-22 14:47 ` [PATCH 0/5] Candidate fix for increased number of GFP_ATOMIC failures V2 Pekka Enberg
2009-10-22 16:03   ` Mel Gorman
2009-10-24  1:52   ` Christoph Lameter
2009-10-24  6:48     ` Pekka Enberg
2009-10-24  6:48     ` Pekka Enberg
2009-10-22 15:43 ` reinette chatre
2009-10-27 10:40   ` Mel Gorman
2009-10-27 23:34     ` reinette chatre
2009-10-23  7:31 ` Sven Geggus
2009-10-23 16:58 ` Karol Lewandowski
2009-10-23 21:12   ` Karol Lewandowski
2009-10-24 13:46     ` Mel LKML
2009-10-28 11:42       ` Karol Lewandowski
2009-10-28 11:59         ` Mel Gorman
2009-10-30 14:23           ` Karol Lewandowski
2009-11-02 20:30             ` Mel Gorman
2009-11-04  2:03               ` Karol Lewandowski
2009-10-28 12:55         ` Tobi Oetiker
2009-10-24 13:51 ` Frans Pop
2009-10-24 14:02 ` Sven Geggus
2009-10-27 13:27   ` Mel Gorman
2009-10-26 17:37 ` Tobias Oetiker
2009-10-27 15:36   ` Mel Gorman
2009-10-26 22:17 ` Frans Pop
2009-10-26 23:45   ` Frans Pop
2009-11-06  6:03 ` Tobias Diedrich
2009-11-06  9:24   ` Mel Gorman
2009-11-06  9:24   ` Mel Gorman
2009-11-06 11:15     ` Tobias Diedrich

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=20091023091334.GV11778@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=bzolnier@gmail.com \
    --cc=davem@davemloft.net \
    --cc=elendil@planet.nl \
    --cc=gregkh@suse.de \
    --cc=jens.axboe@oracle.com \
    --cc=jkosina@suse.cz \
    --cc=kalle.valo@iki.fi \
    --cc=karol.k.lewandowski@gmail.com \
    --cc=kernel-testers@vger.kernel.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linville@tuxdriver.com \
    --cc=lists@fuchsschwanzdomain.de \
    --cc=mohamed.abbas@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=reinette.chatre@intel.com \
    --cc=rientjes@google.com \
    --cc=rjw@sisk.pl \
    --cc=skraw@ithnet.com \
    --cc=tobi@oetiker.ch \
    /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