Skip to content

Commit b95046b

Browse files
Michal Hockotorvalds
authored andcommitted
mm, sparse, page_ext: drop ugly N_HIGH_MEMORY branches for allocations
Commit f52407c ("memory hotplug: alloc page from other node in memory online") has introduced N_HIGH_MEMORY checks to only use NUMA aware allocations when there is some memory present because the respective node might not have any memory yet at the time and so it could fail or even OOM. Things have changed since then though. Zonelists are now always initialized before we do any allocations even for hotplug (see 959ecc4 ("mm/memory_hotplug.c: fix building of node hotplug zonelist")). Therefore these checks are not really needed. In fact caller of the allocator should never care about whether the node is populated because that might change at any time. Link: http://lkml.kernel.org/r/20170721143915.14161-10-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Shaohua Li <shaohua.li@intel.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Toshi Kani <toshi.kani@hpe.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b93e0f3 commit b95046b

3 files changed

Lines changed: 7 additions & 19 deletions

File tree

‎mm/page_ext.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,7 @@ static void *__meminit alloc_page_ext(size_t size, int nid)
222222
return addr;
223223
}
224224

225-
if (node_state(nid, N_HIGH_MEMORY))
226-
addr = vzalloc_node(size, nid);
227-
else
228-
addr = vzalloc(size);
225+
addr = vzalloc_node(size, nid);
229226

230227
return addr;
231228
}

‎mm/sparse-vmemmap.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,9 @@ void * __meminit vmemmap_alloc_block(unsigned long size, int node)
5454
if (slab_is_available()) {
5555
struct page *page;
5656

57-
if (node_state(node, N_HIGH_MEMORY))
58-
page = alloc_pages_node(
59-
node, GFP_KERNEL | __GFP_ZERO | __GFP_RETRY_MAYFAIL,
60-
get_order(size));
61-
else
62-
page = alloc_pages(
63-
GFP_KERNEL | __GFP_ZERO | __GFP_RETRY_MAYFAIL,
64-
get_order(size));
57+
page = alloc_pages_node(node,
58+
GFP_KERNEL | __GFP_ZERO | __GFP_RETRY_MAYFAIL,
59+
get_order(size));
6560
if (page)
6661
return page_address(page);
6762
return NULL;

‎mm/sparse.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,10 @@ static noinline struct mem_section __ref *sparse_index_alloc(int nid)
6565
unsigned long array_size = SECTIONS_PER_ROOT *
6666
sizeof(struct mem_section);
6767

68-
if (slab_is_available()) {
69-
if (node_state(nid, N_HIGH_MEMORY))
70-
section = kzalloc_node(array_size, GFP_KERNEL, nid);
71-
else
72-
section = kzalloc(array_size, GFP_KERNEL);
73-
} else {
68+
if (slab_is_available())
69+
section = kzalloc_node(array_size, GFP_KERNEL, nid);
70+
else
7471
section = memblock_virt_alloc_node(array_size, nid);
75-
}
7672

7773
return section;
7874
}

0 commit comments

Comments
 (0)