diff options
author | Mel Gorman <mel@csn.ul.ie> | 2007-10-16 04:25:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:42:59 -0400 |
commit | e2c55dc87f4a398b9c4dcc702dbc23a07fe14e23 (patch) | |
tree | b3811de298d4c98c4765db4af3838428553b5382 | |
parent | b92a6edd4b77a8794adb497280beea5df5e59a14 (diff) |
Drain per-cpu lists when high-order allocations fail
Per-cpu pages can accidentally cause fragmentation because they are free, but
pinned pages in an otherwise contiguous block. When this patch is applied,
the per-cpu caches are drained after the direct-reclaim is entered if the
requested order is greater than 0. It simply reuses the code used by suspend
and hotplug.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/page_alloc.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fea1e3b56c3d..aa7e5d2f28a5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -876,7 +876,9 @@ void mark_free_pages(struct zone *zone) | |||
876 | } | 876 | } |
877 | spin_unlock_irqrestore(&zone->lock, flags); | 877 | spin_unlock_irqrestore(&zone->lock, flags); |
878 | } | 878 | } |
879 | #endif /* CONFIG_PM */ | ||
879 | 880 | ||
881 | #if defined(CONFIG_HIBERNATION) || defined(CONFIG_PAGE_GROUP_BY_MOBILITY) | ||
880 | /* | 882 | /* |
881 | * Spill all of this CPU's per-cpu pages back into the buddy allocator. | 883 | * Spill all of this CPU's per-cpu pages back into the buddy allocator. |
882 | */ | 884 | */ |
@@ -888,7 +890,28 @@ void drain_local_pages(void) | |||
888 | __drain_pages(smp_processor_id()); | 890 | __drain_pages(smp_processor_id()); |
889 | local_irq_restore(flags); | 891 | local_irq_restore(flags); |
890 | } | 892 | } |
891 | #endif /* CONFIG_HIBERNATION */ | 893 | |
894 | void smp_drain_local_pages(void *arg) | ||
895 | { | ||
896 | drain_local_pages(); | ||
897 | } | ||
898 | |||
899 | /* | ||
900 | * Spill all the per-cpu pages from all CPUs back into the buddy allocator | ||
901 | */ | ||
902 | void drain_all_local_pages(void) | ||
903 | { | ||
904 | unsigned long flags; | ||
905 | |||
906 | local_irq_save(flags); | ||
907 | __drain_pages(smp_processor_id()); | ||
908 | local_irq_restore(flags); | ||
909 | |||
910 | smp_call_function(smp_drain_local_pages, NULL, 0, 1); | ||
911 | } | ||
912 | #else | ||
913 | void drain_all_local_pages(void) {} | ||
914 | #endif /* CONFIG_HIBERNATION || CONFIG_PAGE_GROUP_BY_MOBILITY */ | ||
892 | 915 | ||
893 | /* | 916 | /* |
894 | * Free a 0-order page | 917 | * Free a 0-order page |
@@ -1480,6 +1503,9 @@ nofail_alloc: | |||
1480 | 1503 | ||
1481 | cond_resched(); | 1504 | cond_resched(); |
1482 | 1505 | ||
1506 | if (order != 0) | ||
1507 | drain_all_local_pages(); | ||
1508 | |||
1483 | if (likely(did_some_progress)) { | 1509 | if (likely(did_some_progress)) { |
1484 | page = get_page_from_freelist(gfp_mask, order, | 1510 | page = get_page_from_freelist(gfp_mask, order, |
1485 | zonelist, alloc_flags); | 1511 | zonelist, alloc_flags); |