From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Matt Roper <matthew.d.roper@intel.com>,
Matthew Brost <matthew.brost@intel.com>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH i-g-t] tests/xe_exec_threads: Reduce copy & paste
Date: Fri, 29 Mar 2024 14:14:49 -0700 [thread overview]
Message-ID: <20240329211449.924460-1-lucas.demarchi@intel.com> (raw)
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
next reply other threads:[~2024-03-29 21:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 21:14 Lucas De Marchi [this message]
2024-03-29 22:15 ` ✗ GitLab.Pipeline: warning for tests/xe_exec_threads: Reduce copy & paste 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
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=20240329211449.924460-1-lucas.demarchi@intel.com \
--to=lucas.demarchi@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=matthew.d.roper@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