Skip to content

Commit

Permalink
mm, oom: ensure memoryless node zonelist always includes zones
Browse files Browse the repository at this point in the history
With memoryless node support being worked on, it's possible that for
optimizations that a node may not have a non-NULL zonelist.  When
CONFIG_NUMA is enabled and node 0 is memoryless, this means the zonelist
for first_online_node may become NULL.

The oom killer requires a zonelist that includes all memory zones for
the sysrq trigger and pagefault out of memory handler.

Ensure that a non-NULL zonelist is always passed to the oom killer.

[[email protected]: fix non-numa build]
Signed-off-by: David Rientjes <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Rik van Riel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rientjes authored and torvalds committed Aug 7, 2014
1 parent 6e90b58 commit 8d060bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/tty/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static struct sysrq_key_op sysrq_term_op = {

static void moom_callback(struct work_struct *ignored)
{
out_of_memory(node_zonelist(first_online_node, GFP_KERNEL), GFP_KERNEL,
out_of_memory(node_zonelist(first_memory_node, GFP_KERNEL), GFP_KERNEL,
0, NULL, true);
}

Expand Down
11 changes: 10 additions & 1 deletion include/linux/nodemask.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,15 @@ static inline int num_node_state(enum node_states state)
for_each_node_mask((__node), node_states[__state])

#define first_online_node first_node(node_states[N_ONLINE])
#define next_online_node(nid) next_node((nid), node_states[N_ONLINE])
#define first_memory_node first_node(node_states[N_MEMORY])
static inline int next_online_node(int nid)
{
return next_node(nid, node_states[N_ONLINE]);
}
static inline int next_memory_node(int nid)
{
return next_node(nid, node_states[N_MEMORY]);
}

extern int nr_node_ids;
extern int nr_online_nodes;
Expand Down Expand Up @@ -471,6 +479,7 @@ static inline int num_node_state(enum node_states state)
for ( (node) = 0; (node) == 0; (node) = 1)

#define first_online_node 0
#define first_memory_node 0
#define next_online_node(nid) (MAX_NUMNODES)
#define nr_node_ids 1
#define nr_online_nodes 1
Expand Down
2 changes: 1 addition & 1 deletion mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ void pagefault_out_of_memory(void)
if (mem_cgroup_oom_synchronize(true))
return;

zonelist = node_zonelist(first_online_node, GFP_KERNEL);
zonelist = node_zonelist(first_memory_node, GFP_KERNEL);
if (try_set_zonelist_oom(zonelist, GFP_KERNEL)) {
out_of_memory(NULL, 0, 0, NULL, false);
clear_zonelist_oom(zonelist, GFP_KERNEL);
Expand Down

0 comments on commit 8d060bf

Please sign in to comment.