diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2008-11-19 18:36:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-19 21:49:58 -0500 |
commit | f481891fdc49d3d1b8a9674a1825d183069a805f (patch) | |
tree | 4f027a1321dcd06165394d0a23e49df51c8befc1 | |
parent | ac97b9f9a2d0b83488e0bbcb8517b229d5c9b142 (diff) |
cpuset: update top cpuset's mems after adding a node
After adding a node into the machine, top cpuset's mems isn't updated.
By reviewing the code, we found that the update function
cpuset_track_online_nodes()
was invoked after node_states[N_ONLINE] changes. It is wrong because
N_ONLINE just means node has pgdat, and if node has/added memory, we use
N_HIGH_MEMORY. So, We should invoke the update function after
node_states[N_HIGH_MEMORY] changes, just like its commit says.
This patch fixes it. And we use notifier of memory hotplug instead of
direct calling of cpuset_track_online_nodes().
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Acked-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Paul Menage <menage@google.com
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/cpuset.h | 4 | ||||
-rw-r--r-- | kernel/cpuset.c | 19 | ||||
-rw-r--r-- | mm/memory_hotplug.c | 3 |
3 files changed, 16 insertions, 10 deletions
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 2691926fb506..8e540d32c9fe 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h | |||
@@ -74,8 +74,6 @@ static inline int cpuset_do_slab_mem_spread(void) | |||
74 | return current->flags & PF_SPREAD_SLAB; | 74 | return current->flags & PF_SPREAD_SLAB; |
75 | } | 75 | } |
76 | 76 | ||
77 | extern void cpuset_track_online_nodes(void); | ||
78 | |||
79 | extern int current_cpuset_is_being_rebound(void); | 77 | extern int current_cpuset_is_being_rebound(void); |
80 | 78 | ||
81 | extern void rebuild_sched_domains(void); | 79 | extern void rebuild_sched_domains(void); |
@@ -151,8 +149,6 @@ static inline int cpuset_do_slab_mem_spread(void) | |||
151 | return 0; | 149 | return 0; |
152 | } | 150 | } |
153 | 151 | ||
154 | static inline void cpuset_track_online_nodes(void) {} | ||
155 | |||
156 | static inline int current_cpuset_is_being_rebound(void) | 152 | static inline int current_cpuset_is_being_rebound(void) |
157 | { | 153 | { |
158 | return 0; | 154 | return 0; |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 81fc6791a296..da7ff6137f37 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/list.h> | 36 | #include <linux/list.h> |
37 | #include <linux/mempolicy.h> | 37 | #include <linux/mempolicy.h> |
38 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
39 | #include <linux/memory.h> | ||
39 | #include <linux/module.h> | 40 | #include <linux/module.h> |
40 | #include <linux/mount.h> | 41 | #include <linux/mount.h> |
41 | #include <linux/namei.h> | 42 | #include <linux/namei.h> |
@@ -2015,12 +2016,23 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb, | |||
2015 | * Call this routine anytime after node_states[N_HIGH_MEMORY] changes. | 2016 | * Call this routine anytime after node_states[N_HIGH_MEMORY] changes. |
2016 | * See also the previous routine cpuset_track_online_cpus(). | 2017 | * See also the previous routine cpuset_track_online_cpus(). |
2017 | */ | 2018 | */ |
2018 | void cpuset_track_online_nodes(void) | 2019 | static int cpuset_track_online_nodes(struct notifier_block *self, |
2020 | unsigned long action, void *arg) | ||
2019 | { | 2021 | { |
2020 | cgroup_lock(); | 2022 | cgroup_lock(); |
2021 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | 2023 | switch (action) { |
2022 | scan_for_empty_cpusets(&top_cpuset); | 2024 | case MEM_ONLINE: |
2025 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | ||
2026 | break; | ||
2027 | case MEM_OFFLINE: | ||
2028 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | ||
2029 | scan_for_empty_cpusets(&top_cpuset); | ||
2030 | break; | ||
2031 | default: | ||
2032 | break; | ||
2033 | } | ||
2023 | cgroup_unlock(); | 2034 | cgroup_unlock(); |
2035 | return NOTIFY_OK; | ||
2024 | } | 2036 | } |
2025 | #endif | 2037 | #endif |
2026 | 2038 | ||
@@ -2036,6 +2048,7 @@ void __init cpuset_init_smp(void) | |||
2036 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | 2048 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; |
2037 | 2049 | ||
2038 | hotcpu_notifier(cpuset_track_online_cpus, 0); | 2050 | hotcpu_notifier(cpuset_track_online_cpus, 0); |
2051 | hotplug_memory_notifier(cpuset_track_online_nodes, 10); | ||
2039 | } | 2052 | } |
2040 | 2053 | ||
2041 | /** | 2054 | /** |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6837a1014372..b5b2b15085a8 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/highmem.h> | 22 | #include <linux/highmem.h> |
23 | #include <linux/vmalloc.h> | 23 | #include <linux/vmalloc.h> |
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/cpuset.h> | ||
26 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
27 | #include <linux/migrate.h> | 26 | #include <linux/migrate.h> |
28 | #include <linux/page-isolation.h> | 27 | #include <linux/page-isolation.h> |
@@ -498,8 +497,6 @@ int add_memory(int nid, u64 start, u64 size) | |||
498 | /* we online node here. we can't roll back from here. */ | 497 | /* we online node here. we can't roll back from here. */ |
499 | node_set_online(nid); | 498 | node_set_online(nid); |
500 | 499 | ||
501 | cpuset_track_online_nodes(); | ||
502 | |||
503 | if (new_pgdat) { | 500 | if (new_pgdat) { |
504 | ret = register_one_node(nid); | 501 | ret = register_one_node(nid); |
505 | /* | 502 | /* |