aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2009-03-31 18:23:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-01 11:59:15 -0400
commit327c0e968645f2601a43f5ea7c19c7b3a5fa0a34 (patch)
treeacc6789c120a6d5000ceebf51e690d14c6cfcacb
parent2678958e1225f350806d90f211a3b475f64aee80 (diff)
vmscan: fix it to take care of nodemask
try_to_free_pages() is used for the direct reclaim of up to SWAP_CLUSTER_MAX pages when watermarks are low. The caller to alloc_pages_nodemask() can specify a nodemask of nodes that are allowed to be used but this is not passed to try_to_free_pages(). This can lead to unnecessary reclaim of pages that are unusable by the caller and int the worst case lead to allocation failure as progress was not been make where it is needed. This patch passes the nodemask used for alloc_pages_nodemask() to try_to_free_pages(). Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/buffer.c2
-rw-r--r--include/linux/swap.h2
-rw-r--r--mm/page_alloc.c3
-rw-r--r--mm/vmscan.c13
4 files changed, 15 insertions, 5 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 0c14f8d52ee5..c77b848c3d43 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -290,7 +290,7 @@ static void free_more_memory(void)
290 &zone); 290 &zone);
291 if (zone) 291 if (zone)
292 try_to_free_pages(node_zonelist(nid, GFP_NOFS), 0, 292 try_to_free_pages(node_zonelist(nid, GFP_NOFS), 0,
293 GFP_NOFS); 293 GFP_NOFS, NULL);
294 } 294 }
295} 295}
296 296
diff --git a/include/linux/swap.h b/include/linux/swap.h
index d30215578877..b8b0c4ce83e6 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -212,7 +212,7 @@ static inline void lru_cache_add_active_file(struct page *page)
212 212
213/* linux/mm/vmscan.c */ 213/* linux/mm/vmscan.c */
214extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 214extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
215 gfp_t gfp_mask); 215 gfp_t gfp_mask, nodemask_t *mask);
216extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, 216extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
217 gfp_t gfp_mask, bool noswap, 217 gfp_t gfp_mask, bool noswap,
218 unsigned int swappiness); 218 unsigned int swappiness);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index cbd532161f68..0284e528748d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1582,7 +1582,8 @@ nofail_alloc:
1582 reclaim_state.reclaimed_slab = 0; 1582 reclaim_state.reclaimed_slab = 0;
1583 p->reclaim_state = &reclaim_state; 1583 p->reclaim_state = &reclaim_state;
1584 1584
1585 did_some_progress = try_to_free_pages(zonelist, order, gfp_mask); 1585 did_some_progress = try_to_free_pages(zonelist, order,
1586 gfp_mask, nodemask);
1586 1587
1587 p->reclaim_state = NULL; 1588 p->reclaim_state = NULL;
1588 lockdep_clear_current_reclaim_state(); 1589 lockdep_clear_current_reclaim_state();
diff --git a/mm/vmscan.c b/mm/vmscan.c
index f4619c6cd59e..06e72693b458 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -78,6 +78,12 @@ struct scan_control {
78 /* Which cgroup do we reclaim from */ 78 /* Which cgroup do we reclaim from */
79 struct mem_cgroup *mem_cgroup; 79 struct mem_cgroup *mem_cgroup;
80 80
81 /*
82 * Nodemask of nodes allowed by the caller. If NULL, all nodes
83 * are scanned.
84 */
85 nodemask_t *nodemask;
86
81 /* Pluggable isolate pages callback */ 87 /* Pluggable isolate pages callback */
82 unsigned long (*isolate_pages)(unsigned long nr, struct list_head *dst, 88 unsigned long (*isolate_pages)(unsigned long nr, struct list_head *dst,
83 unsigned long *scanned, int order, int mode, 89 unsigned long *scanned, int order, int mode,
@@ -1538,7 +1544,8 @@ static void shrink_zones(int priority, struct zonelist *zonelist,
1538 struct zone *zone; 1544 struct zone *zone;
1539 1545
1540 sc->all_unreclaimable = 1; 1546 sc->all_unreclaimable = 1;
1541 for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) { 1547 for_each_zone_zonelist_nodemask(zone, z, zonelist, high_zoneidx,
1548 sc->nodemask) {
1542 if (!populated_zone(zone)) 1549 if (!populated_zone(zone))
1543 continue; 1550 continue;
1544 /* 1551 /*
@@ -1683,7 +1690,7 @@ out:
1683} 1690}
1684 1691
1685unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 1692unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
1686 gfp_t gfp_mask) 1693 gfp_t gfp_mask, nodemask_t *nodemask)
1687{ 1694{
1688 struct scan_control sc = { 1695 struct scan_control sc = {
1689 .gfp_mask = gfp_mask, 1696 .gfp_mask = gfp_mask,
@@ -1694,6 +1701,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
1694 .order = order, 1701 .order = order,
1695 .mem_cgroup = NULL, 1702 .mem_cgroup = NULL,
1696 .isolate_pages = isolate_pages_global, 1703 .isolate_pages = isolate_pages_global,
1704 .nodemask = nodemask,
1697 }; 1705 };
1698 1706
1699 return do_try_to_free_pages(zonelist, &sc); 1707 return do_try_to_free_pages(zonelist, &sc);
@@ -1714,6 +1722,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
1714 .order = 0, 1722 .order = 0,
1715 .mem_cgroup = mem_cont, 1723 .mem_cgroup = mem_cont,
1716 .isolate_pages = mem_cgroup_isolate_pages, 1724 .isolate_pages = mem_cgroup_isolate_pages,
1725 .nodemask = NULL, /* we don't care the placement */
1717 }; 1726 };
1718 struct zonelist *zonelist; 1727 struct zonelist *zonelist;
1719 1728