Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757600Ab0DGS3j (ORCPT ); Wed, 7 Apr 2010 14:29:39 -0400 Received: from gir.skynet.ie ([193.1.99.77]:50199 "EHLO gir.skynet.ie" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757481Ab0DGS3g (ORCPT ); Wed, 7 Apr 2010 14:29:36 -0400 Date: Wed, 7 Apr 2010 19:29:16 +0100 From: Mel Gorman To: Andrew Morton Cc: Andrea Arcangeli , Christoph Lameter , Adam Litke , Avi Kivity , David Rientjes , Minchan Kim , KAMEZAWA Hiroyuki , KOSAKI Motohiro , Rik van Riel , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 11/14] Direct compact when a high-order allocation fails Message-ID: <20100407182916.GY17882@csn.ul.ie> References: <1270224168-14775-1-git-send-email-mel@csn.ul.ie> <1270224168-14775-12-git-send-email-mel@csn.ul.ie> <20100406170603.8a999dc2.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20100406170603.8a999dc2.akpm@linux-foundation.org> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5540 Lines: 186 On Tue, Apr 06, 2010 at 05:06:03PM -0700, Andrew Morton wrote: > > @@ -896,6 +904,9 @@ static const char * const vmstat_text[] = { > > "compact_blocks_moved", > > "compact_pages_moved", > > "compact_pagemigrate_failed", > > + "compact_stall", > > + "compact_fail", > > + "compact_success", > > CONFIG_COMPACTION=n? > This patch goes on top of the series. It looks big but it's mainly moving code. ==== CUT HERE ==== mm,compaction: Do not display compaction-related stats when !CONFIG_COMPACTION Although compaction can be disabled from .config, the vmstat entries still exist. This patch removes the vmstat entries. As page_alloc.c refers directly to the counters, the patch introduces __alloc_pages_direct_compact() to isolate use of the counters. Signed-off-by: Mel Gorman --- include/linux/vmstat.h | 2 + mm/page_alloc.c | 92 ++++++++++++++++++++++++++++++++--------------- mm/vmstat.c | 2 + 3 files changed, 66 insertions(+), 30 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index b4b4d34..7f43ccd 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -43,8 +43,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY, KSWAPD_SKIP_CONGESTION_WAIT, PAGEOUTRUN, ALLOCSTALL, PGROTATED, +#ifdef CONFIG_COMPACTION COMPACTBLOCKS, COMPACTPAGES, COMPACTPAGEFAILED, COMPACTSTALL, COMPACTFAIL, COMPACTSUCCESS, +#endif #ifdef CONFIG_HUGETLB_PAGE HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL, #endif diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 46f6be4..514cc96 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1756,6 +1756,59 @@ out: return page; } +#ifdef CONFIG_COMPACTION +/* Try memory compaction for high-order allocations before reclaim */ +static struct page * +__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, + struct zonelist *zonelist, enum zone_type high_zoneidx, + nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, + int migratetype, unsigned long *did_some_progress) +{ + struct page *page; + + if (!order) + return NULL; + + *did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask, + nodemask); + if (*did_some_progress != COMPACT_SKIPPED) { + + /* Page migration frees to the PCP lists but we want merging */ + drain_pages(get_cpu()); + put_cpu(); + + page = get_page_from_freelist(gfp_mask, nodemask, + order, zonelist, high_zoneidx, + alloc_flags, preferred_zone, + migratetype); + if (page) { + __count_vm_event(COMPACTSUCCESS); + return page; + } + + /* + * It's bad if compaction run occurs and fails. + * The most likely reason is that pages exist, + * but not enough to satisfy watermarks. + */ + count_vm_event(COMPACTFAIL); + + cond_resched(); + } + + return NULL; +} +#else +static inline struct page * +__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, + struct zonelist *zonelist, enum zone_type high_zoneidx, + nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, + int migratetype, unsigned long *did_some_progress) +{ + return NULL; +} +#endif /* CONFIG_COMPACTION */ + /* The really slow allocator path where we enter direct reclaim */ static inline struct page * __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order, @@ -1769,36 +1822,6 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order, cond_resched(); - /* Try memory compaction for high-order allocations before reclaim */ - if (order) { - *did_some_progress = try_to_compact_pages(zonelist, - order, gfp_mask, nodemask); - if (*did_some_progress != COMPACT_SKIPPED) { - - /* Page migration frees to the PCP lists but we want merging */ - drain_pages(get_cpu()); - put_cpu(); - - page = get_page_from_freelist(gfp_mask, nodemask, - order, zonelist, high_zoneidx, - alloc_flags, preferred_zone, - migratetype); - if (page) { - __count_vm_event(COMPACTSUCCESS); - return page; - } - - /* - * It's bad if compaction run occurs and fails. - * The most likely reason is that pages exist, - * but not enough to satisfy watermarks. - */ - count_vm_event(COMPACTFAIL); - - cond_resched(); - } - } - /* We now go into synchronous reclaim */ cpuset_memory_pressure_bump(); p->flags |= PF_MEMALLOC; @@ -1972,6 +1995,15 @@ rebalance: if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL)) goto nopage; + /* Try direct compaction */ + page = __alloc_pages_direct_compact(gfp_mask, order, + zonelist, high_zoneidx, + nodemask, + alloc_flags, preferred_zone, + migratetype, &did_some_progress); + if (page) + goto got_pg; + /* Try direct reclaim and then allocating */ page = __alloc_pages_direct_reclaim(gfp_mask, order, zonelist, high_zoneidx, diff --git a/mm/vmstat.c b/mm/vmstat.c index 2780a36..0a58cbe 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -901,12 +901,14 @@ static const char * const vmstat_text[] = { "pgrotated", +#ifdef CONFIG_COMPACTION "compact_blocks_moved", "compact_pages_moved", "compact_pagemigrate_failed", "compact_stall", "compact_fail", "compact_success", +#endif #ifdef CONFIG_HUGETLB_PAGE "htlb_buddy_alloc_success", -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/