diff options
Diffstat (limited to 'arch/x86/mm')
| -rw-r--r-- | arch/x86/mm/Makefile | 2 | ||||
| -rw-r--r-- | arch/x86/mm/mmio-mod.c | 19 | ||||
| -rw-r--r-- | arch/x86/mm/numa.c | 67 | ||||
| -rw-r--r-- | arch/x86/mm/numa_64.c | 111 |
4 files changed, 89 insertions, 110 deletions
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 08537747cb58..fdd30d08ab52 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile | |||
| @@ -14,7 +14,7 @@ obj-$(CONFIG_MMIOTRACE) += mmiotrace.o | |||
| 14 | mmiotrace-y := kmmio.o pf_in.o mmio-mod.o | 14 | mmiotrace-y := kmmio.o pf_in.o mmio-mod.o |
| 15 | obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o | 15 | obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o |
| 16 | 16 | ||
| 17 | obj-$(CONFIG_NUMA) += numa_$(BITS).o | 17 | obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o |
| 18 | obj-$(CONFIG_K8_NUMA) += k8topology_64.o | 18 | obj-$(CONFIG_K8_NUMA) += k8topology_64.o |
| 19 | obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o | 19 | obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o |
| 20 | 20 | ||
diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c index 2c4baa88f2cb..c9342ed8b402 100644 --- a/arch/x86/mm/mmio-mod.c +++ b/arch/x86/mm/mmio-mod.c | |||
| @@ -378,27 +378,34 @@ static void clear_trace_list(void) | |||
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | #ifdef CONFIG_HOTPLUG_CPU | 380 | #ifdef CONFIG_HOTPLUG_CPU |
| 381 | static cpumask_t downed_cpus; | 381 | static cpumask_var_t downed_cpus; |
| 382 | 382 | ||
| 383 | static void enter_uniprocessor(void) | 383 | static void enter_uniprocessor(void) |
| 384 | { | 384 | { |
| 385 | int cpu; | 385 | int cpu; |
| 386 | int err; | 386 | int err; |
| 387 | 387 | ||
| 388 | if (downed_cpus == NULL && | ||
| 389 | !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) { | ||
| 390 | pr_notice(NAME "Failed to allocate mask\n"); | ||
| 391 | goto out; | ||
| 392 | } | ||
| 393 | |||
| 388 | get_online_cpus(); | 394 | get_online_cpus(); |
| 389 | downed_cpus = cpu_online_map; | 395 | cpumask_copy(downed_cpus, cpu_online_mask); |
| 390 | cpu_clear(first_cpu(cpu_online_map), downed_cpus); | 396 | cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus); |
| 391 | if (num_online_cpus() > 1) | 397 | if (num_online_cpus() > 1) |
| 392 | pr_notice(NAME "Disabling non-boot CPUs...\n"); | 398 | pr_notice(NAME "Disabling non-boot CPUs...\n"); |
| 393 | put_online_cpus(); | 399 | put_online_cpus(); |
| 394 | 400 | ||
| 395 | for_each_cpu_mask(cpu, downed_cpus) { | 401 | for_each_cpu(cpu, downed_cpus) { |
| 396 | err = cpu_down(cpu); | 402 | err = cpu_down(cpu); |
| 397 | if (!err) | 403 | if (!err) |
| 398 | pr_info(NAME "CPU%d is down.\n", cpu); | 404 | pr_info(NAME "CPU%d is down.\n", cpu); |
| 399 | else | 405 | else |
| 400 | pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err); | 406 | pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err); |
| 401 | } | 407 | } |
| 408 | out: | ||
| 402 | if (num_online_cpus() > 1) | 409 | if (num_online_cpus() > 1) |
| 403 | pr_warning(NAME "multiple CPUs still online, " | 410 | pr_warning(NAME "multiple CPUs still online, " |
| 404 | "may miss events.\n"); | 411 | "may miss events.\n"); |
| @@ -411,10 +418,10 @@ static void __ref leave_uniprocessor(void) | |||
| 411 | int cpu; | 418 | int cpu; |
| 412 | int err; | 419 | int err; |
| 413 | 420 | ||
| 414 | if (cpus_weight(downed_cpus) == 0) | 421 | if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0) |
| 415 | return; | 422 | return; |
| 416 | pr_notice(NAME "Re-enabling CPUs...\n"); | 423 | pr_notice(NAME "Re-enabling CPUs...\n"); |
| 417 | for_each_cpu_mask(cpu, downed_cpus) { | 424 | for_each_cpu(cpu, downed_cpus) { |
| 418 | err = cpu_up(cpu); | 425 | err = cpu_up(cpu); |
| 419 | if (!err) | 426 | if (!err) |
| 420 | pr_info(NAME "enabled CPU%d.\n", cpu); | 427 | pr_info(NAME "enabled CPU%d.\n", cpu); |
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c new file mode 100644 index 000000000000..550df481accd --- /dev/null +++ b/arch/x86/mm/numa.c | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /* Common code for 32 and 64-bit NUMA */ | ||
| 2 | #include <linux/topology.h> | ||
| 3 | #include <linux/module.h> | ||
| 4 | #include <linux/bootmem.h> | ||
| 5 | |||
| 6 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
| 7 | # define DBG(x...) printk(KERN_DEBUG x) | ||
| 8 | #else | ||
| 9 | # define DBG(x...) | ||
| 10 | #endif | ||
| 11 | |||
| 12 | /* | ||
| 13 | * Which logical CPUs are on which nodes | ||
| 14 | */ | ||
| 15 | cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; | ||
| 16 | EXPORT_SYMBOL(node_to_cpumask_map); | ||
| 17 | |||
| 18 | /* | ||
| 19 | * Allocate node_to_cpumask_map based on number of available nodes | ||
| 20 | * Requires node_possible_map to be valid. | ||
| 21 | * | ||
| 22 | * Note: node_to_cpumask() is not valid until after this is done. | ||
| 23 | * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) | ||
| 24 | */ | ||
| 25 | void __init setup_node_to_cpumask_map(void) | ||
| 26 | { | ||
| 27 | unsigned int node, num = 0; | ||
| 28 | |||
| 29 | /* setup nr_node_ids if not done yet */ | ||
| 30 | if (nr_node_ids == MAX_NUMNODES) { | ||
| 31 | for_each_node_mask(node, node_possible_map) | ||
| 32 | num = node; | ||
| 33 | nr_node_ids = num + 1; | ||
| 34 | } | ||
| 35 | |||
| 36 | /* allocate the map */ | ||
| 37 | for (node = 0; node < nr_node_ids; node++) | ||
| 38 | alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); | ||
| 39 | |||
| 40 | /* cpumask_of_node() will now work */ | ||
| 41 | pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); | ||
| 42 | } | ||
| 43 | |||
| 44 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
| 45 | /* | ||
| 46 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | ||
| 47 | */ | ||
| 48 | const struct cpumask *cpumask_of_node(int node) | ||
| 49 | { | ||
| 50 | if (node >= nr_node_ids) { | ||
| 51 | printk(KERN_WARNING | ||
| 52 | "cpumask_of_node(%d): node > nr_node_ids(%d)\n", | ||
| 53 | node, nr_node_ids); | ||
| 54 | dump_stack(); | ||
| 55 | return cpu_none_mask; | ||
| 56 | } | ||
| 57 | if (node_to_cpumask_map[node] == NULL) { | ||
| 58 | printk(KERN_WARNING | ||
| 59 | "cpumask_of_node(%d): no node_to_cpumask_map!\n", | ||
| 60 | node); | ||
| 61 | dump_stack(); | ||
| 62 | return cpu_online_mask; | ||
| 63 | } | ||
| 64 | return node_to_cpumask_map[node]; | ||
| 65 | } | ||
| 66 | EXPORT_SYMBOL(cpumask_of_node); | ||
| 67 | #endif | ||
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index 64c9cf043cdd..d73aaa892371 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c | |||
| @@ -20,12 +20,6 @@ | |||
| 20 | #include <asm/acpi.h> | 20 | #include <asm/acpi.h> |
| 21 | #include <asm/k8.h> | 21 | #include <asm/k8.h> |
| 22 | 22 | ||
| 23 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
| 24 | # define DBG(x...) printk(KERN_DEBUG x) | ||
| 25 | #else | ||
| 26 | # define DBG(x...) | ||
| 27 | #endif | ||
| 28 | |||
| 29 | struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; | 23 | struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; |
| 30 | EXPORT_SYMBOL(node_data); | 24 | EXPORT_SYMBOL(node_data); |
| 31 | 25 | ||
| @@ -49,12 +43,6 @@ DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE); | |||
| 49 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map); | 43 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map); |
| 50 | 44 | ||
| 51 | /* | 45 | /* |
| 52 | * Which logical CPUs are on which nodes | ||
| 53 | */ | ||
| 54 | cpumask_t *node_to_cpumask_map; | ||
| 55 | EXPORT_SYMBOL(node_to_cpumask_map); | ||
| 56 | |||
| 57 | /* | ||
| 58 | * Given a shift value, try to populate memnodemap[] | 46 | * Given a shift value, try to populate memnodemap[] |
| 59 | * Returns : | 47 | * Returns : |
| 60 | * 1 if OK | 48 | * 1 if OK |
| @@ -661,36 +649,6 @@ void __init init_cpu_to_node(void) | |||
| 661 | #endif | 649 | #endif |
| 662 | 650 | ||
| 663 | 651 | ||
| 664 | /* | ||
| 665 | * Allocate node_to_cpumask_map based on number of available nodes | ||
| 666 | * Requires node_possible_map to be valid. | ||
| 667 | * | ||
| 668 | * Note: node_to_cpumask() is not valid until after this is done. | ||
| 669 | * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) | ||
| 670 | */ | ||
| 671 | void __init setup_node_to_cpumask_map(void) | ||
| 672 | { | ||
| 673 | unsigned int node, num = 0; | ||
| 674 | cpumask_t *map; | ||
| 675 | |||
| 676 | /* setup nr_node_ids if not done yet */ | ||
| 677 | if (nr_node_ids == MAX_NUMNODES) { | ||
| 678 | for_each_node_mask(node, node_possible_map) | ||
| 679 | num = node; | ||
| 680 | nr_node_ids = num + 1; | ||
| 681 | } | ||
| 682 | |||
| 683 | /* allocate the map */ | ||
| 684 | map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t)); | ||
| 685 | DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids); | ||
| 686 | |||
| 687 | pr_debug("Node to cpumask map at %p for %d nodes\n", | ||
| 688 | map, nr_node_ids); | ||
| 689 | |||
| 690 | /* node_to_cpumask() will now work */ | ||
| 691 | node_to_cpumask_map = map; | ||
| 692 | } | ||
| 693 | |||
| 694 | void __cpuinit numa_set_node(int cpu, int node) | 652 | void __cpuinit numa_set_node(int cpu, int node) |
| 695 | { | 653 | { |
| 696 | int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map); | 654 | int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map); |
| @@ -723,12 +681,12 @@ void __cpuinit numa_clear_node(int cpu) | |||
| 723 | 681 | ||
| 724 | void __cpuinit numa_add_cpu(int cpu) | 682 | void __cpuinit numa_add_cpu(int cpu) |
| 725 | { | 683 | { |
| 726 | cpu_set(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); | 684 | cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); |
| 727 | } | 685 | } |
| 728 | 686 | ||
| 729 | void __cpuinit numa_remove_cpu(int cpu) | 687 | void __cpuinit numa_remove_cpu(int cpu) |
| 730 | { | 688 | { |
| 731 | cpu_clear(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); | 689 | cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); |
| 732 | } | 690 | } |
| 733 | 691 | ||
| 734 | #else /* CONFIG_DEBUG_PER_CPU_MAPS */ | 692 | #else /* CONFIG_DEBUG_PER_CPU_MAPS */ |
| @@ -739,20 +697,20 @@ void __cpuinit numa_remove_cpu(int cpu) | |||
| 739 | static void __cpuinit numa_set_cpumask(int cpu, int enable) | 697 | static void __cpuinit numa_set_cpumask(int cpu, int enable) |
| 740 | { | 698 | { |
| 741 | int node = early_cpu_to_node(cpu); | 699 | int node = early_cpu_to_node(cpu); |
| 742 | cpumask_t *mask; | 700 | struct cpumask *mask; |
| 743 | char buf[64]; | 701 | char buf[64]; |
| 744 | 702 | ||
| 745 | if (node_to_cpumask_map == NULL) { | 703 | mask = node_to_cpumask_map[node]; |
| 746 | printk(KERN_ERR "node_to_cpumask_map NULL\n"); | 704 | if (mask == NULL) { |
| 705 | printk(KERN_ERR "node_to_cpumask_map[%i] NULL\n", node); | ||
| 747 | dump_stack(); | 706 | dump_stack(); |
| 748 | return; | 707 | return; |
| 749 | } | 708 | } |
| 750 | 709 | ||
| 751 | mask = &node_to_cpumask_map[node]; | ||
| 752 | if (enable) | 710 | if (enable) |
| 753 | cpu_set(cpu, *mask); | 711 | cpumask_set_cpu(cpu, mask); |
| 754 | else | 712 | else |
| 755 | cpu_clear(cpu, *mask); | 713 | cpumask_clear_cpu(cpu, mask); |
| 756 | 714 | ||
| 757 | cpulist_scnprintf(buf, sizeof(buf), mask); | 715 | cpulist_scnprintf(buf, sizeof(buf), mask); |
| 758 | printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", | 716 | printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", |
| @@ -799,59 +757,6 @@ int early_cpu_to_node(int cpu) | |||
| 799 | return per_cpu(x86_cpu_to_node_map, cpu); | 757 | return per_cpu(x86_cpu_to_node_map, cpu); |
| 800 | } | 758 | } |
| 801 | 759 | ||
| 802 | |||
| 803 | /* empty cpumask */ | ||
| 804 | static const cpumask_t cpu_mask_none; | ||
| 805 | |||
| 806 | /* | ||
| 807 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | ||
| 808 | */ | ||
| 809 | const cpumask_t *cpumask_of_node(int node) | ||
| 810 | { | ||
| 811 | if (node_to_cpumask_map == NULL) { | ||
| 812 | printk(KERN_WARNING | ||
| 813 | "cpumask_of_node(%d): no node_to_cpumask_map!\n", | ||
| 814 | node); | ||
| 815 | dump_stack(); | ||
| 816 | return (const cpumask_t *)&cpu_online_map; | ||
| 817 | } | ||
| 818 | if (node >= nr_node_ids) { | ||
| 819 | printk(KERN_WARNING | ||
| 820 | "cpumask_of_node(%d): node > nr_node_ids(%d)\n", | ||
| 821 | node, nr_node_ids); | ||
| 822 | dump_stack(); | ||
| 823 | return &cpu_mask_none; | ||
| 824 | } | ||
| 825 | return &node_to_cpumask_map[node]; | ||
| 826 | } | ||
| 827 | EXPORT_SYMBOL(cpumask_of_node); | ||
| 828 | |||
| 829 | /* | ||
| 830 | * Returns a bitmask of CPUs on Node 'node'. | ||
| 831 | * | ||
| 832 | * Side note: this function creates the returned cpumask on the stack | ||
| 833 | * so with a high NR_CPUS count, excessive stack space is used. The | ||
| 834 | * node_to_cpumask_ptr function should be used whenever possible. | ||
| 835 | */ | ||
| 836 | cpumask_t node_to_cpumask(int node) | ||
| 837 | { | ||
| 838 | if (node_to_cpumask_map == NULL) { | ||
| 839 | printk(KERN_WARNING | ||
| 840 | "node_to_cpumask(%d): no node_to_cpumask_map!\n", node); | ||
| 841 | dump_stack(); | ||
| 842 | return cpu_online_map; | ||
| 843 | } | ||
| 844 | if (node >= nr_node_ids) { | ||
| 845 | printk(KERN_WARNING | ||
| 846 | "node_to_cpumask(%d): node > nr_node_ids(%d)\n", | ||
| 847 | node, nr_node_ids); | ||
| 848 | dump_stack(); | ||
| 849 | return cpu_mask_none; | ||
| 850 | } | ||
| 851 | return node_to_cpumask_map[node]; | ||
| 852 | } | ||
| 853 | EXPORT_SYMBOL(node_to_cpumask); | ||
| 854 | |||
| 855 | /* | 760 | /* |
| 856 | * --------- end of debug versions of the numa functions --------- | 761 | * --------- end of debug versions of the numa functions --------- |
| 857 | */ | 762 | */ |
