riscv: Make __flush_tlb_range() loop over pte instead of flushing the whole tlb
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Mon, 30 Oct 2023 13:30:27 +0000 (14:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2024 18:10:52 +0000 (19:10 +0100)
commit53a38f8f75ec2cdf441493925f87b0181a73ecc3
tree44b863f7c5fd96524f1bd8168909535e691d975e
parent72afe05d626551c41a243c34386361a0f8b353a8
riscv: Make __flush_tlb_range() loop over pte instead of flushing the whole tlb

[ Upstream commit 9d4e8d5fa7dbbb606b355f40d918a1feef821bc5 ]

Currently, when the range to flush covers more than one page (a 4K page or
a hugepage), __flush_tlb_range() flushes the whole tlb. Flushing the whole
tlb comes with a greater cost than flushing a single entry so we should
flush single entries up to a certain threshold so that:
threshold * cost of flushing a single entry < cost of flushing the whole
tlb.

Co-developed-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # On RZ/Five SMARC
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
Tested-by: Samuel Holland <samuel.holland@sifive.com>
Link: https://lore.kernel.org/r/20231030133027.19542-4-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Stable-dep-of: d9807d60c145 ("riscv: mm: execute local TLB flush after populating vmemmap")
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/include/asm/sbi.h
arch/riscv/include/asm/tlbflush.h
arch/riscv/kernel/sbi.c
arch/riscv/mm/tlbflush.c