diff mbox series

[17/18] mm: Use less stack for page allocations

Message ID 20200619162425.1052382-18-ben.widawsky@intel.com (mailing list archive)
State New, archived
Headers show
Series multiple preferred nodes | expand

Commit Message

Ben Widawsky June 19, 2020, 4:24 p.m. UTC
After converting __alloc_pages_nodemask to take in a preferred
nodoemask, __alloc_pages_node is left holding the bag as requiring stack
space since it needs to generate a nodemask for the specific node.
The patch attempts to remove all callers of it unless absolutely
necessary to avoid using stack space which is theoretically significant
in huge NUMA systems.

It turns out there aren't too many opportunities to do this as all
callers know exactly what they want. The difference between
__alloc_pages_node and alloc_pages_node is the former is meant for
explicit node allocation while the latter support providing no
preference (by specifying NUMA_NO_NODE as nid). Now it becomes clear
that NUMA_NO_NODE can be implemented without using stack space via some
of the newer functions that have been added, in particular,
__alloc_pages_nodes and __alloc_pages_nodemask.

In the non NUMA case, alloc_pages used numa_node_id(), which is 0.
Switching to NUMA_NO_NODE allows us to avoid using the stack.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
---
 include/linux/gfp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 47e9c02c17ae..e78982ef9349 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -532,7 +532,7 @@  static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
 						unsigned int order)
 {
 	if (nid == NUMA_NO_NODE)
-		nid = numa_mem_id();
+		return __alloc_pages_nodes(NULL, gfp_mask, order);
 
 	return __alloc_pages_node(nid, gfp_mask, order);
 }
@@ -551,8 +551,8 @@  extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order,
 #define alloc_hugepage_vma(gfp_mask, vma, addr, order) \
 	alloc_pages_vma(gfp_mask, order, vma, addr, numa_node_id(), true)
 #else
-#define alloc_pages(gfp_mask, order) \
-		alloc_pages_node(numa_node_id(), gfp_mask, order)
+#define alloc_pages(gfp_mask, order)                                           \
+	alloc_pages_node(NUMA_NO_NODE, gfp_mask, order)
 #define alloc_pages_vma(gfp_mask, order, vma, addr, node, false)\
 	alloc_pages(gfp_mask, order)
 #define alloc_hugepage_vma(gfp_mask, vma, addr, order) \