lkml.org 
[lkml]   [2022]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 05/18] KVM: selftests/hardware_disable_test: code consolidation and cleanup
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@intel.com>
> ---
> .../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.

\
 
 \ /
  Last update: 2022-10-27 02:17    [W:0.236 / U:2.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site