linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: Free pages from local pcp lists under tight memory conditions
@ 2005-11-23  0:10 Rohit Seth
  2005-11-23  5:36 ` Andrew Morton
  2005-11-23 19:30 ` Christoph Lameter
  0 siblings, 2 replies; 26+ messages in thread
From: Rohit Seth @ 2005-11-23  0:10 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: linux-mm, linux-kernel

Andrew, Linus,

[PATCH]: This patch free pages (pcp->batch from each list at a time) from
local pcp lists when a higher order allocation request is not able to 
get serviced from global free_list.

This should help fix some of the earlier failures seen with order 1 allocations.

I will send separate patches for:

1- Reducing the remote cpus pcp
2- Clean up page_alloc.c for CONFIG_HOTPLUG_CPU to use this code appropiately

Signed-off-by: Rohit Seth <rohit.seth@intel.com>


--- a/mm/page_alloc.c	2005-11-22 07:03:40.000000000 -0800
+++ linux-2.6.15-rc2/mm/page_alloc.c	2005-11-22 07:17:48.000000000 -0800
@@ -827,6 +827,35 @@
 	return page;
 }
 
+static int
+reduce_cpu_pcp(void )
+{
+	struct zone *zone;
+	unsigned long flags;
+	unsigned int cpu = get_cpu();
+	int i, ret=0;
+
+	local_irq_save(flags);
+	for_each_zone(zone) {
+		struct per_cpu_pageset *pset;
+
+		pset = zone_pcp(zone, cpu);
+		for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
+			struct per_cpu_pages *pcp;
+
+			pcp = &pset->pcp[i];
+			if (pcp->count == 0)
+				continue;
+			pcp->count -= free_pages_bulk(zone, pcp->batch,
+						&pcp->list, 0);
+			ret++;
+		}
+	}
+	local_irq_restore(flags);
+	put_cpu();
+	return ret;
+}
+
 /*
  * This is the 'heart' of the zoned buddy allocator.
  */
@@ -887,6 +916,7 @@
 	 * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc.
 	 * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
 	 */
+try_again:
 	page = get_page_from_freelist(gfp_mask, order, zonelist, alloc_flags);
 	if (page)
 		goto got_pg;
@@ -911,8 +941,15 @@
 	}
 
 	/* Atomic allocations - we can't balance anything */
-	if (!wait)
-		goto nopage;
+	if (!wait) {
+		/* Check if there are pages available on pcp lists that can be 
+		 * moved to global page list to satisfy higher order allocations.
+		 */
+		if ((order > 0) && (reduce_cpu_pcp()))
+			goto try_again;
+		else 
+			goto nopage;
+	}
 
 rebalance:
 	cond_resched();
@@ -950,6 +987,14 @@
 		goto restart;
 	}
 
+	if (order > 0) 
+		while (reduce_cpu_pcp()) {
+			if (get_page_from_freelist(gfp_mask, order, zonelist, alloc_flags))
+				goto got_pg;
+		}
+	/* FIXME: Add the support for reducing/draining the remote pcps.
+	 */
+
 	/*
 	 * Don't let big-order allocations loop unless the caller explicitly
 	 * requests that.  Wait for some write requests to complete then retry.

--
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>

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2005-12-02  0:32 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-23  0:10 [PATCH]: Free pages from local pcp lists under tight memory conditions Rohit Seth
2005-11-23  5:36 ` Andrew Morton
2005-11-23  5:58   ` Andrew Morton
2005-11-23 18:17     ` Rohit Seth
2005-11-23  6:36   ` Christoph Lameter
2005-11-23  6:42   ` Christoph Lameter
2005-11-23 16:35     ` Linus Torvalds
2005-11-23 17:03       ` Christoph Lameter
2005-11-23 17:54   ` Rohit Seth
2005-11-23 18:06     ` Mel Gorman
2005-11-23 19:41       ` Rohit Seth
2005-11-24  9:25         ` Mel Gorman
2005-11-23 23:26       ` Rohit Seth
2005-11-23 19:30 ` Christoph Lameter
2005-11-23 19:46   ` Rohit Seth
2005-11-23 19:55     ` Andrew Morton
2005-11-23 21:00       ` Rohit Seth
2005-11-23 21:25         ` Christoph Lameter
2005-11-23 22:29           ` Rohit Seth
2005-11-23 21:26         ` Andrew Morton
2005-11-23 21:40           ` Rohit Seth
2005-11-24  3:02         ` Paul Jackson
2005-11-29 23:18           ` Rohit Seth
2005-12-01 14:44             ` Paul Jackson
2005-12-02  0:32               ` Nick Piggin
2005-11-23 22:01       ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox