Skip to content

KVM selftests code consolidation and cleanup

Wei Wang kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest18 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18KVM: selftests/kvm_util: use array of pointers to maintain vcpus in kvm_vmtools/testing/selftests/kvm/include/kvm_util.h tools/testing/selftests/kvm/include/kvm_util_base.h tools/testing/selftests/kvm/lib/kvm_util.c +1 more+17 -264 replies
2/18KVM: selftests/kvm_util: use vm->vcpus[] when create vm with vcpustools/testing/selftests/kvm/lib/kvm_util.c+3 -60 replies
3/18KVM: selftests/kvm_util: helper functions for vcpus and threadstools/testing/selftests/kvm/include/kvm_util.h tools/testing/selftests/kvm/include/kvm_util_base.h tools/testing/selftests/kvm/lib/kvm_util.c+194 -03 replies
4/18KVM: selftests/kvm_page_table_test: vcpu related code consolidationtools/testing/selftests/kvm/kvm_page_table_test.c+3 -130 replies
5/18KVM: selftests/hardware_disable_test: code consolidation and cleanuptools/testing/selftests/kvm/hardware_disable_test.c+15 -414 replies
6/18KVM: selftests/dirty_log_test: vcpu related code consolidationtools/testing/selftests/kvm/dirty_log_test.c+7 -90 replies
7/18KVM: selftests/max_guest_memory_test: vcpu related code consolidationtools/testing/selftests/kvm/max_guest_memory_test.c+20 -330 replies
8/18KVM: selftests/set_memory_region_test: vcpu related code consolidationtools/testing/selftests/kvm/set_memory_region_test.c+6 -100 replies
9/18KVM: selftests/steal_time: vcpu related code consolidation and cleanuptools/testing/selftests/kvm/steal_time.c+9 -61 reply
10/18KVM: selftests/tsc_scaling_sync: vcpu related code consolidationtools/testing/selftests/kvm/x86_64/tsc_scaling_sync.c+5 -200 replies
11/18KVM: selftest/xapic_ipi_test: vcpu related code consolidationtools/testing/selftests/kvm/x86_64/xapic_ipi_test.c+24 -300 replies
12/18KVM: selftests/rseq_test: name the migration thread and some cleanuptools/testing/selftests/kvm/rseq_test.c+5 -51 reply
13/18KVM: selftests/perf_test_util: vcpu related code consolidationtools/testing/selftests/kvm/access_tracking_perf_test.c tools/testing/selftests/kvm/demand_paging_test.c tools/testing/selftests/kvm/dirty_log_perf_test.c +4 more+53 -820 replies
14/18KVM: selftest/memslot_perf_test: vcpu related code consolidationtools/testing/selftests/kvm/memslot_perf_test.c+71 -660 replies
15/18KVM: selftests/vgic_init: vcpu related code consolidationtools/testing/selftests/kvm/aarch64/vgic_init.c+17 -180 replies
16/18KVM: selftest/arch_timer: vcpu related code consolidationtools/testing/selftests/kvm/aarch64/arch_timer.c+16 -260 replies
17/18KVM: selftests: remove the *vcpu[] input from __vm_create_with_vcpustools/testing/selftests/kvm/aarch64/arch_timer.c tools/testing/selftests/kvm/aarch64/vgic_init.c tools/testing/selftests/kvm/hardware_disable_test.c +7 more+14 -150 replies
18/18KVM: selftests/kvm_create_max_vcpus: check KVM_MAX_VCPUStools/testing/selftests/kvm/kvm_create_max_vcpus.c+7 -01 reply

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH v1 00/18] KVM selftests code consolidation and cleanup

This patch series intends to improve kvm selftests with better code consolidation using the helper functions to perform vcpu and thread related operations.

In general, several aspects are improved:
1) The current users allocate an array of vcpu pointers to the vcpus that are added to a vm, and an array of vcpu threads. This isn't necessary as kvm_vm already maintains a list of added vcpus. This series changes the list of vcpus in the kvm_vm struct to a vcpu array for users to work with and removes each user's own allocation of such vcpu arrays. Aslo add the vcpu thread to the kvm_vcpu struct, so that users don't need to explicitly allocate a thread array to manage vcpu threads on their own.
2) Change the users to use the helper functions provided by this series with the following enhancements:
- Many users working with pthread_create/join forgot to check if error on returning. The helper functions have handled thoses inside, so users don't need to handle them by themselves;
- The vcpu threads created via the helper functions are named in "vcpu-##id" format. Naming the threads facilitates debugging, performance tuning, runtime pining etc;
- helper functions named with "vm_vcpu_threads_" iterates over all the vcpus that have been added to the vm. Users don't need a explicit loop to go through the added cpus by themselves.
3) kvm_vcpu is used as the interface parameter to the vcpu thread's start routine, and the user specific data is made to be the private data in kvm_vcpu. This can simplify the user specific data structures, as kvm_vcpu has already included the required info for the thread, for example, in patch 13, the cpu_idx field from "struct vcpu_thread" is a duplicate of vcpu->id.

The changes have been tested on an SPR server. Patch 15 and 16 haven't been tested due to the lack of an ARM environment currently.

Wei Wang (18):
KVM: selftests/kvm_util: use array of pointers to maintain vcpus in
kvm_vm
KVM: selftests/kvm_util: use vm->vcpus[] when create vm with vcpus
KVM: selftests/kvm_util: helper functions for vcpus and threads
KVM: selftests/kvm_page_table_test: vcpu related code consolidation
KVM: selftests/hardware_disable_test: code consolidation and cleanup
KVM: selftests/dirty_log_test: vcpu related code consolidation
KVM: selftests/max_guest_memory_test: vcpu related code consolidation
KVM: selftests/set_memory_region_test: vcpu related code consolidation
KVM: selftests/steal_time: vcpu related code consolidation and cleanup
KVM: selftests/tsc_scaling_sync: vcpu related code consolidation
KVM: selftest/xapic_ipi_test: vcpu related code consolidation
KVM: selftests/rseq_test: name the migration thread and some cleanup
KVM: selftests/perf_test_util: vcpu related code consolidation
KVM: selftest/memslot_perf_test: vcpu related code consolidation
KVM: selftests/vgic_init: vcpu related code consolidation
KVM: selftest/arch_timer: vcpu related code consolidation
KVM: selftests: remove the *vcpu[] input from __vm_create_with_vcpus
KVM: selftests/kvm_create_max_vcpus: check KVM_MAX_VCPUS

 .../selftests/kvm/aarch64/arch_timer.c        |  42 ++--
 .../testing/selftests/kvm/aarch64/vgic_init.c |  35 ++-
 .../selftests/kvm/access_tracking_perf_test.c |  18 +-
 .../selftests/kvm/demand_paging_test.c        |   9 +-
 .../selftests/kvm/dirty_log_perf_test.c       |  11 +-
 tools/testing/selftests/kvm/dirty_log_test.c  |  16 +-
 .../selftests/kvm/hardware_disable_test.c     |  56 ++---
 .../testing/selftests/kvm/include/kvm_util.h  |  24 ++
 .../selftests/kvm/include/kvm_util_base.h     |  12 +-
 .../selftests/kvm/include/perf_test_util.h    |   9 +-
 .../selftests/kvm/kvm_create_max_vcpus.c      |   7 +
 .../selftests/kvm/kvm_page_table_test.c       |  16 +-
 tools/testing/selftests/kvm/lib/kvm_util.c    | 217 +++++++++++++++---
 .../selftests/kvm/lib/perf_test_util.c        |  68 ++----
 .../selftests/kvm/lib/x86_64/perf_test_util.c |  11 +-
 tools/testing/selftests/kvm/lib/x86_64/vmx.c  |   2 +-
 .../selftests/kvm/max_guest_memory_test.c     |  53 ++---
 .../kvm/memslot_modification_stress_test.c    |   9 +-
 .../testing/selftests/kvm/memslot_perf_test.c | 137 +++++------
 tools/testing/selftests/kvm/rseq_test.c       |  10 +-
 .../selftests/kvm/set_memory_region_test.c    |  16 +-
 tools/testing/selftests/kvm/steal_time.c      |  15 +-
 .../selftests/kvm/x86_64/tsc_scaling_sync.c   |  25 +-
 .../selftests/kvm/x86_64/xapic_ipi_test.c     |  54 ++---
 24 files changed, 476 insertions(+), 396 deletions(-)
Signature · 1 line
2.27.0