From patchwork Fri Apr 22 01:34:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1156 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:42 -0000 Delivered-To: patches@linaro.org Received: by 10.220.162.205 with SMTP id w13cs131150vcx; Thu, 21 Apr 2011 18:34:26 -0700 (PDT) Received: by 10.236.187.97 with SMTP id x61mr511062yhm.476.1303436065886; Thu, 21 Apr 2011 18:34:25 -0700 (PDT) Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx.google.com with ESMTPS id z30si5739235yhh.110.2011.04.21.18.34.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Apr 2011 18:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.152 as permitted sender) client-ip=32.97.110.152; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.152 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p3M1M8XQ019854; Thu, 21 Apr 2011 19:22:08 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p3M1YJOM040288; Thu, 21 Apr 2011 19:34:19 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p3M1YInM008416; Thu, 21 Apr 2011 19:34:19 -0600 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p3M1YIWP008401; Thu, 21 Apr 2011 19:34:18 -0600 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 0510E1E750E; Thu, 21 Apr 2011 18:34:17 -0700 (PDT) From: John Stultz To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Dave Hansen , Mel Gorman , Andrew Morton , John Stultz Subject: [PATCH] mm: Check if any page in a pageblock is reserved before marking it MIGRATE_RESERVE Date: Thu, 21 Apr 2011 18:34:03 -0700 Message-Id: <1303436043-26644-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 MIME-Version: 1.0 From: Arve Hjønnevåg This fixes a problem where the first pageblock got marked MIGRATE_RESERVE even though it only had a few free pages. This in turn caused no contiguous memory to be reserved and frequent kswapd wakeups that emptied the caches to get more contiguous memory. CC: Dave Hansen CC: Mel Gorman CC: Andrew Morton Signed-off-by: Arve Hjønnevåg Acked-by: Mel Gorman [This patch was submitted and acked a little over a year ago (see: http://lkml.org/lkml/2010/4/6/172 ), but never seemingly made it upstream. Resending for comments. -jstultz] Signed-off-by: John Stultz --- mm/page_alloc.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ed87f3b..209d9bf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3288,6 +3288,20 @@ static inline unsigned long wait_table_bits(unsigned long size) #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) /* + * Check if a pageblock contains reserved pages + */ +static int pageblock_is_reserved(unsigned long start_pfn) +{ + unsigned long end_pfn = start_pfn + pageblock_nr_pages; + unsigned long pfn; + + for (pfn = start_pfn; pfn < end_pfn; pfn++) + if (PageReserved(pfn_to_page(pfn))) + return 1; + return 0; +} + +/* * Mark a number of pageblocks as MIGRATE_RESERVE. The number * of blocks reserved is based on min_wmark_pages(zone). The memory within * the reserve will tend to store contiguous free pages. Setting min_free_kbytes @@ -3326,7 +3340,7 @@ static void setup_zone_migrate_reserve(struct zone *zone) continue; /* Blocks with reserved pages will never free, skip them. */ - if (PageReserved(page)) + if (pageblock_is_reserved(pfn)) continue; block_migratetype = get_pageblock_migratetype(page);