Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/xe_exec_threads: Reduce copy & paste
@ 2024-03-29 21:14 Lucas De Marchi
  2024-03-29 22:15 ` ✗ GitLab.Pipeline: warning for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lucas De Marchi @ 2024-03-29 21:14 UTC (permalink / raw)
  To: igt-dev; +Cc: Matt Roper, Matthew Brost, Lucas De Marchi

Replace copy & paste by a loop, so we avoid issues like the one fixed by
commit 27c06a4106e1 ("tests/xe_exec_threads: Fill in GT field for second
balancer thread").

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 tests/intel/xe_exec_threads.c | 36 ++++++-----------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/tests/intel/xe_exec_threads.c b/tests/intel/xe_exec_threads.c
index 05ea1d35a..e9588f9b9 100644
--- a/tests/intel/xe_exec_threads.c
+++ b/tests/intel/xe_exec_threads.c
@@ -1030,6 +1030,7 @@ static void threads(int fd, int flags)
 		xe_for_each_gt(fd, gt)
 			xe_for_each_engine_class(class) {
 				int num_placements = 0;
+				int *data_flags = (int[]){ VIRTUAL, PARALLEL, -1 };
 
 				xe_for_each_engine(fd, hwe) {
 					if (hwe->engine_class != class ||
@@ -1038,36 +1039,10 @@ static void threads(int fd, int flags)
 					++num_placements;
 				}
 
-				if (num_placements > 1) {
-					threads_data[i].mutex = &mutex;
-					threads_data[i].cond = &cond;
-					if (flags & SHARED_VM)
-						threads_data[i].addr = addr |
-							(i << ADDRESS_SHIFT);
-					else
-						threads_data[i].addr = addr;
-					threads_data[i].userptr = userptr |
-						(i << ADDRESS_SHIFT);
-					if (flags & FD)
-						threads_data[i].fd = 0;
-					else
-						threads_data[i].fd = fd;
-					threads_data[i].gt = gt;
-					threads_data[i].vm_legacy_mode =
-						vm_legacy_mode;
-					threads_data[i].class = class;
-					threads_data[i].n_exec_queue = N_EXEC_QUEUE;
-					threads_data[i].n_exec = N_EXEC;
-					threads_data[i].flags = flags;
-					threads_data[i].flags &= ~BALANCER;
-					threads_data[i].flags |= VIRTUAL;
-					threads_data[i].go = &go;
-
-					++n_threads;
-					pthread_create(&threads_data[i].thread, 0,
-						       thread, &threads_data[i]);
-					++i;
+				if (num_placements <= 1)
+					continue;
 
+				while (*data_flags >= 0) {
 					threads_data[i].mutex = &mutex;
 					threads_data[i].cond = &cond;
 					if (flags & SHARED_VM)
@@ -1089,13 +1064,14 @@ static void threads(int fd, int flags)
 					threads_data[i].n_exec = N_EXEC;
 					threads_data[i].flags = flags;
 					threads_data[i].flags &= ~BALANCER;
-					threads_data[i].flags |= PARALLEL;
+					threads_data[i].flags |= *data_flags;
 					threads_data[i].go = &go;
 
 					++n_threads;
 					pthread_create(&threads_data[i].thread, 0,
 						       thread, &threads_data[i]);
 					++i;
+					data_flags++;
 				}
 			}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-30 23:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29 21:14 [PATCH i-g-t] tests/xe_exec_threads: Reduce copy & paste Lucas De Marchi
2024-03-29 22:15 ` ✗ GitLab.Pipeline: warning for " Patchwork
2024-03-29 22:41 ` ✓ CI.xeBAT: success " Patchwork
2024-03-29 22:46 ` ✓ Fi.CI.BAT: " Patchwork
2024-03-29 23:36 ` [PATCH i-g-t] " Matthew Brost
2024-03-30 23:26 ` ✗ Fi.CI.IGT: failure for " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox