[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221024113445.1022147-7-wei.w.wang@intel.com>
Date: Mon, 24 Oct 2022 19:34:33 +0800
From: Wei Wang <wei.w.wang@...el.com>
To: seanjc@...gle.com, pbonzini@...hat.com
Cc: dmatlack@...gle.com, vipinsh@...gle.com, ajones@...tanamicro.com,
eric.auger@...hat.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Wei Wang <wei.w.wang@...el.com>
Subject: [PATCH v1 06/18] KVM: selftests/dirty_log_test: vcpu related code consolidation
Remove the globally defined vcpu thread, and reuse the one from
kvm_vcpu. Also, use the helper functions to create and join the vcpu
thread, which has implemented error check (i.e. TEST_ASSERT) inside.
Signed-off-by: Wei Wang <wei.w.wang@...el.com>
---
tools/testing/selftests/kvm/dirty_log_test.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index b5234d6efbe1..9177b8ca004d 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -9,7 +9,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <pthread.h>
#include <semaphore.h>
#include <sys/types.h>
#include <signal.h>
@@ -188,12 +187,11 @@ enum log_mode_t {
static enum log_mode_t host_log_mode_option = LOG_MODE_ALL;
/* Logging mode for current run */
static enum log_mode_t host_log_mode;
-static pthread_t vcpu_thread;
static uint32_t test_dirty_ring_count = TEST_DIRTY_RING_COUNT;
-static void vcpu_kick(void)
+static void vcpu_kick(struct kvm_vcpu *vcpu)
{
- pthread_kill(vcpu_thread, SIG_IPI);
+ pthread_kill(vcpu->thread, SIG_IPI);
}
/*
@@ -315,10 +313,10 @@ static uint32_t dirty_ring_collect_one(struct kvm_dirty_gfn *dirty_gfns,
return count;
}
-static void dirty_ring_wait_vcpu(void)
+static void dirty_ring_wait_vcpu(struct kvm_vcpu *vcpu)
{
/* This makes sure that hardware PML cache flushed */
- vcpu_kick();
+ vcpu_kick(vcpu);
sem_wait_until(&sem_vcpu_stop);
}
@@ -336,7 +334,7 @@ static void dirty_ring_collect_dirty_pages(struct kvm_vcpu *vcpu, int slot,
uint32_t count = 0, cleared;
bool continued_vcpu = false;
- dirty_ring_wait_vcpu();
+ dirty_ring_wait_vcpu(vcpu);
if (!dirty_ring_vcpu_ring_full) {
/*
@@ -772,7 +770,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
host_clear_count = 0;
host_track_next_count = 0;
- pthread_create(&vcpu_thread, NULL, vcpu_worker, vcpu);
+ vcpu_thread_create(vcpu, vcpu_worker, 0);
while (iteration < p->iterations) {
/* Give the vcpu thread some time to dirty some pages */
@@ -805,7 +803,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
/* Tell the vcpu thread to quit */
host_quit = true;
log_mode_before_vcpu_join();
- pthread_join(vcpu_thread, NULL);
+ vm_vcpu_threads_join(vm);
pr_info("Total bits checked: dirty (%"PRIu64"), clear (%"PRIu64"), "
"track_next (%"PRIu64")\n", host_dirty_count, host_clear_count,
--
2.27.0
Powered by blists - more mailing lists