aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2014-01-21 18:50:55 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-21 19:19:48 -0500
commit560dca27a6b36015e4f69a4ceba0ee5be0707c17 (patch)
tree961006de1f5ef34d462bfc7de5018b63ef56061d /mm/memblock.c
parent9a28f9dc8d10b619af9a37b1e27c41ada5415629 (diff)
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: 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>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 018e55dc004d..1c2ef2c7edab 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -785,11 +785,9 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
785 struct memblock_type *rsv = &memblock.reserved; 785 struct memblock_type *rsv = &memblock.reserved;
786 int mi = *idx & 0xffffffff; 786 int mi = *idx & 0xffffffff;
787 int ri = *idx >> 32; 787 int ri = *idx >> 32;
788 bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
789 788
790 if (nid == MAX_NUMNODES) 789 if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
791 pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n", 790 nid = NUMA_NO_NODE;
792 __func__);
793 791
794 for ( ; mi < mem->cnt; mi++) { 792 for ( ; mi < mem->cnt; mi++) {
795 struct memblock_region *m = &mem->regions[mi]; 793 struct memblock_region *m = &mem->regions[mi];
@@ -797,7 +795,7 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
797 phys_addr_t m_end = m->base + m->size; 795 phys_addr_t m_end = m->base + m->size;
798 796
799 /* only memory regions are associated with nodes, check it */ 797 /* only memory regions are associated with nodes, check it */
800 if (check_node && nid != memblock_get_region_node(m)) 798 if (nid != NUMA_NO_NODE && nid != memblock_get_region_node(m))
801 continue; 799 continue;
802 800
803 /* scan areas before each reservation for intersection */ 801 /* scan areas before each reservation for intersection */
@@ -858,11 +856,9 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
858 struct memblock_type *rsv = &memblock.reserved; 856 struct memblock_type *rsv = &memblock.reserved;
859 int mi = *idx & 0xffffffff; 857 int mi = *idx & 0xffffffff;
860 int ri = *idx >> 32; 858 int ri = *idx >> 32;
861 bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
862 859
863 if (nid == MAX_NUMNODES) 860 if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
864 pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n", 861 nid = NUMA_NO_NODE;
865 __func__);
866 862
867 if (*idx == (u64)ULLONG_MAX) { 863 if (*idx == (u64)ULLONG_MAX) {
868 mi = mem->cnt - 1; 864 mi = mem->cnt - 1;
@@ -875,7 +871,7 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
875 phys_addr_t m_end = m->base + m->size; 871 phys_addr_t m_end = m->base + m->size;
876 872
877 /* only memory regions are associated with nodes, check it */ 873 /* only memory regions are associated with nodes, check it */
878 if (check_node && nid != memblock_get_region_node(m)) 874 if (nid != NUMA_NO_NODE && nid != memblock_get_region_node(m))
879 continue; 875 continue;
880 876
881 /* skip hotpluggable memory regions if needed */ 877 /* skip hotpluggable memory regions if needed */
@@ -1067,9 +1063,8 @@ static void * __init memblock_virt_alloc_internal(
1067 phys_addr_t alloc; 1063 phys_addr_t alloc;
1068 void *ptr; 1064 void *ptr;
1069 1065
1070 if (nid == MAX_NUMNODES) 1066 if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
1071 pr_warn("%s: usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE\n", 1067 nid = NUMA_NO_NODE;
1072 __func__);
1073 1068
1074 /* 1069 /*
1075 * Detect any accidental use of these APIs after slab is ready, as at 1070 * Detect any accidental use of these APIs after slab is ready, as at