Commit 560dca27 authored by Grygorii Strashko's avatar Grygorii Strashko Committed by Linus Torvalds

mm/memblock: use WARN_ONCE when MAX_NUMNODES passed as input parameter

Check nid parameter and produce warning if it has deprecated
MAX_NUMNODES value.  Also re-assign NUMA_NO_NODE value to the nid
parameter in this case.

These will help to identify the wrong API usage (the caller) and make
code simpler.
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9a28f9dc
...@@ -785,11 +785,9 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid, ...@@ -785,11 +785,9 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
struct memblock_type *rsv = &memblock.reserved; struct memblock_type *rsv = &memblock.reserved;
int mi = *idx & 0xffffffff; int mi = *idx & 0xffffffff;
int ri = *idx >> 32; int ri = *idx >> 32;
bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
if (nid == MAX_NUMNODES) if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n", nid = NUMA_NO_NODE;
__func__);
for ( ; mi < mem->cnt; mi++) { for ( ; mi < mem->cnt; mi++) {
struct memblock_region *m = &mem->regions[mi]; struct memblock_region *m = &mem->regions[mi];
...@@ -797,7 +795,7 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid, ...@@ -797,7 +795,7 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
phys_addr_t m_end = m->base + m->size; phys_addr_t m_end = m->base + m->size;
/* only memory regions are associated with nodes, check it */ /* only memory regions are associated with nodes, check it */
if (check_node && nid != memblock_get_region_node(m)) if (nid != NUMA_NO_NODE && nid != memblock_get_region_node(m))
continue; continue;
/* scan areas before each reservation for intersection */ /* scan areas before each reservation for intersection */
...@@ -858,11 +856,9 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid, ...@@ -858,11 +856,9 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
struct memblock_type *rsv = &memblock.reserved; struct memblock_type *rsv = &memblock.reserved;
int mi = *idx & 0xffffffff; int mi = *idx & 0xffffffff;
int ri = *idx >> 32; int ri = *idx >> 32;
bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
if (nid == MAX_NUMNODES) if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n", nid = NUMA_NO_NODE;
__func__);
if (*idx == (u64)ULLONG_MAX) { if (*idx == (u64)ULLONG_MAX) {
mi = mem->cnt - 1; mi = mem->cnt - 1;
...@@ -875,7 +871,7 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid, ...@@ -875,7 +871,7 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
phys_addr_t m_end = m->base + m->size; phys_addr_t m_end = m->base + m->size;
/* only memory regions are associated with nodes, check it */ /* only memory regions are associated with nodes, check it */
if (check_node && nid != memblock_get_region_node(m)) if (nid != NUMA_NO_NODE && nid != memblock_get_region_node(m))
continue; continue;
/* skip hotpluggable memory regions if needed */ /* skip hotpluggable memory regions if needed */
...@@ -1067,9 +1063,8 @@ static void * __init memblock_virt_alloc_internal( ...@@ -1067,9 +1063,8 @@ static void * __init memblock_virt_alloc_internal(
phys_addr_t alloc; phys_addr_t alloc;
void *ptr; void *ptr;
if (nid == MAX_NUMNODES) if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
pr_warn("%s: usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE\n", nid = NUMA_NO_NODE;
__func__);
/* /*
* Detect any accidental use of these APIs after slab is ready, as at * Detect any accidental use of these APIs after slab is ready, as at
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment