Skip to content

KVM: arm64: Use MMU read lock for clearing dirty logs

Vipin Sharma kvm kvm-riscv kvmarm linux-arm-kernel linux-kselftest linux-mips linux-riscv lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9KVM: selftests: Allow dirty_log_perf_test to clear dirty memory in chunkstools/testing/selftests/kvm/dirty_log_perf_test.c tools/testing/selftests/kvm/include/memstress.h tools/testing/selftests/kvm/lib/memstress.c+44 -110 replies
2/9KVM: selftests: Add optional delay between consecutive Clear-Dirty-Log callstools/testing/selftests/kvm/dirty_log_perf_test.c tools/testing/selftests/kvm/include/memstress.h tools/testing/selftests/kvm/lib/memstress.c+27 -50 replies
3/9KVM: selftests: Pass count of read and write accesses from guest to hosttools/testing/selftests/kvm/lib/memstress.c+10 -30 replies
4/9KVM: selftests: Print read and write accesses of pages by vCPUs in dirty_log_perf_testtools/testing/selftests/kvm/dirty_log_perf_test.c+17 -10 replies
5/9KVM: selftests: Allow independent execution of vCPUs in dirty_log_perf_testtools/testing/selftests/kvm/dirty_log_perf_test.c+40 -200 replies
6/9KVM: arm64: Correct the kvm_pgtable_stage2_flush() documentationarch/arm64/include/asm/kvm_pgtable.h+2 -30 replies
7/9KVM: mmu: Move mmu lock/unlock to arch code for clear dirty logarch/arm64/kvm/mmu.c arch/mips/kvm/mmu.c arch/riscv/kvm/mmu.c +3 more+9 -61 reply
8/9KMV: arm64: Allow stage2_apply_range_sched() to pass page table walker flagsarch/arm64/include/asm/kvm_pgtable.h arch/arm64/kvm/hyp/nvhe/mem_protect.c arch/arm64/kvm/hyp/pgtable.c +1 more+37 -210 replies
9/9KVM: arm64: Run clear-dirty-log under MMU read lockarch/arm64/kvm/mmu.c+9 -52 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/9] KVM: arm64: Use MMU read lock for clearing dirty logs

This patch series improves guest vCPUs performances on Arm during clearing dirty log operations by taking MMU read lock instead of MMU write lock.

vCPUs write protection faults are fixed in Arm using MMU read locks. However, when userspace is clearing dirty logs via KVM_CLEAR_DIRTY_LOG ioctl, then kernel code takes MMU write lock. This will block vCPUs write protection faults and degrade guest performance. This degradation gets worse as guest VM size increases in terms of memory and vCPU count.

In this series, MMU read lock adoption is made possible by using KVM_PGTABLE_WALK_SHARED flag in page walker.

Patches 1 to 5:
These patches are modifying dirty_log_perf_test. Intent is to mimic production scenarios where guest keeps on executing while userspace threads collect and clear dirty logs independently.

Three new command line options are added:
1. j: Allows to run guest vCPUs and main thread collecting dirty logs independently of each other after initialization is complete.
2. k: Allows to clear dirty logs in smaller chunks compared to existing whole memslot clear in one call.
3. l: Allows to add customizable wait time between consecutive clear dirty log calls to mimic sending dirty memory to destination.

Patch 7-8:
These patches refactor code to move MMU lock operations to arch specific code, refactor Arm's page table walker APIs, and change MMU write lock for clearing dirty logs to read lock. Patch 8 has results showing improvements based on dirty_log_perf_test.

Vipin Sharma (9):
KVM: selftests: Allow dirty_log_perf_test to clear dirty memory in
chunks
KVM: selftests: Add optional delay between consecutive Clear-Dirty-Log
calls
KVM: selftests: Pass count of read and write accesses from guest to
host
KVM: selftests: Print read and write accesses of pages by vCPUs in
dirty_log_perf_test
KVM: selftests: Allow independent execution of vCPUs in
dirty_log_perf_test
KVM: arm64: Correct the kvm_pgtable_stage2_flush() documentation
KVM: mmu: Move mmu lock/unlock to arch code for clear dirty log
KMV: arm64: Allow stage2_apply_range_sched() to pass page table walker
flags
KVM: arm64: Run clear-dirty-log under MMU read lock

 arch/arm64/include/asm/kvm_pgtable.h          |  17 ++-
 arch/arm64/kvm/hyp/nvhe/mem_protect.c         |   4 +-
 arch/arm64/kvm/hyp/pgtable.c                  |  16 ++-
 arch/arm64/kvm/mmu.c                          |  36 ++++--
 arch/mips/kvm/mmu.c                           |   2 +
 arch/riscv/kvm/mmu.c                          |   2 +
 arch/x86/kvm/mmu/mmu.c                        |   3 +
 .../selftests/kvm/dirty_log_perf_test.c       | 108 ++++++++++++++----
 .../testing/selftests/kvm/include/memstress.h |  13 ++-
 tools/testing/selftests/kvm/lib/memstress.c   |  43 +++++--
 virt/kvm/dirty_ring.c                         |   2 -
 virt/kvm/kvm_main.c                           |   4 -
 12 files changed, 185 insertions(+), 65 deletions(-)

base-commit: 95b9779c1758f03cf494e8550d6249a40089ed1c

Signature · 1 line
2.40.0.634.g4ca3ef3211-goog