diff mbox series

[v4,3/3] RISC-V: Issue a tlb page flush if possible

Message ID 20190822075151.24838-4-atish.patra@wdc.com (mailing list archive)
State New, archived
Headers show
Series Optimize tlbflush path | expand

Commit Message

Atish Patra Aug. 22, 2019, 7:51 a.m. UTC
If tlbflush request is for page only, there is no need to do a
complete local tlb shootdown.

Just do a local tlb flush for the given address.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
 arch/riscv/mm/tlbflush.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Aug. 22, 2019, 8:11 a.m. UTC | #1
On Thu, Aug 22, 2019 at 12:51:51AM -0700, Atish Patra wrote:
> If tlbflush request is for page only, there is no need to do a
> complete local tlb shootdown.
> 
> Just do a local tlb flush for the given address.

Looks good, although I suspect in many cases even doing multiple
single-page sfence.vma calls might be cheaper than the global one.

But I think that is worth a Ń•eparate discussion, preferably with actual
numbers.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Atish Patra Aug. 22, 2019, 6:31 p.m. UTC | #2
On Thu, 2019-08-22 at 10:11 +0200, Christoph Hellwig wrote:
> On Thu, Aug 22, 2019 at 12:51:51AM -0700, Atish Patra wrote:
> > If tlbflush request is for page only, there is no need to do a
> > complete local tlb shootdown.
> > 
> > Just do a local tlb flush for the given address.
> 
> Looks good, although I suspect in many cases even doing multiple
> single-page sfence.vma calls might be cheaper than the global one.
> 
> But I think that is worth a Ń•eparate discussion, preferably with
> actual
> numbers.
> 

Yup. Finding a good threashold is always tricky without real
benchmarks.

> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks for the review.
diff mbox series

Patch

diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c
index 8172fbf46123..b1c04751bcf1 100644
--- a/arch/riscv/mm/tlbflush.c
+++ b/arch/riscv/mm/tlbflush.c
@@ -27,7 +27,10 @@  static void __sbi_tlb_flush_range(struct cpumask *cmask, unsigned long start,
 
 	if (cpumask_any_but(cmask, cpuid) >= nr_cpu_ids) {
 		/* local cpu is the only cpu present in cpumask */
-		local_flush_tlb_all();
+		if (size <= PAGE_SIZE)
+			local_flush_tlb_page(start);
+		else
+			local_flush_tlb_all();
 	} else {
 		riscv_cpuid_to_hartid_mask(cmask, &hmask);
 		sbi_remote_sfence_vma(cpumask_bits(&hmask), start, size);