diff options
author | Mark Rutland <mark.rutland@arm.com> | 2017-08-14 23:09:37 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-08-14 23:09:37 +0000 |
commit | f1f0b344b87262414940021627cd310c3d53f788 (patch) | |
tree | cd32fd3a64427993dba0bf7c5b5ee0c4da57d554 | |
parent | 22a57365f012bdce60c69dbb365426b063d48eda (diff) | |
parent | f150ed74698431c50c615da1ed9ac18adb796270 (diff) | |
download | v4.4-f1f0b344b87262414940021627cd310c3d53f788.tar.gz |
UPSTREAM: arm64: make cpu number a percpu variable am: f7f69dfb02
am: f150ed7469
Change-Id: I5bfd0a5a5eb1e079f38eba286ba24108067bea9a
-rw-r--r-- | arch/arm64/include/asm/smp.h | 11 | ||||
-rw-r--r-- | arch/arm64/kernel/smp.c | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index 2013a4dc5124..d7e851c5bc42 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -16,11 +16,20 @@ #ifndef __ASM_SMP_H #define __ASM_SMP_H +#include <asm/percpu.h> + #include <linux/threads.h> #include <linux/cpumask.h> #include <linux/thread_info.h> -#define raw_smp_processor_id() (current_thread_info()->cpu) +DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number); + +/* + * We don't use this_cpu_read(cpu_number) as that has implicit writes to + * preempt_count, and associated (compiler) barriers, that we'd like to avoid + * the expense of. If we're preemptible, the value can be stale at use anyway. + */ +#define raw_smp_processor_id() (*this_cpu_ptr(&cpu_number)) struct seq_file; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 8526ff64e4b2..0b66134345f7 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -57,6 +57,9 @@ #define CREATE_TRACE_POINTS #include <trace/events/ipi.h> +DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); +EXPORT_PER_CPU_SYMBOL(cpu_number); + /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core @@ -608,6 +611,8 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (max_cpus == 0) break; + per_cpu(cpu_number, cpu) = cpu; + if (cpu == smp_processor_id()) continue; |