1111#include <linux/mmzone.h>
1212#include <linux/export.h>
1313#include <linux/nodemask.h>
14+ #include <linux/numa_memblks.h>
1415#include <linux/swap.h>
1516#include <linux/memblock.h>
1617#include <linux/pfn.h>
2728#include <asm/time.h>
2829
2930int numa_off ;
30- unsigned char node_distances [MAX_NUMNODES ][MAX_NUMNODES ];
31- EXPORT_SYMBOL (node_distances );
32-
33- static struct numa_meminfo numa_meminfo ;
3431cpumask_t cpus_on_node [MAX_NUMNODES ];
3532cpumask_t phys_cpus_on_node [MAX_NUMNODES ];
3633EXPORT_SYMBOL (cpus_on_node );
@@ -43,8 +40,6 @@ s16 __cpuid_to_node[CONFIG_NR_CPUS] = {
4340};
4441EXPORT_SYMBOL (__cpuid_to_node );
4542
46- nodemask_t numa_nodes_parsed __initdata ;
47-
4843#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
4944unsigned long __per_cpu_offset [NR_CPUS ] __read_mostly ;
5045EXPORT_SYMBOL (__per_cpu_offset );
@@ -145,48 +140,6 @@ void numa_remove_cpu(unsigned int cpu)
145140 cpumask_clear_cpu (cpu , & cpus_on_node [nid ]);
146141}
147142
148- static int __init numa_add_memblk_to (int nid , u64 start , u64 end ,
149- struct numa_meminfo * mi )
150- {
151- /* ignore zero length blks */
152- if (start == end )
153- return 0 ;
154-
155- /* whine about and ignore invalid blks */
156- if (start > end || nid < 0 || nid >= MAX_NUMNODES ) {
157- pr_warn ("NUMA: Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n" ,
158- nid , start , end - 1 );
159- return 0 ;
160- }
161-
162- if (mi -> nr_blks >= NR_NODE_MEMBLKS ) {
163- pr_err ("NUMA: too many memblk ranges\n" );
164- return - EINVAL ;
165- }
166-
167- mi -> blk [mi -> nr_blks ].start = PFN_ALIGN (start );
168- mi -> blk [mi -> nr_blks ].end = PFN_ALIGN (end - PAGE_SIZE + 1 );
169- mi -> blk [mi -> nr_blks ].nid = nid ;
170- mi -> nr_blks ++ ;
171- return 0 ;
172- }
173-
174- /**
175- * numa_add_memblk - Add one numa_memblk to numa_meminfo
176- * @nid: NUMA node ID of the new memblk
177- * @start: Start address of the new memblk
178- * @end: End address of the new memblk
179- *
180- * Add a new memblk to the default numa_meminfo.
181- *
182- * RETURNS:
183- * 0 on success, -errno on failure.
184- */
185- int __init numa_add_memblk (int nid , u64 start , u64 end )
186- {
187- return numa_add_memblk_to (nid , start , end , & numa_meminfo );
188- }
189-
190143static void __init node_mem_init (unsigned int node )
191144{
192145 unsigned long start_pfn , end_pfn ;
@@ -205,18 +158,6 @@ static void __init node_mem_init(unsigned int node)
205158
206159#ifdef CONFIG_ACPI_NUMA
207160
208- static void __init add_node_intersection (u32 node , u64 start , u64 size , u32 type )
209- {
210- static unsigned long num_physpages ;
211-
212- num_physpages += (size >> PAGE_SHIFT );
213- pr_info ("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n" ,
214- node , type , start , size );
215- pr_info (" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n" ,
216- start >> PAGE_SHIFT , (start + size ) >> PAGE_SHIFT , num_physpages );
217- memblock_set_node (start , size , & memblock .memory , node );
218- }
219-
220161/*
221162 * add_numamem_region
222163 *
@@ -228,28 +169,21 @@ static void __init add_node_intersection(u32 node, u64 start, u64 size, u32 type
228169 */
229170static void __init add_numamem_region (u64 start , u64 end , u32 type )
230171{
231- u32 i ;
232- u64 ofs = start ;
172+ u32 node = pa_to_nid (start );
173+ u64 size = end - start ;
174+ static unsigned long num_physpages ;
233175
234176 if (start >= end ) {
235177 pr_debug ("Invalid region: %016llx-%016llx\n" , start , end );
236178 return ;
237179 }
238180
239- for (i = 0 ; i < numa_meminfo .nr_blks ; i ++ ) {
240- struct numa_memblk * mb = & numa_meminfo .blk [i ];
241-
242- if (ofs > mb -> end )
243- continue ;
244-
245- if (end > mb -> end ) {
246- add_node_intersection (mb -> nid , ofs , mb -> end - ofs , type );
247- ofs = mb -> end ;
248- } else {
249- add_node_intersection (mb -> nid , ofs , end - ofs , type );
250- break ;
251- }
252- }
181+ num_physpages += (size >> PAGE_SHIFT );
182+ pr_info ("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n" ,
183+ node , type , start , size );
184+ pr_info (" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n" ,
185+ start >> PAGE_SHIFT , end >> PAGE_SHIFT , num_physpages );
186+ memblock_set_node (start , size , & memblock .memory , node );
253187}
254188
255189static void __init init_node_memblock (void )
@@ -291,24 +225,6 @@ static void __init init_node_memblock(void)
291225 }
292226}
293227
294- static void __init numa_default_distance (void )
295- {
296- int row , col ;
297-
298- for (row = 0 ; row < MAX_NUMNODES ; row ++ )
299- for (col = 0 ; col < MAX_NUMNODES ; col ++ ) {
300- if (col == row )
301- node_distances [row ][col ] = LOCAL_DISTANCE ;
302- else
303- /* We assume that one node per package here!
304- *
305- * A SLIT should be used for multiple nodes
306- * per package to override default setting.
307- */
308- node_distances [row ][col ] = REMOTE_DISTANCE ;
309- }
310- }
311-
312228/*
313229 * fake_numa_init() - For Non-ACPI systems
314230 * Return: 0 on success, -errno on failure.
@@ -333,11 +249,11 @@ int __init init_numa_memory(void)
333249 for (i = 0 ; i < NR_CPUS ; i ++ )
334250 set_cpuid_to_node (i , NUMA_NO_NODE );
335251
336- numa_default_distance ();
252+ numa_reset_distance ();
337253 nodes_clear (numa_nodes_parsed );
338254 nodes_clear (node_possible_map );
339255 nodes_clear (node_online_map );
340- memset ( & numa_meminfo , 0 , sizeof ( numa_meminfo ));
256+ WARN_ON ( memblock_clear_hotplug ( 0 , PHYS_ADDR_MAX ));
341257
342258 /* Parse SRAT and SLIT if provided by firmware. */
343259 ret = acpi_disabled ? fake_numa_init () : acpi_numa_init ();
0 commit comments