aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/lib/perf_test_util.c
diff options
context:
space:
mode:
authorVipin Sharma <vipinsh@google.com>2022-11-03 12:17:19 -0700
committerSean Christopherson <seanjc@google.com>2022-11-16 10:03:24 -0800
commitd886724ea81c6a4dc5e37d4ee09287a31ab8335e (patch)
tree9a8efec469058b33158eaef207065b9f1429c382 /tools/testing/selftests/kvm/lib/perf_test_util.c
parent0001725d0f9b5d749540021befb67c117d566416 (diff)
downloadlinux-d886724ea81c6a4dc5e37d4ee09287a31ab8335e.tar.gz
linux-d886724ea81c6a4dc5e37d4ee09287a31ab8335e.tar.bz2
linux-d886724ea81c6a4dc5e37d4ee09287a31ab8335e.zip
KVM: selftests: Allowing running dirty_log_perf_test on specific CPUs
Add a command line option, -c, to pin vCPUs to physical CPUs (pCPUs), i.e. to force vCPUs to run on specific pCPUs. Requirement to implement this feature came in discussion on the patch "Make page tables for eager page splitting NUMA aware" https://lore.kernel.org/lkml/YuhPT2drgqL+osLl@google.com/ This feature is useful as it provides a way to analyze performance based on the vCPUs and dirty log worker locations, like on the different NUMA nodes or on the same NUMA nodes. To keep things simple, implementation is intentionally very limited, either all of the vCPUs will be pinned followed by an optional main thread or nothing will be pinned. Signed-off-by: Vipin Sharma <vipinsh@google.com> Suggested-by: David Matlack <dmatlack@google.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221103191719.1559407-8-vipinsh@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/perf_test_util.c')
-rw-r--r--tools/testing/selftests/kvm/lib/perf_test_util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c
index 9618b37c66f7..3a1d0a44419b 100644
--- a/tools/testing/selftests/kvm/lib/perf_test_util.c
+++ b/tools/testing/selftests/kvm/lib/perf_test_util.c
@@ -2,6 +2,8 @@
/*
* Copyright (C) 2020, Google LLC.
*/
+#define _GNU_SOURCE
+
#include <inttypes.h>
#include "kvm_util.h"
@@ -243,6 +245,10 @@ void __weak perf_test_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_v
static void *vcpu_thread_main(void *data)
{
struct vcpu_thread *vcpu = data;
+ int vcpu_idx = vcpu->vcpu_idx;
+
+ if (perf_test_args.pin_vcpus)
+ kvm_pin_this_task_to_pcpu(perf_test_args.vcpu_to_pcpu[vcpu_idx]);
WRITE_ONCE(vcpu->running, true);
@@ -255,7 +261,7 @@ static void *vcpu_thread_main(void *data)
while (!READ_ONCE(all_vcpu_threads_running))
;
- vcpu_thread_fn(&perf_test_args.vcpu_args[vcpu->vcpu_idx]);
+ vcpu_thread_fn(&perf_test_args.vcpu_args[vcpu_idx]);
return NULL;
}