[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210512014231.466aff04@xhacker>
Date: Wed, 12 May 2021 01:42:31 +0800
From: Jisheng Zhang <jszhang3@...l.ustc.edu.cn>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] riscv: Optimize switch_mm by passing "cpu" to
flush_icache_deferred()
From: Jisheng Zhang <jszhang@...nel.org>
Directly passing the cpu to flush_icache_deferred() rather than calling
smp_processor_id() again.
Here are some performance numbers:
With a run of hackbench 30 times on a single core riscv64 Qemu instance
with 1GB memory:
without this patch: mean 36.934
with this patch: mean 36.104 (improved by 2.24%)
Signed-off-by: Jisheng Zhang <jszhang@...nel.org>
---
arch/riscv/mm/context.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
index 68aa312fc352..6d445f2888ec 100644
--- a/arch/riscv/mm/context.c
+++ b/arch/riscv/mm/context.c
@@ -281,10 +281,9 @@ static inline void set_mm(struct mm_struct *mm, unsigned int cpu)
* actually performs that local instruction cache flush, which implicitly only
* refers to the current hart.
*/
-static inline void flush_icache_deferred(struct mm_struct *mm)
+static inline void flush_icache_deferred(struct mm_struct *mm, unsigned int cpu)
{
#ifdef CONFIG_SMP
- unsigned int cpu = smp_processor_id();
cpumask_t *mask = &mm->context.icache_stale_mask;
if (cpumask_test_cpu(cpu, mask)) {
@@ -320,5 +319,5 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next,
set_mm(next, cpu);
- flush_icache_deferred(next);
+ flush_icache_deferred(next, cpu);
}
--
2.31.0
Powered by blists - more mailing lists