path: root/mm/slob.c
diff options
authorVlastimil Babka <>2015-09-08 15:03:50 -0700
committerLinus Torvalds <>2015-09-08 15:35:28 -0700
commit96db800f5d73cd5c49461253d45766e094f0f8c2 (patch)
tree7f6ea4c232c04196cedf34d8b35cce641228daa6 /mm/slob.c
parent7fadc820222497eac234d1d51a66517c00a6ca4c (diff)
mm: rename alloc_pages_exact_node() to __alloc_pages_node()
alloc_pages_exact_node() was introduced in commit 6484eb3e2a81 ("page allocator: do not check NUMA node ID when the caller knows the node is valid") as an optimized variant of alloc_pages_node(), that doesn't fallback to current node for nid == NUMA_NO_NODE. Unfortunately the name of the function can easily suggest that the allocation is restricted to the given node and fails otherwise. In truth, the node is only preferred, unless __GFP_THISNODE is passed among the gfp flags. The misleading name has lead to mistakes in the past, see for example commits 5265047ac301 ("mm, thp: really limit transparent hugepage allocation to local node") and b360edb43f8e ("mm, mempolicy: migrate_to_node should only migrate to node"). Another issue with the name is that there's a family of alloc_pages_exact*() functions where 'exact' means exact size (instead of page order), which leads to more confusion. To prevent further mistakes, this patch effectively renames alloc_pages_exact_node() to __alloc_pages_node() to better convey that it's an optimized variant of alloc_pages_node() not intended for general usage. Both functions get described in comments. It has been also considered to really provide a convenience function for allocations restricted to a node, but the major opinion seems to be that __GFP_THISNODE already provides that functionality and we shouldn't duplicate the API needlessly. The number of users would be small anyway. Existing callers of alloc_pages_exact_node() are simply converted to call __alloc_pages_node(), with the exception of sba_alloc_coherent() which open-codes the check for NUMA_NO_NODE, so it is converted to use alloc_pages_node() instead. This means it no longer performs some VM_BUG_ON checks, and since the current check for nid in alloc_pages_node() uses a 'nid < 0' comparison (which includes NUMA_NO_NODE), it may hide wrong values which would be previously exposed. Both differences will be rectified by the next patch. To sum up, this patch makes no functional changes, except temporarily hiding potentially buggy callers. Restricting the checks in alloc_pages_node() is left for the next patch which can in turn expose more existing buggy callers. Signed-off-by: Vlastimil Babka <> Acked-by: Johannes Weiner <> Acked-by: Robin Holt <> Acked-by: Michal Hocko <> Acked-by: Christoph Lameter <> Acked-by: Michael Ellerman <> Cc: Mel Gorman <> Cc: David Rientjes <> Cc: Greg Thelen <> Cc: Aneesh Kumar K.V <> Cc: Pekka Enberg <> Cc: Joonsoo Kim <> Cc: Naoya Horiguchi <> Cc: Tony Luck <> Cc: Fenghua Yu <> Cc: Arnd Bergmann <> Cc: Benjamin Herrenschmidt <> Cc: Paul Mackerras <> Cc: Gleb Natapov <> Cc: Paolo Bonzini <> Cc: Thomas Gleixner <> Cc: Ingo Molnar <> Cc: "H. Peter Anvin" <> Cc: Cliff Whickman <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/slob.c')
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/slob.c b/mm/slob.c
index 165bbd3cd606..0d7e5df74d1f 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -45,7 +45,7 @@
* NUMA support in SLOB is fairly simplistic, pushing most of the real
* logic down to the page allocator, and simply doing the node accounting
* on the upper levels. In the event that a node id is explicitly
- * provided, alloc_pages_exact_node() with the specified node id is used
+ * provided, __alloc_pages_node() with the specified node id is used
* instead. The common case (or when the node id isn't explicitly provided)
* will default to the current node, as per numa_node_id().
@@ -193,7 +193,7 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
if (node != NUMA_NO_NODE)
- page = alloc_pages_exact_node(node, gfp, order);
+ page = __alloc_pages_node(node, gfp, order);
page = alloc_pages(gfp, order);