Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343327
b: refs/heads/master
c: 6715ddf
h: refs/heads/master
i:
  343325: dfc8823
  343323: b2b0e8f
  343319: 30e7393
  343311: cde28a7
  343295: 2603108
v: v3
  • Loading branch information
Lai Jiangshan authored and Linus Torvalds committed Dec 13, 2012
1 parent b938763 commit a0149e8
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4b0ef1fe8a626f0ba7f649764f979d0dc9eab86b
refs/heads/master: 6715ddf94576ff39f5d1cda8d4c568d3b79e82ec
5 changes: 4 additions & 1 deletion trunk/Documentation/memory-hotplug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,17 @@ struct memory_notify {
unsigned long start_pfn;
unsigned long nr_pages;
int status_change_nid_normal;
int status_change_nid_high;
int status_change_nid;
}

start_pfn is start_pfn of online/offline memory.
nr_pages is # of pages of online/offline memory.
status_change_nid_normal is set node id when N_NORMAL_MEMORY of nodemask
is (will be) set/clear, if this is -1, then nodemask status is not changed.
status_change_nid is set node id when N_HIGH_MEMORY of nodemask is (will be)
status_change_nid_high is set node id when N_HIGH_MEMORY of nodemask
is (will be) set/clear, if this is -1, then nodemask status is not changed.
status_change_nid is set node id when N_MEMORY of nodemask is (will be)
set/clear. It means a new(memoryless) node gets new memory by online and a
node loses all memory. If this is -1, then nodemask status is not changed.
If status_changed_nid* >= 0, callback should create/discard structures for the
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct memory_notify {
unsigned long start_pfn;
unsigned long nr_pages;
int status_change_nid_normal;
int status_change_nid_high;
int status_change_nid;
};

Expand Down
87 changes: 72 additions & 15 deletions trunk/mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,15 @@ static void node_states_check_changes_online(unsigned long nr_pages,
enum zone_type zone_last = ZONE_NORMAL;

/*
* If we have HIGHMEM, node_states[N_NORMAL_MEMORY] contains nodes
* which have 0...ZONE_NORMAL, set zone_last to ZONE_NORMAL.
* If we have HIGHMEM or movable node, node_states[N_NORMAL_MEMORY]
* contains nodes which have zones of 0...ZONE_NORMAL,
* set zone_last to ZONE_NORMAL.
*
* If we don't have HIGHMEM, node_states[N_NORMAL_MEMORY] contains nodes
* which have 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE.
* If we don't have HIGHMEM nor movable node,
* node_states[N_NORMAL_MEMORY] contains nodes which have zones of
* 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE.
*/
if (N_HIGH_MEMORY == N_NORMAL_MEMORY)
if (N_MEMORY == N_NORMAL_MEMORY)
zone_last = ZONE_MOVABLE;

/*
Expand All @@ -615,12 +617,34 @@ static void node_states_check_changes_online(unsigned long nr_pages,
else
arg->status_change_nid_normal = -1;

#ifdef CONFIG_HIGHMEM
/*
* If we have movable node, node_states[N_HIGH_MEMORY]
* contains nodes which have zones of 0...ZONE_HIGHMEM,
* set zone_last to ZONE_HIGHMEM.
*
* If we don't have movable node, node_states[N_NORMAL_MEMORY]
* contains nodes which have zones of 0...ZONE_MOVABLE,
* set zone_last to ZONE_MOVABLE.
*/
zone_last = ZONE_HIGHMEM;
if (N_MEMORY == N_HIGH_MEMORY)
zone_last = ZONE_MOVABLE;

if (zone_idx(zone) <= zone_last && !node_state(nid, N_HIGH_MEMORY))
arg->status_change_nid_high = nid;
else
arg->status_change_nid_high = -1;
#else
arg->status_change_nid_high = arg->status_change_nid_normal;
#endif

/*
* if the node don't have memory befor online, we will need to
* set the node to node_states[N_HIGH_MEMORY] after the memory
* set the node to node_states[N_MEMORY] after the memory
* is online.
*/
if (!node_state(nid, N_HIGH_MEMORY))
if (!node_state(nid, N_MEMORY))
arg->status_change_nid = nid;
else
arg->status_change_nid = -1;
Expand All @@ -631,7 +655,10 @@ static void node_states_set_node(int node, struct memory_notify *arg)
if (arg->status_change_nid_normal >= 0)
node_set_state(node, N_NORMAL_MEMORY);

node_set_state(node, N_HIGH_MEMORY);
if (arg->status_change_nid_high >= 0)
node_set_state(node, N_HIGH_MEMORY);

node_set_state(node, N_MEMORY);
}


Expand Down Expand Up @@ -1099,13 +1126,15 @@ static void node_states_check_changes_offline(unsigned long nr_pages,
enum zone_type zt, zone_last = ZONE_NORMAL;

/*
* If we have HIGHMEM, node_states[N_NORMAL_MEMORY] contains nodes
* which have 0...ZONE_NORMAL, set zone_last to ZONE_NORMAL.
* If we have HIGHMEM or movable node, node_states[N_NORMAL_MEMORY]
* contains nodes which have zones of 0...ZONE_NORMAL,
* set zone_last to ZONE_NORMAL.
*
* If we don't have HIGHMEM, node_states[N_NORMAL_MEMORY] contains nodes
* which have 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE.
* If we don't have HIGHMEM nor movable node,
* node_states[N_NORMAL_MEMORY] contains nodes which have zones of
* 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE.
*/
if (N_HIGH_MEMORY == N_NORMAL_MEMORY)
if (N_MEMORY == N_NORMAL_MEMORY)
zone_last = ZONE_MOVABLE;

/*
Expand All @@ -1122,6 +1151,30 @@ static void node_states_check_changes_offline(unsigned long nr_pages,
else
arg->status_change_nid_normal = -1;

#ifdef CONFIG_HIGHMEM
/*
* If we have movable node, node_states[N_HIGH_MEMORY]
* contains nodes which have zones of 0...ZONE_HIGHMEM,
* set zone_last to ZONE_HIGHMEM.
*
* If we don't have movable node, node_states[N_NORMAL_MEMORY]
* contains nodes which have zones of 0...ZONE_MOVABLE,
* set zone_last to ZONE_MOVABLE.
*/
zone_last = ZONE_HIGHMEM;
if (N_MEMORY == N_HIGH_MEMORY)
zone_last = ZONE_MOVABLE;

for (; zt <= zone_last; zt++)
present_pages += pgdat->node_zones[zt].present_pages;
if (zone_idx(zone) <= zone_last && nr_pages >= present_pages)
arg->status_change_nid_high = zone_to_nid(zone);
else
arg->status_change_nid_high = -1;
#else
arg->status_change_nid_high = arg->status_change_nid_normal;
#endif

/*
* node_states[N_HIGH_MEMORY] contains nodes which have 0...ZONE_MOVABLE
*/
Expand All @@ -1146,9 +1199,13 @@ static void node_states_clear_node(int node, struct memory_notify *arg)
if (arg->status_change_nid_normal >= 0)
node_clear_state(node, N_NORMAL_MEMORY);

if ((N_HIGH_MEMORY != N_NORMAL_MEMORY) &&
(arg->status_change_nid >= 0))
if ((N_MEMORY != N_NORMAL_MEMORY) &&
(arg->status_change_nid_high >= 0))
node_clear_state(node, N_HIGH_MEMORY);

if ((N_MEMORY != N_HIGH_MEMORY) &&
(arg->status_change_nid >= 0))
node_clear_state(node, N_MEMORY);
}

static int __ref __offline_pages(unsigned long start_pfn,
Expand Down

0 comments on commit a0149e8

Please sign in to comment.