linux/tools/testing/selftests/kvm
David Matlack c33e05d9b0 KVM: selftests: Introduce access_tracking_perf_test
This test measures the performance effects of KVM's access tracking.
Access tracking is driven by the MMU notifiers test_young, clear_young,
and clear_flush_young. These notifiers do not have a direct userspace
API, however the clear_young notifier can be triggered by marking a
pages as idle in /sys/kernel/mm/page_idle/bitmap. This test leverages
that mechanism to enable access tracking on guest memory.

To measure performance this test runs a VM with a configurable number of
vCPUs that each touch every page in disjoint regions of memory.
Performance is measured in the time it takes all vCPUs to finish
touching their predefined region.

Example invocation:

  $ ./access_tracking_perf_test -v 8
  Testing guest mode: PA-bits:ANY, VA-bits:48,  4K pages
  guest physical test memory offset: 0xffdfffff000

  Populating memory             : 1.337752570s
  Writing to populated memory   : 0.010177640s
  Reading from populated memory : 0.009548239s
  Mark memory idle              : 23.973131748s
  Writing to idle memory        : 0.063584496s
  Mark memory idle              : 24.924652964s
  Reading from idle memory      : 0.062042814s

Breaking down the results:

 * "Populating memory": The time it takes for all vCPUs to perform the
   first write to every page in their region.

 * "Writing to populated memory" / "Reading from populated memory": The
   time it takes for all vCPUs to write and read to every page in their
   region after it has been populated. This serves as a control for the
   later results.

 * "Mark memory idle": The time it takes for every vCPU to mark every
   page in their region as idle through page_idle.

 * "Writing to idle memory" / "Reading from idle memory": The time it
   takes for all vCPUs to write and read to every page in their region
   after it has been marked idle.

This test should be portable across architectures but it is only enabled
for x86_64 since that's all I have tested.

Reviewed-by: Ben Gardon <bgardon@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20210713220957.3493520-7-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-07-27 16:59:00 -04:00
..
aarch64 KVM: arm64: selftests: get-reg-list: actually enable pmu regs in pmu sublist 2021-07-14 11:55:18 +01:00
include Merge tag 'kvm-s390-master-5.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD 2021-07-14 12:14:27 -04:00
lib KVM: selftests: Address extra memslot parameters in vm_vaddr_alloc 2021-07-15 10:19:41 -04:00
s390x KVM: selftests: sync_regs test for diag318 2020-12-10 13:36:05 +01:00
x86_64 KVM: selftests: smm_test: Test SMM enter from L2 2021-07-15 10:19:44 -04:00
.gitignore KVM: selftests: Introduce access_tracking_perf_test 2021-07-27 16:59:00 -04:00
access_tracking_perf_test.c KVM: selftests: Introduce access_tracking_perf_test 2021-07-27 16:59:00 -04:00
config selftests: kvm: Adding config fragments 2019-08-09 16:52:38 +02:00
demand_paging_test.c KVM: selftests: add shared hugetlbfs backing source type 2021-05-27 07:45:57 -04:00
dirty_log_perf_test.c KVM: selftests: Fix missing break in dirty_log_perf_test arg parsing 2021-07-27 16:58:59 -04:00
dirty_log_test.c KVM: selftests: Unconditionally use memslot '0' for page table allocations 2021-06-24 11:47:48 -04:00
hardware_disable_test.c KVM: selftests: Unconditionally use memslot 0 when loading elf binary 2021-06-24 04:31:17 -04:00
kvm_binary_stats_test.c KVM: selftests: Add selftest for KVM statistics data binary interface 2021-06-24 18:00:26 -04:00
kvm_create_max_vcpus.c KVM: selftests: Convert some printf's to pr_info's 2020-03-16 17:57:07 +01:00
kvm_page_table_test.c KVM: selftests: Unconditionally use memslot '0' for page table allocations 2021-06-24 11:47:48 -04:00
Makefile KVM: selftests: Introduce access_tracking_perf_test 2021-07-27 16:59:00 -04:00
memslot_modification_stress_test.c KVM: selftests: Fix 32-bit truncation of vm_get_max_gfn() 2021-05-27 07:45:54 -04:00
memslot_perf_test.c KVM: selftests: Unconditionally use memslot '0' for page table allocations 2021-06-24 11:47:48 -04:00
set_memory_region_test.c Merge tag 'kvm-s390-master-5.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD 2021-07-14 12:14:27 -04:00
settings selftests: kvm: Raise the default timeout to 120 seconds 2021-02-09 08:17:08 -05:00
steal_time.c KVM: selftests: change pthread_yield to sched_yield 2021-07-14 11:55:18 +01:00