x86/mm/numa: Clean up topology parsing in amd_numa_init()
PATCH 1/2 x86/mm/numa: Clean up topology parsing in amd_numa_init()
Since commit e23bba604433 ("x86-64, NUMA: Unify emulated distance mapping"), nodeids[] is only written but never read. Remove it.
Also drop the start variable and the base < start clamp, since start is always zero and the expression always false.
While at it, use min() for the limit > end clamp and drop the redundant second limit > end clamp.
Signed-off-by Thorsten Blum <[email protected]>
--- arch/x86/mm/amdtopology.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
arch/x86/mm/amdtopology.c +3 -12
@@ -27,8 +27,6 @@#include <asm/apic.h> #include <asm/amd/nb.h> -static unsigned char __initdata nodeids[8 ]; -static __init int find_northbridge (void ) {int num;
@@ -56,7 +54,7 @@ static __init int find_northbridge(void)int __init amd_numa_init (void ) {unsigned int numnodes, cores, apicid; -u64 prevbase, start =PFN_PHYS (0 ); +u64 prevbase;u64 end =PFN_PHYS (max_pfn);u32 nodeid, reg;int i, j, nb;
@@ -84,7 +82,7 @@ int __init amd_numa_init(void) base =read_pci_config (0 , nb,1 ,0x40 + i*8 ); limit =read_pci_config (0 , nb,1 ,0x44 + i*8 ); - nodeids[i] = nodeid = limit &7 ; + nodeid = limit &7 ;if ((base &3 ) ==0 ) {if (i < numnodes)pr_info ("Skipping disabled node %d\n" , i);
@@ -115,19 +113,12 @@ int __init amd_numa_init(void) limit >>=16 ; limit++; limit <<=24 ; - -if (limit > end) - limit = end; + limit =min (limit, end);if (limit <= base)continue ; base >>=16 ; base <<=24 ; - -if (base < start) - base = start; -if (limit > end) - limit = end;if (limit == base) {pr_err ("Empty node %d\n" , nodeid);continue ;
PATCH 2/2 x86/mm/numa: Update format specifiers in amd_numa_init()
Use %u instead of %d as format specifiers when printing numnodes and nodeid values, which are both unsigned integers.
Use %llx instead of %Lx for the u64 base and limit values.
Signed-off-by Thorsten Blum <[email protected]>
--- arch/x86/mm/amdtopology.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
arch/x86/mm/amdtopology.c +9 -10
@@ -73,7 +73,7 @@ int __init amd_numa_init(void)if (numnodes <=1 )return -ENOENT ; -pr_info ("Number of physical nodes %d\n" , numnodes); +pr_info ("Number of physical nodes %u\n" , numnodes); prevbase =0 ;for (i =0 ; i <8 ; i++) {
@@ -89,24 +89,23 @@ int __init amd_numa_init(void)continue ; }if (nodeid >= numnodes) { -pr_info ("Ignoring excess node %d (%Lx:%Lx)\n" , nodeid, +pr_info ("Ignoring excess node %u (%llx:%llx)\n" , nodeid, base, limit);continue ; }if (!limit) { -pr_info ("Skipping node entry %d (base %Lx)\n" , +pr_info ("Skipping node entry %d (base %llx)\n" , i, base);continue ; }if ((base >>8 ) &3 || (limit >>8 ) &3 ) { -pr_err ("Node %d using interleaving mode %Lx/%Lx\n" , +pr_err ("Node %u using interleaving mode %llx/%llx\n" , nodeid, (base >>8 ) &3 , (limit >>8 ) &3 );return -EINVAL ; }if (node_isset (nodeid, numa_nodes_parsed)) { -pr_info ("Node %d already present, skipping\n" , - nodeid); +pr_info ("Node %u already present, skipping\n" , nodeid);continue ; }
@@ -120,23 +119,23 @@ int __init amd_numa_init(void) base >>=16 ; base <<=24 ;if (limit == base) { -pr_err ("Empty node %d\n" , nodeid); +pr_err ("Empty node %u\n" , nodeid);continue ; }if (limit < base) { -pr_err ("Node %d bogus settings %Lx-%Lx.\n" , +pr_err ("Node %u bogus settings %llx-%llx.\n" , nodeid, base, limit);continue ; }/* Could sort here, but pun for now. Should not happen anyroads. */ if (prevbase > base) { -pr_err ("Node map not sorted %Lx,%Lx\n" , +pr_err ("Node map not sorted %llx,%llx\n" , prevbase, base);return -EINVAL ; } -pr_info ("Node %d MemBase %016Lx Limit %016Lx\n" , +pr_info ("Node %u MemBase %016llx Limit %016llx\n" , nodeid, base, limit); prevbase = base;