Skip to contentSkip to conversation

home/psoham/UPSTREAM/

PATCH Soham Purkait 1 participant 1 message Mar 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

If the engine accuracy test is run with other processes using the DRM device, the GPU engine activity may be higher than expected. Which may lead to false positives in the test, even if the engine activity is reported correctly.
To help identify this issue, a check for other processes using the DRM device is provided and a warning message is printed if any such processes are found and the very test is skipped.

---
 tests/intel/xe_pmu.c | 25 +++++++++++++++++++++++++
 tests/meson.build    |  1 +
 2 files changed, 26 insertions(+)
tests/intel/xe_pmu.c +25 -0
index fb4b871e7..4dd610e8c 100644
@@ -95,6 +95,7 @@
  */
 
 #include "igt.h"
+#include "igt_drm_clients.h"
 #include "igt_perf.h"
 #include "igt_sriov_device.h"
 #include "igt_sysfs.h"
@@ -507,6 +508,30 @@ static void accuracy(int fd, struct drm_xe_engine_class_instance *eci,
 	uint64_t config, before[2], after[2];
 	int link[2], pmu_fd[2];
 	double engine_activity, expected;
+	unsigned long wait = 100000;
+	struct igt_drm_client_proc *procs = NULL;
+	int num_clients = 0;
+
+	/* Wait for other processes using the DRM device ends */
+	for (int pass = 0; pass < 50; pass++) {
+		if (!igt_drm_get_client_procs(fd, getpid(), NULL))
+			break;
+		usleep(wait);
+	}
+
+	num_clients = igt_drm_get_client_procs(fd, getpid(), &procs);
+
+	/* Check if still any process is using the DRM device */
+	if (num_clients) {
+		for (unsigned int i = 0; i < num_clients; i++) {
+			igt_warn("%s (pid=%u client=%lu) is using DRM device.\n",
+				 procs[i].print_name, procs[i].pid, procs[i].id);
+		}
+		free(procs);
+		procs = NULL;
+		igt_skip("As other processes are using the DRM device, "
+			 "cannot ensure the reliability of this test.\n");
+	}
 
 	cycle_us = min_test_us / target_iter;
 	active_us = cycle_us * target_percentage / 100;
tests/meson.build +1 -0
index 79f21c018..d13598fdd 100644
@@ -422,6 +422,7 @@ extra_dependencies = {
 	'sw_sync': [ libatomic ],
 	'xe_fault_injection': [ lib_igt_xe_oa ],
 	'xe_oa': [ lib_igt_xe_oa ],
+	'xe_pmu': [ lib_igt_drm_clients ],
         'xe_compute': [ igt_deps,lib_igt_perf,lib_igt_profiling,math ],
 }
 
Signature · 12 lines
2.43.0

home/psoham/UPSTREAM/v1-0003-HAX-Add-engine-accuracy-tests-to-xe-fast-feedback.patch0000664000175000017500000000172015162511175027040 0ustar  psohampsohamFrom 45d3e5f0c0b46007fb6ac9fb6149328927f8eb1b Mon Sep 17 00:00:00 2001
From: Soham Purkait <[email protected]>
Date: Mon, 16 Mar 2026 14:51:32 +0530
Subject: [PATCH i-g-t v1 3/3] HAX: Add engine accuracy tests to
 xe-fast-feedback.testlist

Signed-off-by: Soham Purkait <[email protected]>
---
 tests/intel-ci/xe.fast-feedback.testlist | 3 +++
 1 file changed, 3 insertions(+)
tests/intel-ci/xe.fast-feedback.testlist +3 -0
index acff025fa..4ab07db77 100644
@@ -163,6 +163,9 @@ igt@xe_mmap@cpu-caching
 igt@xe_mmap@system
 igt@xe_mmap@vram
 igt@xe_mmap@vram-system
+igt@xe_pmu@engine-activity-accuracy-2
+igt@xe_pmu@engine-activity-accuracy-50
+igt@xe_pmu@engine-activity-accuracy-90
 igt@xe_pm_residency@gt-c6-on-idle
 igt@xe_prime_self_import@basic-with_one_bo
 igt@xe_prime_self_import@basic-with_fd_dup
Signature · 21 lines
2.43.0

home/psoham/UPSTREAM/v1-0001-lib-igt_drm_clients-Add-helper-to-list-and-count-.patch0000664000175000017500000000770515162511175027250 0ustar  psohampsohamFrom f8bf09da6e3d9474ff1d7ef0159fcd8667627eba Mon Sep 17 00:00:00 2001
From: Soham Purkait <[email protected]>
Date: Mon, 30 Mar 2026 16:49:38 +0530
Subject: [PATCH i-g-t v1 1/3] lib/igt_drm_clients: Add helper to list and
 count the DRM client processes

Add a helper that scans all DRM clients for a card fd, optionally
populating a list of client processes as an array of
struct igt_drm_client_proc, and always returns the count of client
processes excluding the caller process.

This allows callers (like tests) to find other DRM clients which are
using the card.

Signed-off-by: Soham Purkait <[email protected]>
---
 lib/igt_drm_clients.c | 93 +++++++++++++++++++++++++++++++++++++++++++
 lib/igt_drm_clients.h | 10 +++++
 2 files changed, 103 insertions(+)
lib/igt_drm_clients.c +93 -0

96 lines not on this page · raw message

lib/igt_drm_clients.h +10 -0
index 946d709de..4d47c06f9 100644
@@ -54,6 +54,12 @@ struct igt_drm_client_regions {
 	char **names; /* Array of region names, either auto-detected or from the passed in region map. */
 };
 
+struct igt_drm_client_proc {
+	unsigned int pid;
+	unsigned long id;
+	char print_name[64];
+};
+
 struct igt_drm_clients;
 
 struct igt_drm_client {
@@ -119,4 +125,8 @@ struct igt_drm_clients *
 igt_drm_clients_sort(struct igt_drm_clients *clients,
 		     int (*cmp)(const void *, const void *, void *));
 
+int igt_drm_get_client_procs(int card_fd,
+			     pid_t self_pid,
+			     struct igt_drm_client_proc **procs);
+
 #endif /* IGT_DRM_CLIENTS_H */
Signature · 34 lines
2.43.0

home/psoham/UPSTREAM/v1-0000-cover-letter.patch0000664000175000017500000000244415162512676020453 0ustar  psohampsohamFrom 45d3e5f0c0b46007fb6ac9fb6149328927f8eb1b Mon Sep 17 00:00:00 2001
From: Soham Purkait <[email protected]>
Date: Mon, 30 Mar 2026 20:40:53 +0530
Subject: [PATCH i-g-t v1 0/3] tests/intel/xe_pmu: Guard engine accuracy tests against busy DRM clients

The engine-activity accuracy subtests are sensitive to unrelated
DRM clients on the same card. When other processes keep the device busy,
the measured engine activity can be higher than expected and trigger
false failures.

This series improves the robustness of the subtest by first introducing
a helper to enumerate DRM client processes associated with a given card
fd, and subsequently using it in engine accuracy tests to detect competing
clients triggering a warning, and skipping the test.

Soham Purkait (3):
  lib/igt_drm_clients: Add helper to list and count the DRM client
    processes
  tests/intel/xe_pmu: Check if other processes are using the DRM device
  HAX: Add engine accuracy tests to xe-fast-feedback.testlist

 lib/igt_drm_clients.c                    | 93 ++++++++++++++++++++++++
 lib/igt_drm_clients.h                    | 10 +++
 tests/intel-ci/xe.fast-feedback.testlist |  3 +
 tests/intel/xe_pmu.c                     | 25 +++++++
 tests/meson.build                        |  1 +
 5 files changed, 132 insertions(+)

-- 
2.43.0