Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: lucas.demarchi@intel.com, jonathan.cavitt@intel.com,
	saurabhg.gupta@intel.com
Subject: [igt-dev] [PATCH i-g-t] tests/xe_create: Unthread create-execqueues tests
Date: Tue,  5 Dec 2023 13:10:20 -0800	[thread overview]
Message-ID: <20231205211020.226517-1-jonathan.cavitt@intel.com> (raw)

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 <jonathan.cavitt@intel.com>
CC: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
CC: Kamil Konieczny <kamil.konieczny@linux.intel.com>
CC: Lucas de Marchi <lucas.demarchi@intel.com>
CC: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
---
 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

             reply	other threads:[~2023-12-05 21:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 21:10 Jonathan Cavitt [this message]
2023-12-05 22:26 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/xe_create: Unthread create-execqueues tests Patchwork
2023-12-05 23:49 ` [igt-dev] ✗ CI.xeBAT: " Patchwork
2023-12-07  7:39 ` [igt-dev] [PATCH i-g-t] " Zbigniew Kempczyński

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231205211020.226517-1-jonathan.cavitt@intel.com \
    --to=jonathan.cavitt@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=saurabhg.gupta@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox