RE: [PATCH v5 0/5] dirty_log_perf_test vCPU pinning
From: Wang, Wei W
Date: Fri Oct 14 2022 - 11:12:31 EST
On Tuesday, October 11, 2022 6:06 AM, Vipin Sharma wrote:
> Pin vCPUs to a host physical CPUs (pCPUs) in dirty_log_perf_test and optionally
> pin the main application thread to a physical cpu if provided. All tests based on
> perf_test_util framework can take advantage of it if needed.
>
> While at it, I changed atoi() to atoi_paranoid(), atoi_positive,
> atoi_non_negative() in other tests, sorted command line options alphabetically
> in dirty_log_perf_test, and added break between -e and -g which was missed in
> original commit when -e was introduced.
Just curious why not re-using the existing tools (e.g. taskset) to do the pinning?
For example, with below changes:
diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/se lftests/kvm/lib/perf_test_util.c
index 9618b37c66f7..aac58d1acb3c 100644
--- a/tools/testing/selftests/kvm/lib/perf_test_util.c
+++ b/tools/testing/selftests/kvm/lib/perf_test_util.c
@@ -264,6 +264,7 @@ void perf_test_start_vcpu_threads(int nr_vcpus,
void (*vcpu_fn)(struct perf_test_vcpu_args *))
{
int i;
+ char vcpu_name[5];
vcpu_thread_fn = vcpu_fn;
WRITE_ONCE(all_vcpu_threads_running, false);
@@ -275,6 +276,8 @@ void perf_test_start_vcpu_threads(int nr_vcpus,
WRITE_ONCE(vcpu->running, false);
pthread_create(&vcpu->thread, NULL, vcpu_thread_main, vcpu);
+ sprintf(vcpu_name, "%s%d", "vcpu", i);
+ pthread_setname_np(vcpu->thread, vcpu_name);
}
and with top we can get
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4464 root 20 0 4248684 4.0g 1628 R 99.9 26.2 0:50.97 dirty_log_perf_
4467 root 20 0 4248684 4.0g 1628 R 99.9 26.2 0:50.93 vcpu0
4469 root 20 0 4248684 4.0g 1628 R 99.9 26.2 0:50.93 vcpu2
4470 root 20 0 4248684 4.0g 1628 R 99.9 26.2 0:50.94 vcpu3
4468 root 20 0 4248684 4.0g 1628 R 99.7 26.2 0:50.93 vcpu1