From: "Thomas, Sobin" <sobin.thomas@intel.com>
To: "Dandamudi, Priyanka" <priyanka.dandamudi@intel.com>,
"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
"Brost, Matthew" <matthew.brost@intel.com>
Cc: "Sharma, Nishit" <nishit.sharma@intel.com>
Subject: Re: [PATCH i-g-t v5 4/5] tests/intel: Add threaded random-size allocation stress tests
Date: Thu, 8 Oct 2026 16:05:57 +0530 [thread overview]
Message-ID: <82f59c67-6c47-403b-b052-4920bde49fd0@intel.com> (raw)
In-Reply-To: <CH3PR11MB8434785B888540B99D8B4BCF8D962@CH3PR11MB8434.namprd11.prod.outlook.com>
On 10/5/2026 12:26 PM, Dandamudi, Priyanka wrote:
>
>> -----Original Message-----
>> From: Thomas, Sobin <sobin.thomas@intel.com>
>> Sent: 22 September 2026 16:35
>> To: igt-dev@lists.freedesktop.org; Brost, Matthew <matthew.brost@intel.com>
>> Cc: Sharma, Nishit <nishit.sharma@intel.com>; Dandamudi, Priyanka
>> <priyanka.dandamudi@intel.com>
>> Subject: [PATCH i-g-t v5 4/5] tests/intel: Add threaded random-size allocation
>> stress tests
>>
>> Add a new TYPE_THREAD test mode that creates a worker thread per available
>> engine and performs random-sized BO allocations concurrently.
>>
>> Each thread creates its own VM and execution queue and exercises the existing
>> allocation path with both aligned and unaligned bind addresses.
>> Additional variants cover leaked bindings.
>>
>> These tests provide additional stress coverage for concurrent BO allocation and
>> VM bind activity across multiple engines.
>>
>> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
>> Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
>> ---
>> tests/intel/xe_bo_alloc.c | 149 +++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 148 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/intel/xe_bo_alloc.c b/tests/intel/xe_bo_alloc.c index
>> 343d07626..d8368087b 100644
>> --- a/tests/intel/xe_bo_alloc.c
>> +++ b/tests/intel/xe_bo_alloc.c
>> @@ -56,6 +56,26 @@
>> * Description: Test 10 batches of 10 random BO allocation sizes bound together
>> as a single
>> * array of binds, unaligned bind addresses
>> * Test category: functionality test
>> + *
>> + *
>> + * SUBTEST: threads-rand-sizes-50
>> + * Description: Test 50 random bo allocation sizes in test table with a
>> + thread per engine
>> + * test category: stress test
>> + *
>> + * SUBTEST: threads-rand-sizes-50-unaligned
>> + * Description: Test 50 random bo allocation sizes in test table with a
>> + thread per engine,
>> + * unaligned bind addresses
>> + * test category: stress test
>> + *
>> + * SUBTEST: threads-leak-binding-rand-sizes-50
>> + * Description: Test 50 random BO allocation sizes in test table with a
>> + thread per engine,
>> + * leak the binding
>> + * Test category: stress test
>> + *
>> + * SUBTEST: threads-leak-binding-rand-sizes-50-unaligned
>> + * Description: Test 50 random BO allocation sizes in test table with a
>> + thread per engine,
>> + * leak the binding, unaligned bind addresses
>> + * Test category: stress test
>> */
>>
>> #define GB(x) (1024ULL * 1024ULL * 1024ULL * (x)) @@ -82,7 +102,8 @@ static
>> uint64_t *alloc_sizes; enum test_type {
>> TYPE_ALL_SIZES,
>> TYPE_RANDOM_SIZE,
>> - TYPE_ARRAY_BIND
>> + TYPE_ARRAY_BIND,
>> + TYPE_THREAD
>> };
>>
>> struct test_case {
>> @@ -129,6 +150,20 @@ struct batch_data {
>> uint32_t data;
>> };
>>
>> +struct thread_data {
>> + uint64_t va_base;
>> + pthread_t thread;
>> + pthread_mutex_t *mutex;
>> + pthread_cond_t *cond;
>> + struct drm_xe_engine_class_instance *hwe;
>> + int fd;
>> + int count;
>> + uint32_t vm;
>> + uint32_t flags;
>> + unsigned int seed;
> seed variable is not used anywhere in this commit.
Will be reused in next series along with rand
>> + bool *go;
>> +};
>> +
>> /*
>> * Reserve a chunk of process address space to use as the VM bind address
>> * for a BO, and hand back a pointer inside it aligned either to bo_size @@ -766,6
>> +801,103 @@ static void alloc_random_size_bos_array_bind(int fd, struct
>> drm_xe_engine_class_
>> free(leaks);
>> }
>>
>> +static void *bo_alloc_thread_fn(void *data) {
>> + struct thread_data *t = data;
>> + uint32_t q;
>> + int i;
>> +
>> + igt_assert(!(t->flags & LEAK_BO));
>> +
>> + pthread_mutex_lock(t->mutex);
>> + while (!*t->go)
>> + pthread_cond_wait(t->cond, t->mutex);
>> + pthread_mutex_unlock(t->mutex);
>> +
>> + q = xe_exec_queue_create(t->fd, t->vm, t->hwe, 0);
>> +
>> + for (i = 0; i < t->count; ++i)
>> + test_alloc_size(t->fd, t->vm, q, t->hwe->gt_id,
>> + alloc_sizes[rand() % N_ALLOC_SIZES], here rand_r(&t->seed) can be used instead of global rand()
>> + t->flags, t->va_base);
> Same va_base is being. t->va_base is set once per thread and never advanced between the 50 iterations.
> threads-rand-sizes-50 is fine as it binds and unbinds+releases after each iteration but for leak it might collide with previous one.
Agreed: Will make changes
>> +
>> + xe_exec_queue_destroy(t->fd, q);
>> +
>> + return NULL;
>> +}
>> +
>> +static void run_threaded_bo_alloc_test(int fd, int count, uint32_t
>> +flags) {
>> + struct drm_xe_engine_class_instance *hwe;
>> + struct drm_xe_engine_class_instance **engines;
>> + struct thread_data *threads_data;
>> + pthread_mutex_t mutex;
>> + pthread_cond_t cond;
>> + bool begin_work = false;
>> + int n_found = 0, n_threads = 0, i, ret;
>> +
>> + xe_for_each_engine(fd, hwe)
>> + n_found++;
>> +
>> + igt_assert(n_found > 0);
>> +
>> + engines = calloc(n_found, sizeof(*engines));
>> + igt_assert(engines);
>> +
>> + i = 0;
>> + xe_for_each_engine(fd, hwe)
>> + engines[i++] = hwe;
>> +
>> + threads_data = calloc(n_found, sizeof(*threads_data));
>> + igt_assert(threads_data);
>> +
>> + pthread_mutex_init(&mutex, 0);
>> + pthread_cond_init(&cond, 0);
>> +
>> + for (i = 0; i < n_found; ++i) {
>> + threads_data[i].mutex = &mutex;
>> + threads_data[i].cond = &cond;
>> + /* reuse engine 0 if only one exists */
>> + threads_data[i].hwe = engines[i % n_found];
> Here i%n_found is not required just i is enough as both are same.
Agreed
>> + threads_data[i].fd = fd;
>> + threads_data[i].count = count;
>> + threads_data[i].vm = xe_vm_create(fd, 0, 0);
>> + threads_data[i].flags = flags;
>> + threads_data[i].go = &begin_work;
>> + threads_data[i].seed = i + 1;
>> + threads_data[i].va_base = BO_BIND_BASE_ADDR + (uint64_t)i *
>> THREAD_VA_STRIDE;
>> + ret = pthread_create(&threads_data[i].thread, 0,
>> bo_alloc_thread_fn,
>> + &threads_data[i]);
>> + if (ret)
>> + break;
>> + n_threads++;
>> + }
>> +
>> + ret = pthread_mutex_lock(&mutex);
>> + igt_assert_eq(ret, 0);
>> + begin_work = true;
>> + ret = pthread_cond_broadcast(&cond);
>> + igt_assert_eq(ret, 0);
>> + ret = pthread_mutex_unlock(&mutex);
>> + igt_assert_eq(ret, 0);
>> +
>> + for (i = 0; i < n_threads; ++i) {
>> + ret = pthread_join(threads_data[i].thread, NULL);
>> + igt_assert_eq(ret, 0);
>> + }
>> +
>> + /* vm is created for every slot up to n_found regardless of thread
>> creation success */
>> + for (i = 0; i < n_found; ++i)
>> + xe_vm_destroy(fd, threads_data[i].vm);
>> +
>> + ret = pthread_cond_destroy(&cond);
>> + igt_assert_eq(ret, 0);
>> + ret = pthread_mutex_destroy(&mutex);
>> + igt_assert_eq(ret, 0);
>> + free(threads_data);
>> + free(engines);
>> +}
>> +
>> static void run_gt_dynamic_subtests(int fd, const struct test_case *t) {
>> struct drm_xe_engine_class_instance *hwe; @@ -849,6 +981,11 @@
>> static const struct test_case test_matrix[] = {
>> { "array-binds-rand-sizes-10", 10, ARRAY_BIND, TYPE_ARRAY_BIND, true
>> },
>> { "array-binds-rand-sizes-10-unaligned", 10, ARRAY_BIND | UNALIGNED,
>> TYPE_ARRAY_BIND,
>> true },
>> + { "threads-rand-sizes-50", 50, 0, TYPE_THREAD, false },
>> + { "threads-rand-sizes-50-unaligned", 50, UNALIGNED, TYPE_THREAD,
>> false },
>> + { "threads-leak-binding-rand-sizes-50", 50, LEAK_BINDING,
>> TYPE_THREAD, false },
>> + { "threads-leak-binding-rand-sizes-50-unaligned", 50, LEAK_BINDING |
>> UNALIGNED,
>> + TYPE_THREAD, false },
>> };
>>
>> int igt_main()
>> @@ -864,6 +1001,16 @@ int igt_main()
>> const struct test_case *t = &test_matrix[i];
>>
>> switch (t->type) {
>> + case TYPE_THREAD:
>> + igt_subtest_f("%s", t->name) {
>> + if (t->requires_evict_ram) {
>> + igt_require(xe_has_vram(fd));
>> + igt_require(igt_get_avail_ram_mb() >=
>> + (xe_visible_vram_size(fd, 0)
>>>> 20) / 2);
>> + }
>> + run_threaded_bo_alloc_test(fd, t->count, t-
>>> flags);
>> + }
>> + break;
>> case TYPE_ALL_SIZES:
>> case TYPE_RANDOM_SIZE:
>> case TYPE_ARRAY_BIND:
>> --
>> 2.52.0
next prev parent reply other threads:[~2026-10-08 10:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 11:04 [PATCH i-g-t v5 0/5] Add BO Allocation and VM Bind stress infra Sobin Thomas
2026-09-22 11:04 ` [PATCH i-g-t v5 1/5] tests/intel: add BO allocation stress coverage Sobin Thomas
2026-10-01 4:52 ` Dandamudi, Priyanka
2026-09-22 11:04 ` [PATCH i-g-t v5 2/5] tests/intel: Add random-size BO leak tests Sobin Thomas
2026-10-01 6:50 ` Dandamudi, Priyanka
2026-10-05 6:15 ` Dandamudi, Priyanka
2026-09-22 11:04 ` [PATCH i-g-t v5 3/5] tests/intel: Add array-of-binds random-size allocation tests Sobin Thomas
2026-10-05 6:20 ` Dandamudi, Priyanka
2026-10-08 13:17 ` Thomas, Sobin
2026-09-22 11:04 ` [PATCH i-g-t v5 4/5] tests/intel: Add threaded random-size allocation stress tests Sobin Thomas
2026-10-05 6:56 ` Dandamudi, Priyanka
2026-10-08 10:35 ` Thomas, Sobin [this message]
2026-09-22 11:04 ` [PATCH i-g-t v5 5/5] tests/intel: Add oversubscribe concurrent bind stress subtest Sobin Thomas
2026-09-29 5:17 ` Sharma, Nishit
2026-10-05 14:34 ` Sharma, Nishit
2026-10-08 10:12 ` Thomas, Sobin
2026-09-23 1:23 ` ✓ i915.CI.BAT: success for Add BO Allocation and VM Bind stress infra (rev4) Patchwork
2026-09-23 2:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-23 15:56 ` ✗ i915.CI.Full: failure " Patchwork
2026-09-23 18:40 ` ✗ Xe.CI.FULL: " 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=82f59c67-6c47-403b-b052-4920bde49fd0@intel.com \
--to=sobin.thomas@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=nishit.sharma@intel.com \
--cc=priyanka.dandamudi@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