On Mon, Oct 24, 2022, Wei Wang wrote: > Remove the unnecessary definition of the threads[] array, and use the > helper functions to create and join threads. > > Also move setting of the thread affinity to __vcpu_thread_create using > attribute. This avoids an explicit step to set it after thread > creation. As David called out, please do this in a separate patch (one logical change per patch). > Signed-off-by: Wei Wang <wei.w.wang@xxxxxxxxx> > --- > .../selftests/kvm/hardware_disable_test.c | 56 +++++-------------- > 1 file changed, 15 insertions(+), 41 deletions(-) > > diff --git a/tools/testing/selftests/kvm/hardware_disable_test.c b/tools/testing/selftests/kvm/hardware_disable_test.c > index f5d59b9934f1..c212d34a6714 100644 > --- a/tools/testing/selftests/kvm/hardware_disable_test.c > +++ b/tools/testing/selftests/kvm/hardware_disable_test.c > @@ -8,7 +8,6 @@ > #define _GNU_SOURCE > > #include <fcntl.h> > -#include <pthread.h> > #include <semaphore.h> > #include <stdint.h> > #include <stdlib.h> > @@ -59,64 +58,39 @@ static void *sleeping_thread(void *arg) > pthread_exit(NULL); > } > > -static inline void check_create_thread(pthread_t *thread, pthread_attr_t *attr, > - void *(*f)(void *), void *arg) > -{ > - int r; > - > - r = pthread_create(thread, attr, f, arg); > - TEST_ASSERT(r == 0, "%s: failed to create thread", __func__); > -} > - > -static inline void check_set_affinity(pthread_t thread, cpu_set_t *cpu_set) > -{ > - int r; > - > - r = pthread_setaffinity_np(thread, sizeof(cpu_set_t), cpu_set); > - TEST_ASSERT(r == 0, "%s: failed set affinity", __func__); > -} > - > -static inline void check_join(pthread_t thread, void **retval) > -{ > - int r; > - > - r = pthread_join(thread, retval); > - TEST_ASSERT(r == 0, "%s: failed to join thread", __func__); > -} > - > static void run_test(uint32_t run) > { > struct kvm_vcpu *vcpu; > struct kvm_vm *vm; > cpu_set_t cpu_set; > - pthread_t threads[VCPU_NUM]; > pthread_t throw_away; > - void *b; > + pthread_attr_t attr; > uint32_t i, j; > + int r; > > CPU_ZERO(&cpu_set); > for (i = 0; i < VCPU_NUM; i++) > CPU_SET(i, &cpu_set); Uh, what is this test doing? I assume the intent is to avoid spamming all pCPUs in the system, but I don't get the benefit of doing so.