Skip to content

Commit

Permalink
mm/memblock: use WARN_ONCE when MAX_NUMNODES passed as input parameter
Browse files Browse the repository at this point in the history
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: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Grygorii Strashko authored and Linus Torvalds committed Jan 22, 2014
1 parent 9a28f9d commit 560dca2
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,19 +785,17 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
struct memblock_type *rsv = &memblock.reserved;
int mi = *idx & 0xffffffff;
int ri = *idx >> 32;
bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);

if (nid == MAX_NUMNODES)
pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n",
__func__);
if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
nid = NUMA_NO_NODE;

for ( ; mi < mem->cnt; mi++) {
struct memblock_region *m = &mem->regions[mi];
phys_addr_t m_start = m->base;
phys_addr_t m_end = m->base + m->size;

/* 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;

/* scan areas before each reservation for intersection */
Expand Down Expand Up @@ -858,11 +856,9 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
struct memblock_type *rsv = &memblock.reserved;
int mi = *idx & 0xffffffff;
int ri = *idx >> 32;
bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);

if (nid == MAX_NUMNODES)
pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n",
__func__);
if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
nid = NUMA_NO_NODE;

if (*idx == (u64)ULLONG_MAX) {
mi = mem->cnt - 1;
Expand All @@ -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;

/* 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;

/* skip hotpluggable memory regions if needed */
Expand Down Expand Up @@ -1067,9 +1063,8 @@ static void * __init memblock_virt_alloc_internal(
phys_addr_t alloc;
void *ptr;

if (nid == MAX_NUMNODES)
pr_warn("%s: usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE\n",
__func__);
if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
nid = NUMA_NO_NODE;

/*
* Detect any accidental use of these APIs after slab is ready, as at
Expand Down

0 comments on commit 560dca2

Please sign in to comment.