From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DFC910E60C for ; Tue, 5 Dec 2023 21:21:11 +0000 (UTC) From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Date: Tue, 5 Dec 2023 13:10:20 -0800 Message-Id: <20231205211020.226517-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t] tests/xe_create: Unthread create-execqueues tests List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lucas.demarchi@intel.com, jonathan.cavitt@intel.com, saurabhg.gupta@intel.com Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: The inclusion of igt_fork in the test is designed to improve performance by multithreading the process of execqueue creation. However, after each execqueue is created on a thread, a context switch appears to occur, causing all the execqueues created for that thread to be stored in memory and all the execqueues for the other thread to be loaded. At scale, the delays caused by repeated memory loads and unloads actually cause a reduction in performance, and as such it's actually more performant to create the execqueues serially rather than rely on forking. Signed-off-by: Jonathan Cavitt CC: Zbigniew KempczyƄski CC: Kamil Konieczny CC: Lucas de Marchi CC: Niranjana Vishwanathapura --- tests/intel/xe_create.c | 51 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/tests/intel/xe_create.c b/tests/intel/xe_create.c index bbdddc7c9b..f4a80aa155 100644 --- a/tests/intel/xe_create.c +++ b/tests/intel/xe_create.c @@ -136,47 +136,38 @@ static uint32_t __xe_exec_queue_create(int fd, uint32_t vm, static void create_execqueues(int fd, enum exec_queue_destroy ed) { struct timespec tv = { }; - uint32_t num_engines, exec_queues_per_process, vm; - int nproc = sysconf(_SC_NPROCESSORS_ONLN), seconds; + struct drm_xe_engine *engine; + uint32_t num_engines, vm; + int idx, err, i, seconds; + uint32_t exec_queue, exec_queues[MAXEXECQUEUES]; fd = drm_reopen_driver(fd); num_engines = xe_number_engines(fd); vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_ASYNC_DEFAULT, 0); - exec_queues_per_process = max_t(uint32_t, 1, MAXEXECQUEUES / nproc); - igt_debug("nproc: %u, exec_queues per process: %u\n", nproc, exec_queues_per_process); igt_nsec_elapsed(&tv); - igt_fork(n, nproc) { - struct drm_xe_engine *engine; - uint32_t exec_queue, exec_queues[exec_queues_per_process]; - int idx, err, i; - - srandom(n); - - for (i = 0; i < exec_queues_per_process; i++) { - idx = rand() % num_engines; - engine = xe_engine(fd, idx); - err = __xe_exec_queue_create(fd, vm, &engine->instance, - 0, &exec_queue); - igt_debug("[%2d] Create exec_queue: err=%d, exec_queue=%u [idx = %d]\n", - n, err, exec_queue, i); - if (err) - break; - - if (ed == NOLEAK) - exec_queues[i] = exec_queue; - } + for (i = 0; i < MAXEXECQUEUES; i++) { + idx = rand() % num_engines; + engine = xe_engine(fd, idx); + err = __xe_exec_queue_create(fd, vm, &engine->instance, + 0, &exec_queue); + igt_debug("Create exec_queue: err=%d, exec_queue=%u [idx = %d]\n", + err, exec_queue, i); + if (err) + break; + + if (ed == NOLEAK) + exec_queues[i] = exec_queue; + } - if (ed == NOLEAK) { - while (--i >= 0) { - igt_debug("[%2d] Destroy exec_queue: %u\n", n, exec_queues[i]); - xe_exec_queue_destroy(fd, exec_queues[i]); - } + if (ed == NOLEAK) { + while (--i >= 0) { + igt_debug("Destroy exec_queue: %u\n", exec_queues[i]); + xe_exec_queue_destroy(fd, exec_queues[i]); } } - igt_waitchildren(); xe_vm_destroy(fd, vm); drm_close_driver(fd); -- 2.25.1