[PATCH i-g-t 1/8] tests/intel/xe_drm_fdinfo: Update basic test to include client utilization

Lucas De Marchi lucas.demarchi at intel.com
Mon Jul 1 16:52:20 UTC 2024


On Sat, Jun 22, 2024 at 07:00:55AM GMT, Umesh Nerlige Ramappa wrote:
>Add per client utilization related checks to basic test.
>
>Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
>---
> tests/intel/xe_drm_fdinfo.c | 40 +++++++++++++++++++++++++++++++------
> 1 file changed, 34 insertions(+), 6 deletions(-)
>
>diff --git a/tests/intel/xe_drm_fdinfo.c b/tests/intel/xe_drm_fdinfo.c
>index 2ceafba24..e624029b8 100644
>--- a/tests/intel/xe_drm_fdinfo.c
>+++ b/tests/intel/xe_drm_fdinfo.c
>@@ -14,11 +14,11 @@
> #include "xe/xe_spin.h"
> /**
>  * TEST: xe drm fdinfo
>- * Description: Read and verify drm client memory consumption using fdinfo
>+ * Description: Read and verify drm client memory consumption and engine utilization using fdinfo
>  * Category: Core
>  * Mega feature: General Core features
>  * Sub-category: driver
>- * Functionality: Per client memory statistics
>+ * Functionality: Per client memory and engine utilization statistics
>  * Feature: SMI, core
>  * Test category: SysMan
>  *
>@@ -35,10 +35,17 @@
>  * Description: Create and compare active memory consumption by client
>  */
>
>-IGT_TEST_DESCRIPTION("Read and verify drm client memory consumption using fdinfo");
>+IGT_TEST_DESCRIPTION("Read and verify drm client memory consumption and engine utilization using fdinfo");
>
> #define BO_SIZE (65536)
>
>+static const char *engine_map[] = {
>+	"rcs",
>+	"bcs",
>+	"vcs",
>+	"vecs",
>+	"ccs",
>+};
> /* Subtests */
> static void test_active(int fd, struct drm_xe_engine *engine)
> {
>@@ -259,18 +266,21 @@ static void test_total_resident(int xe)
> 	xe_vm_destroy(xe, vm);
> }
>
>-static void basic(int xe)
>+static void basic(int xe, unsigned int num_classes)
> {
> 	struct drm_xe_mem_region *memregion;
> 	uint64_t memreg = all_memory_regions(xe), region;
> 	struct drm_client_fdinfo info = { };
> 	unsigned int ret;
>
>-	ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
>+	ret = igt_parse_drm_fdinfo(xe, &info, engine_map,
>+				   ARRAY_SIZE(engine_map), NULL, 0);
> 	igt_assert_f(ret != 0, "failed with err:%d\n", errno);
>
> 	igt_assert(!strcmp(info.driver, "xe"));
>
>+	igt_assert_eq(info.num_engines, num_classes);

I don't think they need to match... I think this is more asserting the current
SW behavior (engines exposed to userspace always have an entry in
fdinfo) rather than what we could/should be doing.

Lucas De Marchi


>+
> 	xe_for_each_mem_region(xe, memreg, region) {
> 		memregion = xe_mem_region(xe, region);
> 		igt_assert(info.region_mem[memregion->instance + 1].total >=
>@@ -289,19 +299,37 @@ static void basic(int xe)
>
> igt_main
> {
>+	struct drm_xe_engine_class_instance *hwe;
>+	unsigned int num_engines = 0, num_classes = 0;
>+	unsigned int classes[16] = { };
> 	int xe;
>
> 	igt_fixture {
> 		struct drm_client_fdinfo info = { };
>+		unsigned int i;
>
> 		xe = drm_open_driver(DRIVER_XE);
> 		igt_require_xe(xe);
> 		igt_require(igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0));
>+		igt_require(info.num_engines);
>+
>+		xe_for_each_engine(xe, hwe) {
>+			num_engines++;
>+			igt_assert(hwe->engine_class < ARRAY_SIZE(classes));
>+			classes[hwe->engine_class]++;
>+		}
>+		igt_require(num_engines);
>+
>+		for (i = 0; i < ARRAY_SIZE(classes); i++) {
>+			if (classes[i])
>+				num_classes++;
>+		}
>+		igt_assert(num_classes);
> 	}
>
> 	igt_describe("Check if basic fdinfo content is present");
> 	igt_subtest("basic")
>-		basic(xe);
>+		basic(xe, num_classes);
>
> 	igt_describe("Create and compare total and resident memory consumption by client");
> 	igt_subtest("drm-total-resident")
>-- 
>2.34.1
>


More information about the igt-dev mailing list