[RFC PATCH v2 3/4] riscv: Use variable this_cpu instead of smp_processor_id()

From: Greentime Hu
Date: Fri Jan 10 2020 - 05:46:47 EST


To clean up codes in smpboot.c by using a variable this_cpu to prevent too
many calls for smp_processor_id()

Signed-off-by: Greentime Hu <greentime.hu@xxxxxxxxxx>
---
arch/riscv/kernel/smpboot.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 8bc01f0ca73b..ceef7c579aeb 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -46,6 +46,9 @@ void __init smp_prepare_boot_cpu(void)
void __init smp_prepare_cpus(unsigned int max_cpus)
{
int cpuid;
+ unsigned int this_cpu;
+
+ this_cpu = smp_processor_id();

/* This covers non-smp usecase mandated by "nosmp" option */
if (max_cpus == 0)
@@ -137,6 +140,9 @@ void __init smp_cpus_done(unsigned int max_cpus)
asmlinkage __visible void __init smp_callin(void)
{
struct mm_struct *mm = &init_mm;
+ unsigned int this_cpu;
+
+ this_cpu = smp_processor_id();

if (!IS_ENABLED(CONFIG_RISCV_SBI))
clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id()));
@@ -146,9 +152,9 @@ asmlinkage __visible void __init smp_callin(void)
current->active_mm = mm;

trap_init();
- notify_cpu_starting(smp_processor_id());
- update_siblings_masks(smp_processor_id());
- set_cpu_online(smp_processor_id(), 1);
+ notify_cpu_starting(this_cpu);
+ update_siblings_masks(this_cpu);
+ set_cpu_online(this_cpu, true);
/*
* Remote TLB flushes are ignored while the CPU is offline, so emit
* a local TLB flush right now just in case.
--
2.17.1