Skip to content

Commit 1eb41bb

Browse files
Michal Hockotorvalds
Michal Hocko
authored andcommitted
mm, oom: consider present pages for the node size
constrained_alloc() calculates the size of the oom domain by using node_spanned_pages which is incorrect because this is the full range of the physical memory range that the numa node occupies rather than the memory that backs that range which is represented by node_present_pages. Sparsely populated nodes (e.g. after memory hot remove or simply sparse due to memory layout) can have really a large difference between the two. This shouldn't really cause any real user observable problems because the oom calculates a ratio against totalpages and used memory cannot exceed present pages but it is confusing and wrong from code point of view. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Michal Hocko <[email protected]> Reported-by: David Hildenbrand <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f364f06 commit 1eb41bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/oom_kill.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
287287
!nodes_subset(node_states[N_MEMORY], *oc->nodemask)) {
288288
oc->totalpages = total_swap_pages;
289289
for_each_node_mask(nid, *oc->nodemask)
290-
oc->totalpages += node_spanned_pages(nid);
290+
oc->totalpages += node_present_pages(nid);
291291
return CONSTRAINT_MEMORY_POLICY;
292292
}
293293

@@ -300,7 +300,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
300300
if (cpuset_limited) {
301301
oc->totalpages = total_swap_pages;
302302
for_each_node_mask(nid, cpuset_current_mems_allowed)
303-
oc->totalpages += node_spanned_pages(nid);
303+
oc->totalpages += node_present_pages(nid);
304304
return CONSTRAINT_CPUSET;
305305
}
306306
return CONSTRAINT_NONE;

0 commit comments

Comments
 (0)