Commit f481891fdc49d3d1b8a9674a1825d183069a805f

Authored by Miao Xie
Committed by Linus Torvalds
1 parent ac97b9f9a2

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>

Showing 3 changed files with 16 additions and 10 deletions Side-by-side Diff

include/linux/cpuset.h
... ... @@ -74,8 +74,6 @@
74 74 return current->flags & PF_SPREAD_SLAB;
75 75 }
76 76  
77   -extern void cpuset_track_online_nodes(void);
78   -
79 77 extern int current_cpuset_is_being_rebound(void);
80 78  
81 79 extern void rebuild_sched_domains(void);
... ... @@ -150,8 +148,6 @@
150 148 {
151 149 return 0;
152 150 }
153   -
154   -static inline void cpuset_track_online_nodes(void) {}
155 151  
156 152 static inline int current_cpuset_is_being_rebound(void)
157 153 {
... ... @@ -36,6 +36,7 @@
36 36 #include <linux/list.h>
37 37 #include <linux/mempolicy.h>
38 38 #include <linux/mm.h>
  39 +#include <linux/memory.h>
39 40 #include <linux/module.h>
40 41 #include <linux/mount.h>
41 42 #include <linux/namei.h>
42 43  
43 44  
... ... @@ -2015,12 +2016,23 @@
2015 2016 * Call this routine anytime after node_states[N_HIGH_MEMORY] changes.
2016 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 2022 cgroup_lock();
2021   - top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2022   - scan_for_empty_cpusets(&top_cpuset);
  2023 + switch (action) {
  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 2034 cgroup_unlock();
  2035 + return NOTIFY_OK;
2024 2036 }
2025 2037 #endif
2026 2038  
... ... @@ -2036,6 +2048,7 @@
2036 2048 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2037 2049  
2038 2050 hotcpu_notifier(cpuset_track_online_cpus, 0);
  2051 + hotplug_memory_notifier(cpuset_track_online_nodes, 10);
2039 2052 }
2040 2053  
2041 2054 /**
... ... @@ -22,7 +22,6 @@
22 22 #include <linux/highmem.h>
23 23 #include <linux/vmalloc.h>
24 24 #include <linux/ioport.h>
25   -#include <linux/cpuset.h>
26 25 #include <linux/delay.h>
27 26 #include <linux/migrate.h>
28 27 #include <linux/page-isolation.h>
... ... @@ -497,8 +496,6 @@
497 496  
498 497 /* we online node here. we can't roll back from here. */
499 498 node_set_online(nid);
500   -
501   - cpuset_track_online_nodes();
502 499  
503 500 if (new_pgdat) {
504 501 ret = register_one_node(nid);