Skip to content

RFC riscv: mm: Defer tlb flush to context_switch

Xu Lu linux-riscv lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4riscv: mm: Introduce percpu loaded_asidarch/riscv/include/asm/mmu_context.h arch/riscv/mm/context.c+5 -00 replies
2/4riscv: mm: Introduce percpu tlb flush queuearch/riscv/mm/tlbflush.c+12 -00 replies
3/4riscv: mm: Enqueue tlbflush info if task is not running on target cpuarch/riscv/mm/tlbflush.c+29 -10 replies
4/4riscv: mm: Perform tlb flush during context_switcharch/riscv/include/asm/tlbflush.h arch/riscv/mm/context.c arch/riscv/mm/tlbflush.c+44 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH v1 0/4] riscv: mm: Defer tlb flush to context_switch

When need to flush tlb of a remote cpu, there is no need to send an IPI if the target cpu is not using the asid we want to flush. Instead, we can cache the tlb flush info in percpu buffer, and defer the tlb flush to the next context_switch.

This reduces the number of IPI due to tlb flush:

* ltp - mmapstress01
Before: ~108k
After: ~46k

Future plan in the next version:

- This patch series reduces IPI by deferring tlb flush to context_switch. It does not clear the mm_cpumask of target mm_struct. In the next version, I will apply a threshold to the number of ASIDs maintained by each cpu's tlb. Once the threshold is exceeded, ASID that has not been used for the longest time will be flushed out. And current cpu will be cleared in the mm_cpumask.

Thanks in advance for your comments.

Xu Lu (4):
riscv: mm: Introduce percpu loaded_asid
riscv: mm: Introduce percpu tlb flush queue
riscv: mm: Enqueue tlbflush info if task is not running on target cpu
riscv: mm: Perform tlb flush during context_switch

 arch/riscv/include/asm/mmu_context.h |  1 +
 arch/riscv/include/asm/tlbflush.h    |  4 ++
 arch/riscv/mm/context.c              | 10 ++++
 arch/riscv/mm/tlbflush.c             | 76 +++++++++++++++++++++++++++-
 4 files changed, 90 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1