diff options
author | David Rientjes <rientjes@google.com> | 2009-12-14 20:58:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:13 -0500 |
commit | 8fe23e057172223fe2048768a4d87ab7de7477bc (patch) | |
tree | d176d8e588fca088adfcb110e7c1bc53a839dc84 | |
parent | 9b5e5d0fdc91b73bba8cf5e0fbe3521a953e4e4d (diff) |
mm: clear node in N_HIGH_MEMORY and stop kswapd when all memory is offlined
When memory is hot-removed, its node must be cleared in N_HIGH_MEMORY if
there are no present pages left.
In such a situation, kswapd must also be stopped since it has nothing left
to do.
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Rik van Riel <riel@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Adam Litke <agl@us.ibm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Eric Whitney <eric.whitney@hp.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/swap.h | 1 | ||||
-rw-r--r-- | mm/memory_hotplug.c | 4 | ||||
-rw-r--r-- | mm/vmscan.c | 28 |
3 files changed, 27 insertions, 6 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index 4ec90019c1a4..abce8a0b2507 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -273,6 +273,7 @@ extern int scan_unevictable_register_node(struct node *node); | |||
273 | extern void scan_unevictable_unregister_node(struct node *node); | 273 | extern void scan_unevictable_unregister_node(struct node *node); |
274 | 274 | ||
275 | extern int kswapd_run(int nid); | 275 | extern int kswapd_run(int nid); |
276 | extern void kswapd_stop(int nid); | ||
276 | 277 | ||
277 | #ifdef CONFIG_MMU | 278 | #ifdef CONFIG_MMU |
278 | /* linux/mm/shmem.c */ | 279 | /* linux/mm/shmem.c */ |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index e8116f8bdffa..bc5a08138f1e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -853,6 +853,10 @@ repeat: | |||
853 | 853 | ||
854 | setup_per_zone_wmarks(); | 854 | setup_per_zone_wmarks(); |
855 | calculate_zone_inactive_ratio(zone); | 855 | calculate_zone_inactive_ratio(zone); |
856 | if (!node_present_pages(node)) { | ||
857 | node_clear_state(node, N_HIGH_MEMORY); | ||
858 | kswapd_stop(node); | ||
859 | } | ||
856 | 860 | ||
857 | vm_total_pages = nr_free_pagecache_pages(); | 861 | vm_total_pages = nr_free_pagecache_pages(); |
858 | writeback_set_ratelimit(); | 862 | writeback_set_ratelimit(); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 777af57fd8c8..d0a631a428a0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -2173,6 +2173,7 @@ static int kswapd(void *p) | |||
2173 | order = 0; | 2173 | order = 0; |
2174 | for ( ; ; ) { | 2174 | for ( ; ; ) { |
2175 | unsigned long new_order; | 2175 | unsigned long new_order; |
2176 | int ret; | ||
2176 | 2177 | ||
2177 | prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE); | 2178 | prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE); |
2178 | new_order = pgdat->kswapd_max_order; | 2179 | new_order = pgdat->kswapd_max_order; |
@@ -2184,19 +2185,23 @@ static int kswapd(void *p) | |||
2184 | */ | 2185 | */ |
2185 | order = new_order; | 2186 | order = new_order; |
2186 | } else { | 2187 | } else { |
2187 | if (!freezing(current)) | 2188 | if (!freezing(current) && !kthread_should_stop()) |
2188 | schedule(); | 2189 | schedule(); |
2189 | 2190 | ||
2190 | order = pgdat->kswapd_max_order; | 2191 | order = pgdat->kswapd_max_order; |
2191 | } | 2192 | } |
2192 | finish_wait(&pgdat->kswapd_wait, &wait); | 2193 | finish_wait(&pgdat->kswapd_wait, &wait); |
2193 | 2194 | ||
2194 | if (!try_to_freeze()) { | 2195 | ret = try_to_freeze(); |
2195 | /* We can speed up thawing tasks if we don't call | 2196 | if (kthread_should_stop()) |
2196 | * balance_pgdat after returning from the refrigerator | 2197 | break; |
2197 | */ | 2198 | |
2199 | /* | ||
2200 | * We can speed up thawing tasks if we don't call balance_pgdat | ||
2201 | * after returning from the refrigerator | ||
2202 | */ | ||
2203 | if (!ret) | ||
2198 | balance_pgdat(pgdat, order); | 2204 | balance_pgdat(pgdat, order); |
2199 | } | ||
2200 | } | 2205 | } |
2201 | return 0; | 2206 | return 0; |
2202 | } | 2207 | } |
@@ -2451,6 +2456,17 @@ int kswapd_run(int nid) | |||
2451 | return ret; | 2456 | return ret; |
2452 | } | 2457 | } |
2453 | 2458 | ||
2459 | /* | ||
2460 | * Called by memory hotplug when all memory in a node is offlined. | ||
2461 | */ | ||
2462 | void kswapd_stop(int nid) | ||
2463 | { | ||
2464 | struct task_struct *kswapd = NODE_DATA(nid)->kswapd; | ||
2465 | |||
2466 | if (kswapd) | ||
2467 | kthread_stop(kswapd); | ||
2468 | } | ||
2469 | |||
2454 | static int __init kswapd_init(void) | 2470 | static int __init kswapd_init(void) |
2455 | { | 2471 | { |
2456 | int nid; | 2472 | int nid; |