Skip to content

Verify dirty logging works properly with page stats

Mingwei Zhang kvm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 5 repliesIn review
  2. v24 patches 4 repliesSuperseded
  3. v10 of 4 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Update lpage_disallowed before making spte visible [seanjc].
- Adding tdp_mmu_pages stats [seanjc]
- update comments in selftest [bgardon]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6KVM: x86/mmu: Set lpage_disallowed in TDP MMU before setting SPTEarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/mmu_internal.h arch/x86/kvm/mmu/tdp_mmu.c+23 -133 replies
2/6KVM: x86/mmu: Track the number of TDP MMU pages, but not the actual pagesarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu/tdp_mmu.c+11 -161 reply
3/6KVM: x86/mmu: explicitly check nx_hugepage in disallowed_hugepage_adjust()arch/x86/kvm/mmu/mmu.c+12 -21 reply
4/6KVM: selftests: Dump VM stats in binary stats testtools/testing/selftests/kvm/include/kvm_util_base.h tools/testing/selftests/kvm/kvm_binary_stats_test.c tools/testing/selftests/kvm/lib/kvm_util.c+147 -00 replies
5/6KVM: selftests: Test reading a single stattools/testing/selftests/kvm/include/kvm_util_base.h tools/testing/selftests/kvm/kvm_binary_stats_test.c tools/testing/selftests/kvm/lib/kvm_util.c+57 -00 replies
6/6selftests: KVM: use page stats to check if dirty logging works properlytools/testing/selftests/kvm/dirty_log_perf_test.c+53 -00 replies

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchMingwei ZhangBen Gardon
1/6R-b
2/6R-b R-b
3/6R-b
4/6
5/6
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/6] Verify dirty logging works properly with page stats

This patch set aims to fix a bug in which KVM incorrectly assumes a large page as a NX huge page. The bug would prevent guest VM from regaining large pages and cause performance issue. We fix the bug by explicitly checking the lpage_disallowed field in the shadow page. Moreover, to fix the bug properly for TDP MMU, we integrate two patches from Sean that ensures that we update lpage_disallowed in shadow page before making spte visible to guest.

To verify the bug fixed, we use dirty logging as the testing target and dirty_log_perf_test as the selftest binary. By adding the code to check the page stats from the per-VM interface, we discovered that VMs could regain large pages after dirty logging disabled. We also verify the existence of the bug if running with unpatched kernels.

To make the selftest working properly with per-VM stats interface, we borrowes two patches come from Ben's series: "[PATCH 00/13] KVM: x86: Add a cap to disable NX hugepages on a VM" [1].

[1] https://lore.kernel.org/all/[email protected]/T/

v2 -> v3:
- Update lpage_disallowed before making spte visible [seanjc].
- Adding tdp_mmu_pages stats [seanjc]
- update comments in selftest [bgardon]

v2: https://lore.kernel.org/lkml/[email protected]/T/

v1 -> v2:
- Update the commit message. [dmatlack]
- Update the comments in patch 3/4 to clarify the motivation. [bgardon]
- Add another iteration in dirty_log_perf_test to regain pages [bgardon]

Ben Gardon (2):
KVM: selftests: Dump VM stats in binary stats test
KVM: selftests: Test reading a single stat

Mingwei Zhang (2):
KVM: x86/mmu: explicitly check nx_hugepage in
disallowed_hugepage_adjust()
selftests: KVM: use page stats to check if dirty logging works
properly

Sean Christopherson (2):
KVM: x86/mmu: Set lpage_disallowed in TDP MMU before setting SPTE
KVM: x86/mmu: Track the number of TDP MMU pages, but not the actual
pages

 arch/x86/include/asm/kvm_host.h               |  11 +-
 arch/x86/kvm/mmu/mmu.c                        |  28 ++-
 arch/x86/kvm/mmu/mmu_internal.h               |   2 +-
 arch/x86/kvm/mmu/tdp_mmu.c                    |  36 ++--
 .../selftests/kvm/dirty_log_perf_test.c       |  53 +++++
 .../selftests/kvm/include/kvm_util_base.h     |   2 +
 .../selftests/kvm/kvm_binary_stats_test.c     |   6 +
 tools/testing/selftests/kvm/lib/kvm_util.c    | 196 ++++++++++++++++++
 8 files changed, 303 insertions(+), 31 deletions(-)
Signature · 1 line
2.35.1.1094.g7c7d902a7c-goog