[PATCH i-g-t v2 28/66] tests/xe_eudebug: Add basic-client-th test
Piatkowski, Dominik Karol
dominik.karol.piatkowski at intel.com
Thu Aug 1 12:49:49 UTC 2024
Reviewed-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
> -----Original Message-----
> From: Manszewski, Christoph <christoph.manszewski at intel.com>
> Sent: Tuesday, July 30, 2024 1:45 PM
> To: igt-dev at lists.freedesktop.org
> Cc: Kempczynski, Zbigniew <zbigniew.kempczynski at intel.com>; Kamil
> Konieczny <kamil.konieczny at linux.intel.com>; Grzegorzek, Dominik
> <dominik.grzegorzek at intel.com>; Patelczyk, Maciej
> <maciej.patelczyk at intel.com>; Piatkowski, Dominik Karol
> <dominik.karol.piatkowski at intel.com>; Sikora, Pawel
> <pawel.sikora at intel.com>; Hajda, Andrzej <andrzej.hajda at intel.com>;
> Kolanupaka Naveena <kolanupaka.naveena at intel.com>; Kuoppala, Mika
> <mika.kuoppala at intel.com>; Mun, Gwan-gyeong <gwan-
> gyeong.mun at intel.com>
> Subject: [PATCH i-g-t v2 28/66] tests/xe_eudebug: Add basic-client-th test
>
> From: Pawel Sikora <pawel.sikora at intel.com>
>
> Add basic-client-th test which is a multithreaded version of basic-client.
>
> Create random number of VMs in random number of threads.
>
> Signed-off-by: Pawel Sikora <pawel.sikora at intel.com>
> Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> ---
> tests/intel/xe_eudebug.c | 77
> ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 77 insertions(+)
>
> diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c index
> ab856727e..022b39f1f 100644
> --- a/tests/intel/xe_eudebug.c
> +++ b/tests/intel/xe_eudebug.c
> @@ -13,6 +13,7 @@
> */
>
> #include <poll.h>
> +#include <pthread.h>
> #include <sys/ioctl.h>
>
> #include "igt.h"
> @@ -640,6 +641,10 @@ static void test_read_event(int fd)
> * Description:
> * Attach the debugger to process which opens and closes xe drm client.
> *
> + * SUBTEST: basic-client-th
> + * Description:
> + * Create client basic resources (vms) in multiple threads
> + *
> * SUBTEST: multiple-sessions
> * Description:
> * Simultaneously attach many debuggers to many processes.
> @@ -1057,6 +1062,75 @@ static void test_client_with_trigger(int fd,
> unsigned int flags, int count,
> xe_eudebug_session_destroy(s[i]);
> }
>
> +struct thread_fn_args {
> + struct xe_eudebug_client *client;
> + int fd;
> +};
> +
> +static void *basic_client_th(void *data) {
> + struct thread_fn_args *f = data;
> + struct xe_eudebug_client *c = f->client;
> + uint32_t *vms;
> + int fd, i, num_vms;
> +
> + fd = f->fd;
> + igt_assert(fd);
> +
> + xe_device_get(fd);
> +
> + num_vms = 2 + rand() % 16;
> + vms = calloc(num_vms, sizeof(*vms));
> + igt_assert(vms);
> + igt_debug("Create %d client vms\n", num_vms);
> +
> + for (i = 0; i < num_vms; i++)
> + vms[i] = xe_eudebug_client_vm_create(c, fd,
> +DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE, 0);
> +
> + for (i = 0; i < num_vms; i++)
> + xe_eudebug_client_vm_destroy(c, fd, vms[i]);
> +
> + xe_device_put(fd);
> + free(vms);
> +
> + return NULL;
> +}
> +
> +static void run_basic_client_th(struct xe_eudebug_client *c) {
> + struct thread_fn_args *args;
> + int i, num_threads, fd;
> + pthread_t *threads;
> +
> + args = calloc(1, sizeof(*args));
> + igt_assert(args);
> +
> + num_threads = 2 + random() % 16;
> + igt_debug("Run on %d threads\n", num_threads);
> + threads = calloc(num_threads, sizeof(*threads));
> + igt_assert(threads);
> +
> + fd = xe_eudebug_client_open_driver(c);
> + args->client = c;
> + args->fd = fd;
> +
> + for (i = 0; i < num_threads; i++)
> + pthread_create(&threads[i], NULL, basic_client_th, args);
> +
> + for (i = 0; i < num_threads; i++)
> + pthread_join(threads[i], NULL);
> +
> + xe_eudebug_client_close_driver(c, fd);
> + free(args);
> + free(threads);
> +}
> +
> +static void test_basic_sessions_th(int fd, unsigned int flags, int
> +num_clients, bool match_opposite) {
> + test_client_with_trigger(fd, flags, num_clients, run_basic_client_th,
> + 0, NULL, NULL, match_opposite, 0); }
> +
> static void vm_access_client(struct xe_eudebug_client *c) {
> struct drm_xe_sync sync = {
> @@ -1469,6 +1543,9 @@ igt_main
> igt_subtest("basic-client")
> test_basic_sessions(fd, 0, 1, true);
>
> + igt_subtest("basic-client-th")
> + test_basic_sessions_th(fd, 0, 1, true);
> +
> igt_subtest("basic-vm-access")
> test_vm_access(fd, 0, 1);
>
> --
> 2.34.1
More information about the igt-dev
mailing list