diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-26 06:53:40 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-26 06:53:40 -0500 |
commit | fbb776c3ca4501d5a2821bf1e9bceefcaec7ae47 (patch) | |
tree | ef2b0bba2d31a6408224b4bedcd518b5e5ed6e5c /arch | |
parent | 86c6f274f52c3e991d429869780945c0790e7b65 (diff) |
cpumask: IA64: Introduce cpumask_of_{node,pcibus} to replace {node,pcibus}_to_cpumask
Impact: New APIs
The old node_to_cpumask/node_to_pcibus returned a cpumask_t: these
return a pointer to a struct cpumask. Part of removing cpumasks from
the stack.
We can also use the new for_each_cpu_and() to avoid a temporary cpumask,
and a gratuitous test in sn_topology_show.
(Includes fix from KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tony Luck <tony.luck@intel.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ia64/include/asm/topology.h | 7 | ||||
-rw-r--r-- | arch/ia64/kernel/acpi.c | 2 | ||||
-rw-r--r-- | arch/ia64/kernel/iosapic.c | 23 | ||||
-rw-r--r-- | arch/ia64/sn/kernel/sn2/sn_hwperf.c | 27 |
4 files changed, 30 insertions, 29 deletions
diff --git a/arch/ia64/include/asm/topology.h b/arch/ia64/include/asm/topology.h index 35bcb641c9e5..66f0f1ef9e7f 100644 --- a/arch/ia64/include/asm/topology.h +++ b/arch/ia64/include/asm/topology.h | |||
@@ -34,6 +34,7 @@ | |||
34 | * Returns a bitmask of CPUs on Node 'node'. | 34 | * Returns a bitmask of CPUs on Node 'node'. |
35 | */ | 35 | */ |
36 | #define node_to_cpumask(node) (node_to_cpu_mask[node]) | 36 | #define node_to_cpumask(node) (node_to_cpu_mask[node]) |
37 | #define cpumask_of_node(node) (&node_to_cpu_mask[node]) | ||
37 | 38 | ||
38 | /* | 39 | /* |
39 | * Returns the number of the node containing Node 'nid'. | 40 | * Returns the number of the node containing Node 'nid'. |
@@ -45,7 +46,7 @@ | |||
45 | /* | 46 | /* |
46 | * Returns the number of the first CPU on Node 'node'. | 47 | * Returns the number of the first CPU on Node 'node'. |
47 | */ | 48 | */ |
48 | #define node_to_first_cpu(node) (first_cpu(node_to_cpumask(node))) | 49 | #define node_to_first_cpu(node) (cpumask_first(cpumask_of_node(node))) |
49 | 50 | ||
50 | /* | 51 | /* |
51 | * Determines the node for a given pci bus | 52 | * Determines the node for a given pci bus |
@@ -121,6 +122,10 @@ extern void arch_fix_phys_package_id(int num, u32 slot); | |||
121 | node_to_cpumask(pcibus_to_node(bus)) \ | 122 | node_to_cpumask(pcibus_to_node(bus)) \ |
122 | ) | 123 | ) |
123 | 124 | ||
125 | #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ | ||
126 | cpu_all_mask : \ | ||
127 | cpumask_from_node(pcibus_to_node(bus))) | ||
128 | |||
124 | #include <asm-generic/topology.h> | 129 | #include <asm-generic/topology.h> |
125 | 130 | ||
126 | #endif /* _ASM_IA64_TOPOLOGY_H */ | 131 | #endif /* _ASM_IA64_TOPOLOGY_H */ |
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index bd7acc71e8a9..54ae373e6e22 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c | |||
@@ -1001,7 +1001,7 @@ acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret) | |||
1001 | node = pxm_to_node(pxm); | 1001 | node = pxm_to_node(pxm); |
1002 | 1002 | ||
1003 | if (node >= MAX_NUMNODES || !node_online(node) || | 1003 | if (node >= MAX_NUMNODES || !node_online(node) || |
1004 | cpus_empty(node_to_cpumask(node))) | 1004 | cpumask_empty(cpumask_of_node(node))) |
1005 | return AE_OK; | 1005 | return AE_OK; |
1006 | 1006 | ||
1007 | /* We know a gsi to node mapping! */ | 1007 | /* We know a gsi to node mapping! */ |
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index c8adecd5b416..5cfd3d91001a 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c | |||
@@ -695,32 +695,31 @@ get_target_cpu (unsigned int gsi, int irq) | |||
695 | #ifdef CONFIG_NUMA | 695 | #ifdef CONFIG_NUMA |
696 | { | 696 | { |
697 | int num_cpus, cpu_index, iosapic_index, numa_cpu, i = 0; | 697 | int num_cpus, cpu_index, iosapic_index, numa_cpu, i = 0; |
698 | cpumask_t cpu_mask; | 698 | const struct cpumask *cpu_mask; |
699 | 699 | ||
700 | iosapic_index = find_iosapic(gsi); | 700 | iosapic_index = find_iosapic(gsi); |
701 | if (iosapic_index < 0 || | 701 | if (iosapic_index < 0 || |
702 | iosapic_lists[iosapic_index].node == MAX_NUMNODES) | 702 | iosapic_lists[iosapic_index].node == MAX_NUMNODES) |
703 | goto skip_numa_setup; | 703 | goto skip_numa_setup; |
704 | 704 | ||
705 | cpu_mask = node_to_cpumask(iosapic_lists[iosapic_index].node); | 705 | cpu_mask = cpumask_of_node(iosapic_lists[iosapic_index].node); |
706 | cpus_and(cpu_mask, cpu_mask, domain); | 706 | num_cpus = 0; |
707 | for_each_cpu_mask(numa_cpu, cpu_mask) { | 707 | for_each_cpu_and(numa_cpu, cpu_mask, &domain) { |
708 | if (!cpu_online(numa_cpu)) | 708 | if (cpu_online(numa_cpu)) |
709 | cpu_clear(numa_cpu, cpu_mask); | 709 | num_cpus++; |
710 | } | 710 | } |
711 | 711 | ||
712 | num_cpus = cpus_weight(cpu_mask); | ||
713 | |||
714 | if (!num_cpus) | 712 | if (!num_cpus) |
715 | goto skip_numa_setup; | 713 | goto skip_numa_setup; |
716 | 714 | ||
717 | /* Use irq assignment to distribute across cpus in node */ | 715 | /* Use irq assignment to distribute across cpus in node */ |
718 | cpu_index = irq % num_cpus; | 716 | cpu_index = irq % num_cpus; |
719 | 717 | ||
720 | for (numa_cpu = first_cpu(cpu_mask) ; i < cpu_index ; i++) | 718 | for_each_cpu_and(numa_cpu, cpu_mask, &domain) |
721 | numa_cpu = next_cpu(numa_cpu, cpu_mask); | 719 | if (cpu_online(numa_cpu) && i++ >= cpu_index) |
720 | break; | ||
722 | 721 | ||
723 | if (numa_cpu != NR_CPUS) | 722 | if (numa_cpu < nr_cpu_ids) |
724 | return cpu_physical_id(numa_cpu); | 723 | return cpu_physical_id(numa_cpu); |
725 | } | 724 | } |
726 | skip_numa_setup: | 725 | skip_numa_setup: |
@@ -731,7 +730,7 @@ skip_numa_setup: | |||
731 | * case of NUMA.) | 730 | * case of NUMA.) |
732 | */ | 731 | */ |
733 | do { | 732 | do { |
734 | if (++cpu >= NR_CPUS) | 733 | if (++cpu >= nr_cpu_ids) |
735 | cpu = 0; | 734 | cpu = 0; |
736 | } while (!cpu_online(cpu) || !cpu_isset(cpu, domain)); | 735 | } while (!cpu_online(cpu) || !cpu_isset(cpu, domain)); |
737 | 736 | ||
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c index 636588e7e068..be339477f906 100644 --- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c +++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c | |||
@@ -385,7 +385,6 @@ static int sn_topology_show(struct seq_file *s, void *d) | |||
385 | int j; | 385 | int j; |
386 | const char *slabname; | 386 | const char *slabname; |
387 | int ordinal; | 387 | int ordinal; |
388 | cpumask_t cpumask; | ||
389 | char slice; | 388 | char slice; |
390 | struct cpuinfo_ia64 *c; | 389 | struct cpuinfo_ia64 *c; |
391 | struct sn_hwperf_port_info *ptdata; | 390 | struct sn_hwperf_port_info *ptdata; |
@@ -473,23 +472,21 @@ static int sn_topology_show(struct seq_file *s, void *d) | |||
473 | * CPUs on this node, if any | 472 | * CPUs on this node, if any |
474 | */ | 473 | */ |
475 | if (!SN_HWPERF_IS_IONODE(obj)) { | 474 | if (!SN_HWPERF_IS_IONODE(obj)) { |
476 | cpumask = node_to_cpumask(ordinal); | 475 | for_each_cpu_and(i, cpu_online_mask, |
477 | for_each_online_cpu(i) { | 476 | cpumask_of_node(ordinal)) { |
478 | if (cpu_isset(i, cpumask)) { | 477 | slice = 'a' + cpuid_to_slice(i); |
479 | slice = 'a' + cpuid_to_slice(i); | 478 | c = cpu_data(i); |
480 | c = cpu_data(i); | 479 | seq_printf(s, "cpu %d %s%c local" |
481 | seq_printf(s, "cpu %d %s%c local" | 480 | " freq %luMHz, arch ia64", |
482 | " freq %luMHz, arch ia64", | 481 | i, obj->location, slice, |
483 | i, obj->location, slice, | 482 | c->proc_freq / 1000000); |
484 | c->proc_freq / 1000000); | 483 | for_each_online_cpu(j) { |
485 | for_each_online_cpu(j) { | 484 | seq_printf(s, j ? ":%d" : ", dist %d", |
486 | seq_printf(s, j ? ":%d" : ", dist %d", | 485 | node_distance( |
487 | node_distance( | ||
488 | cpu_to_node(i), | 486 | cpu_to_node(i), |
489 | cpu_to_node(j))); | 487 | cpu_to_node(j))); |
490 | } | ||
491 | seq_putc(s, '\n'); | ||
492 | } | 488 | } |
489 | seq_putc(s, '\n'); | ||
493 | } | 490 | } |
494 | } | 491 | } |
495 | } | 492 | } |