2 * Generic VM initialization for x86-64 NUMA setups.
3 * Copyright 2002,2003 Andi Kleen, SuSE Labs.
5 #include <linux/kernel.h>
7 #include <linux/string.h>
8 #include <linux/init.h>
9 #include <linux/bootmem.h>
10 #include <linux/memblock.h>
11 #include <linux/mmzone.h>
12 #include <linux/ctype.h>
13 #include <linux/module.h>
14 #include <linux/nodemask.h>
15 #include <linux/sched.h>
18 #include <asm/proto.h>
22 #include <asm/amd_nb.h>
24 struct pglist_data
*node_data
[MAX_NUMNODES
] __read_mostly
;
25 EXPORT_SYMBOL(node_data
);
27 struct memnode memnode
;
29 static unsigned long __initdata nodemap_addr
;
30 static unsigned long __initdata nodemap_size
;
33 * Given a shift value, try to populate memnodemap[]
36 * 0 if memnodmap[] too small (of shift too small)
37 * -1 if node overlap or lost ram (shift too big)
39 static int __init
populate_memnodemap(const struct bootnode
*nodes
,
40 int numnodes
, int shift
, int *nodeids
)
42 unsigned long addr
, end
;
45 memset(memnodemap
, 0xff, sizeof(s16
)*memnodemapsize
);
46 for (i
= 0; i
< numnodes
; i
++) {
47 addr
= nodes
[i
].start
;
51 if ((end
>> shift
) >= memnodemapsize
)
54 if (memnodemap
[addr
>> shift
] != NUMA_NO_NODE
)
58 memnodemap
[addr
>> shift
] = i
;
60 memnodemap
[addr
>> shift
] = nodeids
[i
];
62 addr
+= (1UL << shift
);
69 static int __init
allocate_cachealigned_memnodemap(void)
73 memnodemap
= memnode
.embedded_map
;
74 if (memnodemapsize
<= ARRAY_SIZE(memnode
.embedded_map
))
78 nodemap_size
= roundup(sizeof(s16
) * memnodemapsize
, L1_CACHE_BYTES
);
79 nodemap_addr
= memblock_find_in_range(addr
, max_pfn
<<PAGE_SHIFT
,
80 nodemap_size
, L1_CACHE_BYTES
);
81 if (nodemap_addr
== MEMBLOCK_ERROR
) {
83 "NUMA: Unable to allocate Memory to Node hash map\n");
84 nodemap_addr
= nodemap_size
= 0;
87 memnodemap
= phys_to_virt(nodemap_addr
);
88 memblock_x86_reserve_range(nodemap_addr
, nodemap_addr
+ nodemap_size
, "MEMNODEMAP");
90 printk(KERN_DEBUG
"NUMA: Allocated memnodemap from %lx - %lx\n",
91 nodemap_addr
, nodemap_addr
+ nodemap_size
);
96 * The LSB of all start and end addresses in the node map is the value of the
97 * maximum possible shift.
99 static int __init
extract_lsb_from_nodes(const struct bootnode
*nodes
,
102 int i
, nodes_used
= 0;
103 unsigned long start
, end
;
104 unsigned long bitfield
= 0, memtop
= 0;
106 for (i
= 0; i
< numnodes
; i
++) {
107 start
= nodes
[i
].start
;
119 i
= find_first_bit(&bitfield
, sizeof(unsigned long)*8);
120 memnodemapsize
= (memtop
>> i
)+1;
124 int __init
compute_hash_shift(struct bootnode
*nodes
, int numnodes
,
129 shift
= extract_lsb_from_nodes(nodes
, numnodes
);
130 if (allocate_cachealigned_memnodemap())
132 printk(KERN_DEBUG
"NUMA: Using %d for the hash shift.\n",
135 if (populate_memnodemap(nodes
, numnodes
, shift
, nodeids
) != 1) {
136 printk(KERN_INFO
"Your memory is not aligned you need to "
137 "rebuild your kernel with a bigger NODEMAPSIZE "
138 "shift=%d\n", shift
);
144 int __meminit
__early_pfn_to_nid(unsigned long pfn
)
146 return phys_to_nid(pfn
<< PAGE_SHIFT
);
149 static void * __init
early_node_mem(int nodeid
, unsigned long start
,
150 unsigned long end
, unsigned long size
,
156 * put it on high as possible
157 * something will go with NODE_DATA
159 if (start
< (MAX_DMA_PFN
<<PAGE_SHIFT
))
160 start
= MAX_DMA_PFN
<<PAGE_SHIFT
;
161 if (start
< (MAX_DMA32_PFN
<<PAGE_SHIFT
) &&
162 end
> (MAX_DMA32_PFN
<<PAGE_SHIFT
))
163 start
= MAX_DMA32_PFN
<<PAGE_SHIFT
;
164 mem
= memblock_x86_find_in_range_node(nodeid
, start
, end
, size
, align
);
165 if (mem
!= MEMBLOCK_ERROR
)
168 /* extend the search scope */
169 end
= max_pfn_mapped
<< PAGE_SHIFT
;
170 start
= MAX_DMA_PFN
<< PAGE_SHIFT
;
171 mem
= memblock_find_in_range(start
, end
, size
, align
);
172 if (mem
!= MEMBLOCK_ERROR
)
175 printk(KERN_ERR
"Cannot find %lu bytes in node %d\n",
181 /* Initialize bootmem allocator for a node */
183 setup_node_bootmem(int nodeid
, unsigned long start
, unsigned long end
)
185 unsigned long start_pfn
, last_pfn
, nodedata_phys
;
186 const int pgdat_size
= roundup(sizeof(pg_data_t
), PAGE_SIZE
);
193 * Don't confuse VM with a node that doesn't have the
194 * minimum amount of memory:
196 if (end
&& (end
- start
) < NODE_MIN_SIZE
)
199 start
= roundup(start
, ZONE_ALIGN
);
201 printk(KERN_INFO
"Initmem setup node %d %016lx-%016lx\n", nodeid
,
204 start_pfn
= start
>> PAGE_SHIFT
;
205 last_pfn
= end
>> PAGE_SHIFT
;
207 node_data
[nodeid
] = early_node_mem(nodeid
, start
, end
, pgdat_size
,
209 if (node_data
[nodeid
] == NULL
)
211 nodedata_phys
= __pa(node_data
[nodeid
]);
212 memblock_x86_reserve_range(nodedata_phys
, nodedata_phys
+ pgdat_size
, "NODE_DATA");
213 printk(KERN_INFO
" NODE_DATA [%016lx - %016lx]\n", nodedata_phys
,
214 nodedata_phys
+ pgdat_size
- 1);
215 nid
= phys_to_nid(nodedata_phys
);
217 printk(KERN_INFO
" NODE_DATA(%d) on node %d\n", nodeid
, nid
);
219 memset(NODE_DATA(nodeid
), 0, sizeof(pg_data_t
));
220 NODE_DATA(nodeid
)->node_id
= nodeid
;
221 NODE_DATA(nodeid
)->node_start_pfn
= start_pfn
;
222 NODE_DATA(nodeid
)->node_spanned_pages
= last_pfn
- start_pfn
;
224 node_set_online(nodeid
);
228 * There are unfortunately some poorly designed mainboards around that
229 * only connect memory to a single CPU. This breaks the 1:1 cpu->node
230 * mapping. To avoid this fill in the mapping for all possible CPUs,
231 * as the number of CPUs is not known yet. We round robin the existing
234 void __init
numa_init_array(void)
238 rr
= first_node(node_online_map
);
239 for (i
= 0; i
< nr_cpu_ids
; i
++) {
240 if (early_cpu_to_node(i
) != NUMA_NO_NODE
)
242 numa_set_node(i
, rr
);
243 rr
= next_node(rr
, node_online_map
);
244 if (rr
== MAX_NUMNODES
)
245 rr
= first_node(node_online_map
);
249 #ifdef CONFIG_NUMA_EMU
251 static struct bootnode nodes
[MAX_NUMNODES
] __initdata
;
252 static struct bootnode physnodes
[MAX_NUMNODES
] __cpuinitdata
;
253 static char *cmdline __initdata
;
255 void __init
numa_emu_cmdline(char *str
)
260 static int __init
setup_physnodes(unsigned long start
, unsigned long end
,
266 memset(physnodes
, 0, sizeof(physnodes
));
267 #ifdef CONFIG_ACPI_NUMA
269 acpi_get_nodes(physnodes
, start
, end
);
271 #ifdef CONFIG_AMD_NUMA
273 amd_get_nodes(physnodes
);
276 * Basic sanity checking on the physical node map: there may be errors
277 * if the SRAT or AMD code incorrectly reported the topology or the mem=
278 * kernel parameter is used.
280 for (i
= 0; i
< MAX_NUMNODES
; i
++) {
281 if (physnodes
[i
].start
== physnodes
[i
].end
)
283 if (physnodes
[i
].start
> end
) {
284 physnodes
[i
].end
= physnodes
[i
].start
;
287 if (physnodes
[i
].end
< start
) {
288 physnodes
[i
].start
= physnodes
[i
].end
;
291 if (physnodes
[i
].start
< start
)
292 physnodes
[i
].start
= start
;
293 if (physnodes
[i
].end
> end
)
294 physnodes
[i
].end
= end
;
299 * If no physical topology was detected, a single node is faked to cover
300 * the entire address space.
303 physnodes
[ret
].start
= start
;
304 physnodes
[ret
].end
= end
;
310 static void __init
fake_physnodes(int acpi
, int amd
, int nr_nodes
)
315 #ifdef CONFIG_ACPI_NUMA
317 acpi_fake_nodes(nodes
, nr_nodes
);
319 #ifdef CONFIG_AMD_NUMA
321 amd_fake_nodes(nodes
, nr_nodes
);
324 for (i
= 0; i
< nr_cpu_ids
; i
++)
329 * Setups up nid to range from addr to addr + size. If the end
330 * boundary is greater than max_addr, then max_addr is used instead.
331 * The return value is 0 if there is additional memory left for
332 * allocation past addr and -1 otherwise. addr is adjusted to be at
333 * the end of the node.
335 static int __init
setup_node_range(int nid
, u64
*addr
, u64 size
, u64 max_addr
)
338 nodes
[nid
].start
= *addr
;
340 if (*addr
>= max_addr
) {
344 nodes
[nid
].end
= *addr
;
345 node_set(nid
, node_possible_map
);
346 printk(KERN_INFO
"Faking node %d at %016Lx-%016Lx (%LuMB)\n", nid
,
347 nodes
[nid
].start
, nodes
[nid
].end
,
348 (nodes
[nid
].end
- nodes
[nid
].start
) >> 20);
353 * Sets up nr_nodes fake nodes interleaved over physical nodes ranging from addr
354 * to max_addr. The return value is the number of nodes allocated.
356 static int __init
split_nodes_interleave(u64 addr
, u64 max_addr
, int nr_nodes
)
358 nodemask_t physnode_mask
= NODE_MASK_NONE
;
366 if (nr_nodes
> MAX_NUMNODES
) {
367 pr_info("numa=fake=%d too large, reducing to %d\n",
368 nr_nodes
, MAX_NUMNODES
);
369 nr_nodes
= MAX_NUMNODES
;
372 size
= (max_addr
- addr
- memblock_x86_hole_size(addr
, max_addr
)) / nr_nodes
;
374 * Calculate the number of big nodes that can be allocated as a result
375 * of consolidating the remainder.
377 big
= ((size
& ~FAKE_NODE_MIN_HASH_MASK
) * nr_nodes
) /
380 size
&= FAKE_NODE_MIN_HASH_MASK
;
382 pr_err("Not enough memory for each node. "
383 "NUMA emulation disabled.\n");
387 for (i
= 0; i
< MAX_NUMNODES
; i
++)
388 if (physnodes
[i
].start
!= physnodes
[i
].end
)
389 node_set(i
, physnode_mask
);
392 * Continue to fill physical nodes with fake nodes until there is no
393 * memory left on any of them.
395 while (nodes_weight(physnode_mask
)) {
396 for_each_node_mask(i
, physnode_mask
) {
397 u64 end
= physnodes
[i
].start
+ size
;
398 u64 dma32_end
= PFN_PHYS(MAX_DMA32_PFN
);
401 end
+= FAKE_NODE_MIN_SIZE
;
404 * Continue to add memory to this fake node if its
405 * non-reserved memory is less than the per-node size.
407 while (end
- physnodes
[i
].start
-
408 memblock_x86_hole_size(physnodes
[i
].start
, end
) < size
) {
409 end
+= FAKE_NODE_MIN_SIZE
;
410 if (end
> physnodes
[i
].end
) {
411 end
= physnodes
[i
].end
;
417 * If there won't be at least FAKE_NODE_MIN_SIZE of
418 * non-reserved memory in ZONE_DMA32 for the next node,
419 * this one must extend to the boundary.
421 if (end
< dma32_end
&& dma32_end
- end
-
422 memblock_x86_hole_size(end
, dma32_end
) < FAKE_NODE_MIN_SIZE
)
426 * If there won't be enough non-reserved memory for the
427 * next node, this one must extend to the end of the
430 if (physnodes
[i
].end
- end
-
431 memblock_x86_hole_size(end
, physnodes
[i
].end
) < size
)
432 end
= physnodes
[i
].end
;
435 * Avoid allocating more nodes than requested, which can
436 * happen as a result of rounding down each node's size
437 * to FAKE_NODE_MIN_SIZE.
439 if (nodes_weight(physnode_mask
) + ret
>= nr_nodes
)
440 end
= physnodes
[i
].end
;
442 if (setup_node_range(ret
++, &physnodes
[i
].start
,
443 end
- physnodes
[i
].start
,
444 physnodes
[i
].end
) < 0)
445 node_clear(i
, physnode_mask
);
452 * Returns the end address of a node so that there is at least `size' amount of
453 * non-reserved memory or `max_addr' is reached.
455 static u64 __init
find_end_of_node(u64 start
, u64 max_addr
, u64 size
)
457 u64 end
= start
+ size
;
459 while (end
- start
- memblock_x86_hole_size(start
, end
) < size
) {
460 end
+= FAKE_NODE_MIN_SIZE
;
461 if (end
> max_addr
) {
470 * Sets up fake nodes of `size' interleaved over physical nodes ranging from
471 * `addr' to `max_addr'. The return value is the number of nodes allocated.
473 static int __init
split_nodes_size_interleave(u64 addr
, u64 max_addr
, u64 size
)
475 nodemask_t physnode_mask
= NODE_MASK_NONE
;
483 * The limit on emulated nodes is MAX_NUMNODES, so the size per node is
484 * increased accordingly if the requested size is too small. This
485 * creates a uniform distribution of node sizes across the entire
486 * machine (but not necessarily over physical nodes).
488 min_size
= (max_addr
- addr
- memblock_x86_hole_size(addr
, max_addr
)) /
490 min_size
= max(min_size
, FAKE_NODE_MIN_SIZE
);
491 if ((min_size
& FAKE_NODE_MIN_HASH_MASK
) < min_size
)
492 min_size
= (min_size
+ FAKE_NODE_MIN_SIZE
) &
493 FAKE_NODE_MIN_HASH_MASK
;
494 if (size
< min_size
) {
495 pr_err("Fake node size %LuMB too small, increasing to %LuMB\n",
496 size
>> 20, min_size
>> 20);
499 size
&= FAKE_NODE_MIN_HASH_MASK
;
501 for (i
= 0; i
< MAX_NUMNODES
; i
++)
502 if (physnodes
[i
].start
!= physnodes
[i
].end
)
503 node_set(i
, physnode_mask
);
505 * Fill physical nodes with fake nodes of size until there is no memory
506 * left on any of them.
508 while (nodes_weight(physnode_mask
)) {
509 for_each_node_mask(i
, physnode_mask
) {
510 u64 dma32_end
= MAX_DMA32_PFN
<< PAGE_SHIFT
;
513 end
= find_end_of_node(physnodes
[i
].start
,
514 physnodes
[i
].end
, size
);
516 * If there won't be at least FAKE_NODE_MIN_SIZE of
517 * non-reserved memory in ZONE_DMA32 for the next node,
518 * this one must extend to the boundary.
520 if (end
< dma32_end
&& dma32_end
- end
-
521 memblock_x86_hole_size(end
, dma32_end
) < FAKE_NODE_MIN_SIZE
)
525 * If there won't be enough non-reserved memory for the
526 * next node, this one must extend to the end of the
529 if (physnodes
[i
].end
- end
-
530 memblock_x86_hole_size(end
, physnodes
[i
].end
) < size
)
531 end
= physnodes
[i
].end
;
534 * Setup the fake node that will be allocated as bootmem
535 * later. If setup_node_range() returns non-zero, there
536 * is no more memory available on this physical node.
538 if (setup_node_range(ret
++, &physnodes
[i
].start
,
539 end
- physnodes
[i
].start
,
540 physnodes
[i
].end
) < 0)
541 node_clear(i
, physnode_mask
);
548 * Sets up the system RAM area from start_pfn to last_pfn according to the
549 * numa=fake command-line option.
551 static int __init
numa_emulation(unsigned long start_pfn
,
552 unsigned long last_pfn
, int acpi
, int amd
)
554 u64 addr
= start_pfn
<< PAGE_SHIFT
;
555 u64 max_addr
= last_pfn
<< PAGE_SHIFT
;
560 * If the numa=fake command-line contains a 'M' or 'G', it represents
561 * the fixed node size. Otherwise, if it is just a single number N,
562 * split the system RAM into N fake nodes.
564 if (strchr(cmdline
, 'M') || strchr(cmdline
, 'G')) {
567 size
= memparse(cmdline
, &cmdline
);
568 num_nodes
= split_nodes_size_interleave(addr
, max_addr
, size
);
572 n
= simple_strtoul(cmdline
, NULL
, 0);
573 num_nodes
= split_nodes_interleave(addr
, max_addr
, n
);
578 memnode_shift
= compute_hash_shift(nodes
, num_nodes
, NULL
);
579 if (memnode_shift
< 0) {
581 printk(KERN_ERR
"No NUMA hash function found. NUMA emulation "
587 * We need to vacate all active ranges that may have been registered for
588 * the e820 memory map.
590 remove_all_active_ranges();
591 for_each_node_mask(i
, node_possible_map
) {
592 memblock_x86_register_active_regions(i
, nodes
[i
].start
>> PAGE_SHIFT
,
593 nodes
[i
].end
>> PAGE_SHIFT
);
594 setup_node_bootmem(i
, nodes
[i
].start
, nodes
[i
].end
);
596 setup_physnodes(addr
, max_addr
, acpi
, amd
);
597 fake_physnodes(acpi
, amd
, num_nodes
);
601 #endif /* CONFIG_NUMA_EMU */
603 void __init
initmem_init(unsigned long start_pfn
, unsigned long last_pfn
,
608 nodes_clear(node_possible_map
);
609 nodes_clear(node_online_map
);
611 #ifdef CONFIG_NUMA_EMU
612 setup_physnodes(start_pfn
<< PAGE_SHIFT
, last_pfn
<< PAGE_SHIFT
,
614 if (cmdline
&& !numa_emulation(start_pfn
, last_pfn
, acpi
, amd
))
616 setup_physnodes(start_pfn
<< PAGE_SHIFT
, last_pfn
<< PAGE_SHIFT
,
618 nodes_clear(node_possible_map
);
619 nodes_clear(node_online_map
);
622 #ifdef CONFIG_ACPI_NUMA
623 if (!numa_off
&& acpi
&& !acpi_scan_nodes(start_pfn
<< PAGE_SHIFT
,
624 last_pfn
<< PAGE_SHIFT
))
626 nodes_clear(node_possible_map
);
627 nodes_clear(node_online_map
);
630 #ifdef CONFIG_AMD_NUMA
631 if (!numa_off
&& amd
&& !amd_scan_nodes())
633 nodes_clear(node_possible_map
);
634 nodes_clear(node_online_map
);
636 printk(KERN_INFO
"%s\n",
637 numa_off
? "NUMA turned off" : "No NUMA configuration found");
639 printk(KERN_INFO
"Faking a node at %016lx-%016lx\n",
640 start_pfn
<< PAGE_SHIFT
,
641 last_pfn
<< PAGE_SHIFT
);
642 /* setup dummy node covering all memory */
644 memnodemap
= memnode
.embedded_map
;
647 node_set(0, node_possible_map
);
648 for (i
= 0; i
< nr_cpu_ids
; i
++)
650 memblock_x86_register_active_regions(0, start_pfn
, last_pfn
);
651 setup_node_bootmem(0, start_pfn
<< PAGE_SHIFT
, last_pfn
<< PAGE_SHIFT
);
654 unsigned long __init
numa_free_all_bootmem(void)
656 unsigned long pages
= 0;
659 for_each_online_node(i
)
660 pages
+= free_all_bootmem_node(NODE_DATA(i
));
662 pages
+= free_all_memory_core_early(MAX_NUMNODES
);
669 static __init
int find_near_online_node(int node
)
672 int min_val
= INT_MAX
;
675 for_each_online_node(n
) {
676 val
= node_distance(node
, n
);
688 * Setup early cpu_to_node.
690 * Populate cpu_to_node[] only if x86_cpu_to_apicid[],
691 * and apicid_to_node[] tables have valid entries for a CPU.
692 * This means we skip cpu_to_node[] initialisation for NUMA
693 * emulation and faking node case (when running a kernel compiled
694 * for NUMA on a non NUMA box), which is OK as cpu_to_node[]
695 * is already initialized in a round robin manner at numa_init_array,
696 * prior to this call, and this initialization is good enough
697 * for the fake NUMA cases.
699 * Called before the per_cpu areas are setup.
701 void __init
init_cpu_to_node(void)
704 u16
*cpu_to_apicid
= early_per_cpu_ptr(x86_cpu_to_apicid
);
706 BUG_ON(cpu_to_apicid
== NULL
);
708 for_each_possible_cpu(cpu
) {
709 int node
= numa_cpu_node(cpu
);
711 if (node
== NUMA_NO_NODE
)
713 if (!node_online(node
))
714 node
= find_near_online_node(node
);
715 numa_set_node(cpu
, node
);
720 int __cpuinit
numa_cpu_node(int cpu
)
722 int apicid
= early_per_cpu(x86_cpu_to_apicid
, cpu
);
724 if (apicid
!= BAD_APICID
)
725 return __apicid_to_node
[apicid
];
729 #ifndef CONFIG_DEBUG_PER_CPU_MAPS
731 #ifndef CONFIG_NUMA_EMU
732 void __cpuinit
numa_add_cpu(int cpu
)
734 cpumask_set_cpu(cpu
, node_to_cpumask_map
[early_cpu_to_node(cpu
)]);
737 void __cpuinit
numa_remove_cpu(int cpu
)
739 cpumask_clear_cpu(cpu
, node_to_cpumask_map
[early_cpu_to_node(cpu
)]);
742 void __cpuinit
numa_add_cpu(int cpu
)
747 nid
= numa_cpu_node(cpu
);
748 if (nid
== NUMA_NO_NODE
)
749 nid
= early_cpu_to_node(cpu
);
750 BUG_ON(nid
== NUMA_NO_NODE
|| !node_online(nid
));
753 * Use the starting address of the emulated node to find which physical
754 * node it is allocated on.
756 addr
= node_start_pfn(nid
) << PAGE_SHIFT
;
757 for (physnid
= 0; physnid
< MAX_NUMNODES
; physnid
++)
758 if (addr
>= physnodes
[physnid
].start
&&
759 addr
< physnodes
[physnid
].end
)
763 * Map the cpu to each emulated node that is allocated on the physical
764 * node of the cpu's apic id.
766 for_each_online_node(nid
) {
767 addr
= node_start_pfn(nid
) << PAGE_SHIFT
;
768 if (addr
>= physnodes
[physnid
].start
&&
769 addr
< physnodes
[physnid
].end
)
770 cpumask_set_cpu(cpu
, node_to_cpumask_map
[nid
]);
774 void __cpuinit
numa_remove_cpu(int cpu
)
778 for_each_online_node(i
)
779 cpumask_clear_cpu(cpu
, node_to_cpumask_map
[i
]);
781 #endif /* !CONFIG_NUMA_EMU */
783 #else /* CONFIG_DEBUG_PER_CPU_MAPS */
784 static struct cpumask __cpuinit
*debug_cpumask_set_cpu(int cpu
, int enable
)
786 int node
= early_cpu_to_node(cpu
);
787 struct cpumask
*mask
;
790 mask
= node_to_cpumask_map
[node
];
792 pr_err("node_to_cpumask_map[%i] NULL\n", node
);
797 cpulist_scnprintf(buf
, sizeof(buf
), mask
);
798 printk(KERN_DEBUG
"%s cpu %d node %d: mask now %s\n",
799 enable
? "numa_add_cpu" : "numa_remove_cpu",
805 * --------- debug versions of the numa functions ---------
807 #ifndef CONFIG_NUMA_EMU
808 static void __cpuinit
numa_set_cpumask(int cpu
, int enable
)
810 struct cpumask
*mask
;
812 mask
= debug_cpumask_set_cpu(cpu
, enable
);
817 cpumask_set_cpu(cpu
, mask
);
819 cpumask_clear_cpu(cpu
, mask
);
822 static void __cpuinit
numa_set_cpumask(int cpu
, int enable
)
824 int node
= early_cpu_to_node(cpu
);
825 struct cpumask
*mask
;
828 for_each_online_node(i
) {
831 addr
= node_start_pfn(i
) << PAGE_SHIFT
;
832 if (addr
< physnodes
[node
].start
||
833 addr
>= physnodes
[node
].end
)
835 mask
= debug_cpumask_set_cpu(cpu
, enable
);
840 cpumask_set_cpu(cpu
, mask
);
842 cpumask_clear_cpu(cpu
, mask
);
845 #endif /* CONFIG_NUMA_EMU */
847 void __cpuinit
numa_add_cpu(int cpu
)
849 numa_set_cpumask(cpu
, 1);
852 void __cpuinit
numa_remove_cpu(int cpu
)
854 numa_set_cpumask(cpu
, 0);
857 * --------- end of debug versions of the numa functions ---------
860 #endif /* CONFIG_DEBUG_PER_CPU_MAPS */