[PATCH v1 12/18] KVM: selftests/rseq_test: name the migration thread and some cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the helper function to create the migration thread with name. Change
the global defination of migration_thread to local, as it's not
referenced anywhere outside main(). Aslo, check the return value from
pthread_join and assert on errors.

Signed-off-by: Wei Wang <wei.w.wang@xxxxxxxxx>
---
 tools/testing/selftests/kvm/rseq_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
index 6f88da7e60be..c124f00ca4fe 100644
--- a/tools/testing/selftests/kvm/rseq_test.c
+++ b/tools/testing/selftests/kvm/rseq_test.c
@@ -2,7 +2,6 @@
 #define _GNU_SOURCE /* for program_invocation_short_name */
 #include <errno.h>
 #include <fcntl.h>
-#include <pthread.h>
 #include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -28,7 +27,6 @@
  */
 #define NR_TASK_MIGRATIONS 100000
 
-static pthread_t migration_thread;
 static cpu_set_t possible_mask;
 static int min_cpu, max_cpu;
 static bool done;
@@ -204,6 +202,7 @@ int main(int argc, char *argv[])
 	struct kvm_vm *vm;
 	struct kvm_vcpu *vcpu;
 	u32 cpu, rseq_cpu;
+	pthread_t migration_thread;
 
 	/* Tell stdout not to buffer its content */
 	setbuf(stdout, NULL);
@@ -226,8 +225,8 @@ int main(int argc, char *argv[])
 	vm = vm_create_with_one_vcpu(&vcpu, guest_code);
 	ucall_init(vm, NULL);
 
-	pthread_create(&migration_thread, NULL, migration_worker,
-		       (void *)(unsigned long)syscall(SYS_gettid));
+	pthread_create_with_name(&migration_thread, migration_worker,
+		 (void *)(unsigned long)syscall(SYS_gettid), "mig-thread");
 
 	for (i = 0; !done; i++) {
 		vcpu_run(vcpu);
@@ -272,7 +271,8 @@ int main(int argc, char *argv[])
 	TEST_ASSERT(i > (NR_TASK_MIGRATIONS / 2),
 		    "Only performed %d KVM_RUNs, task stalled too much?\n", i);
 
-	pthread_join(migration_thread, NULL);
+	r = pthread_join(migration_thread, NULL);
+	TEST_ASSERT(r == 0, "failed to join the migration thread");
 
 	kvm_vm_free(vm);
 
-- 
2.27.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux