diff mbox series

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

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

Commit Message

Atish Patra Aug. 22, 2019, 12:46 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, 1:50 a.m. UTC | #1
On Wed, Aug 21, 2019 at 05:46:43PM -0700, Atish Patra wrote:
> +		if (size <= PAGE_SIZE && size != -1)
> +			local_flush_tlb_page(start);
> +		else
> +			local_flush_tlb_all();

As Andreas pointed out (unsigned long)-1 is actually larger than
PAGE_SIZE, so we don't need the extra check.
Atish Patra Aug. 22, 2019, 4:02 a.m. UTC | #2
On Thu, 2019-08-22 at 03:50 +0200, Christoph Hellwig wrote:
> On Wed, Aug 21, 2019 at 05:46:43PM -0700, Atish Patra wrote:
> > +		if (size <= PAGE_SIZE && size != -1)
> > +			local_flush_tlb_page(start);
> > +		else
> > +			local_flush_tlb_all();
> 
> As Andreas pointed out (unsigned long)-1 is actually larger than
> PAGE_SIZE, so we don't need the extra check.

Ahh yes. Sorry I missed his comment in the earlier email. Fixed it.
diff mbox series

Patch

diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c
index 36430ee3bed9..9f58b3790baa 100644
--- a/arch/riscv/mm/tlbflush.c
+++ b/arch/riscv/mm/tlbflush.c
@@ -22,7 +22,10 @@  static void __sbi_tlb_flush_range(struct cpumask *cmask, unsigned long start,
 	}
 
 	if (cpumask_test_cpu(cpuid, cmask) && cpumask_weight(cmask) == 1) {
-		local_flush_tlb_all();
+		if (size <= PAGE_SIZE && size != -1)
+			local_flush_tlb_page(start);
+		else
+			local_flush_tlb_all();
 		goto done;
 	}
 	riscv_cpuid_to_hartid_mask(cmask, &hmask);