diff options
author | Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> | 2010-10-06 04:36:59 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-11-28 23:48:19 -0500 |
commit | 99d86705253dcf728dbbec4d694a6764b6edb70c (patch) | |
tree | e4c68adab6448463a77141c1797671417f58242c /arch/powerpc/kernel/smp.c | |
parent | 787d44caa5bca249d8781d21b626c417f1e3cfc4 (diff) |
powerpc: Cleanup APIs for cpu/thread/core mappings
These APIs take logical cpu number as input
Change cpu_first_thread_in_core() to cpu_first_thread_sibling()
Change cpu_last_thread_in_core() to cpu_last_thread_sibling()
These APIs convert core number (index) to logical cpu/thread numbers
Add cpu_first_thread_of_core(int core)
Changed cpu_thread_to_core() to cpu_core_index_of_thread(int cpu)
The goal is to make 'threads_per_core' accessible to the
pseries_energy module. Instead of making an API to read
threads_per_core, this is a higher level wrapper function to
convert from logical cpu number to core number.
The current APIs cpu_first_thread_in_core() and
cpu_last_thread_in_core() returns logical CPU number while
cpu_thread_to_core() returns core number or index which is
not a logical CPU number. The new APIs are now clearly named to
distinguish 'core number' versus first and last 'logical cpu
number' in that core.
The new APIs cpu_{first,last}_thread_sibling() work on
logical cpu numbers. While cpu_first_thread_of_core() and
cpu_core_index_of_thread() work on core index.
Example usage: (4 threads per core system)
cpu_first_thread_sibling(5) = 4
cpu_last_thread_sibling(5) = 7
cpu_core_index_of_thread(5) = 1
cpu_first_thread_of_core(1) = 4
cpu_core_index_of_thread() is used in cpu_to_drc_index() in the
module and cpu_first_thread_of_core() is used in
drc_index_to_cpu() in the module.
Make API changes to few callers. Export symbols for use in modules.
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/smp.c')
-rw-r--r-- | arch/powerpc/kernel/smp.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 68034bbf2e4f..981360509172 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -466,7 +466,20 @@ out: | |||
466 | return id; | 466 | return id; |
467 | } | 467 | } |
468 | 468 | ||
469 | /* Must be called when no change can occur to cpu_present_mask, | 469 | /* Helper routines for cpu to core mapping */ |
470 | int cpu_core_index_of_thread(int cpu) | ||
471 | { | ||
472 | return cpu >> threads_shift; | ||
473 | } | ||
474 | EXPORT_SYMBOL_GPL(cpu_core_index_of_thread); | ||
475 | |||
476 | int cpu_first_thread_of_core(int core) | ||
477 | { | ||
478 | return core << threads_shift; | ||
479 | } | ||
480 | EXPORT_SYMBOL_GPL(cpu_first_thread_of_core); | ||
481 | |||
482 | /* Must be called when no change can occur to cpu_present_map, | ||
470 | * i.e. during cpu online or offline. | 483 | * i.e. during cpu online or offline. |
471 | */ | 484 | */ |
472 | static struct device_node *cpu_to_l2cache(int cpu) | 485 | static struct device_node *cpu_to_l2cache(int cpu) |
@@ -514,7 +527,7 @@ int __devinit start_secondary(void *unused) | |||
514 | notify_cpu_starting(cpu); | 527 | notify_cpu_starting(cpu); |
515 | set_cpu_online(cpu, true); | 528 | set_cpu_online(cpu, true); |
516 | /* Update sibling maps */ | 529 | /* Update sibling maps */ |
517 | base = cpu_first_thread_in_core(cpu); | 530 | base = cpu_first_thread_sibling(cpu); |
518 | for (i = 0; i < threads_per_core; i++) { | 531 | for (i = 0; i < threads_per_core; i++) { |
519 | if (cpu_is_offline(base + i)) | 532 | if (cpu_is_offline(base + i)) |
520 | continue; | 533 | continue; |
@@ -600,7 +613,7 @@ int __cpu_disable(void) | |||
600 | return err; | 613 | return err; |
601 | 614 | ||
602 | /* Update sibling maps */ | 615 | /* Update sibling maps */ |
603 | base = cpu_first_thread_in_core(cpu); | 616 | base = cpu_first_thread_sibling(cpu); |
604 | for (i = 0; i < threads_per_core; i++) { | 617 | for (i = 0; i < threads_per_core; i++) { |
605 | cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i)); | 618 | cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i)); |
606 | cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu)); | 619 | cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu)); |