[PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault

Lucas De Marchi lucas.demarchi at intel.com
Thu Jan 23 17:37:57 UTC 2025


On Thu, Jan 23, 2025 at 11:34:36AM -0600, Lucas De Marchi wrote:
>On Thu, Jan 23, 2025 at 10:22:10AM +0100, Zbigniew Kempczyński wrote:
>>This test is likely only for checking purposes, it doesn't makes
>>sense to merge it after series review.
>>
>>Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
>>Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>>Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
>>---
>>tests/intel-ci/xe-fast-feedback.testlist |  1 +
>>tests/intel/xe_intel_bb.c                | 47 ++++++++++++++++++++++++
>>2 files changed, 48 insertions(+)
>>
>>diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
>>index 0234d3e72d..7adb9a3436 100644
>>--- a/tests/intel-ci/xe-fast-feedback.testlist
>>+++ b/tests/intel-ci/xe-fast-feedback.testlist
>>@@ -7,6 +7,7 @@ igt at fbdev@nullptr
>>igt at fbdev@read
>>igt at fbdev@write
>>
>>+igt at xe_intel_bb@multithread-open
>>igt at kms_addfb_basic@addfb25-4-tiled
>>igt at kms_addfb_basic@addfb25-bad-modifier
>>igt at kms_addfb_basic@addfb25-modifier-no-flag
>>diff --git a/tests/intel/xe_intel_bb.c b/tests/intel/xe_intel_bb.c
>>index 845052bf26..5df009f9ed 100644
>>--- a/tests/intel/xe_intel_bb.c
>>+++ b/tests/intel/xe_intel_bb.c
>>@@ -18,6 +18,7 @@
>>
>>#include "igt.h"
>>#include "igt_crc.h"
>>+#include "igt_device_scan.h"
>>#include "intel_blt.h"
>>#include "intel_bufops.h"
>>#include "intel_mocs.h"
>>@@ -950,6 +951,49 @@ static int render(struct buf_ops *bops, uint32_t tiling,
>>	return fails;
>>}
>>
>>+/**
>>+ * SUBTEST: multithread-open
>>+ * Description: check device scanning when multiple threads are involved
>>+ */
>>+static void *__single_open(void *data)
>>+{
>>+	struct igt_device_card card;
>>+	int fd;
>>+
>>+	igt_info("Thread: %d\n", (int)to_user_pointer(data));
>>+
>>+	for (int i = 0; i < 5; i++)
>>+		igt_devices_scan();
>>+
>>+	igt_assert_eq(igt_device_card_match("pci:vendor=intel", &card), true);
>>+	igt_info("Device detail: %s, %s, %s\n", card.subsystem, card.card, card.render);
>>+
>>+	fd = igt_open_card(&card);
>
>can you point what test needs this? In this scenario, don't we usually
>use igt_fork() for the tests?

I re-read patch 2 and they are mentioned there. Yeah, makes sense.

Lucas De Marchi

>
>Lucas De Marchi
>
>>+	igt_info("Fd: %d\n", fd);
>>+	igt_assert(fd >= 0);
>>+	close(fd);
>>+
>>+	return NULL;
>>+}
>>+
>>+#define NUM_THREADS 100
>>+static void multithread_open(void)
>>+{
>>+	pthread_t pth[NUM_THREADS];
>>+	int i, ret;
>>+
>>+	for (i = 0; i < NUM_THREADS; i++) {
>>+		ret = pthread_create(&pth[i], NULL, __single_open,
>>+				     from_user_pointer(i));
>>+		igt_assert_eq(ret, 0);
>>+	}
>>+
>>+	for (i = 0; i < NUM_THREADS; i++) {
>>+		ret = pthread_join(pth[i], NULL);
>>+		igt_assert_eq(ret, 0);
>>+	}
>>+}
>>+
>>static int opt_handler(int opt, int opt_index, void *data)
>>{
>>	switch (opt) {
>>@@ -1063,6 +1107,9 @@ igt_main_args("dpib", NULL, help_str, opt_handler, NULL)
>>		}
>>	}
>>
>>+	igt_subtest("multithread-open")
>>+		multithread_open();
>>+
>>	igt_fixture {
>>		buf_ops_destroy(bops);
>>		drm_close_driver(xe);
>>-- 
>>2.34.1
>>


More information about the igt-dev mailing list