Skip to contentSkip to conversation

tests/xe: Add tests to read and verify fdinfo

igt-dev Tejas Upadhyay 3 participants 7 messages Sep 4, 2023 – Sep 8, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

This test verifies fdinfo published by xe KMD with following tests :
@basic
@drm-total-residents
@drm-shared
@drm-active

TODO : drm-purgeable test is not possbile as we consider objects in system memory to be purgeable but current xe KMD does not allow BOs to be created in system memory (instead KMD creates it in XE_PL_TT which is VRAM backed system memory).

---
 tests/intel/xe_drm_fdinfo.c | 285 ++++++++++++++++++++++++++++++++++++
 tests/meson.build           |   1 +
 2 files changed, 286 insertions(+)
 create mode 100644 tests/intel/xe_drm_fdinfo.c
tests/intel/xe_drm_fdinfo.c new file +285 -0
new file mode 100644
index 000000000..4f9dcdb66
@@ -0,0 +1,285 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_core.h"
+#include "igt_device.h"
+#include "igt_drm_fdinfo.h"
+#include "lib/igt_syncobj.h"
+#include "xe_drm.h"
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
+#include "xe/xe_spin.h"
+/**
+ * TEST: xe drm fdinfo
+ * Description: Read and verify drm client memory consumption using fdinfo
+ * Feature: SMI, core
+ *
+ * SUBTEST: basic
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Check if basic fdinfo content is present
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-total-resident
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare total and resident memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-shared
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare shared memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-shared
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare shared memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-active
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare active memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ */
+
+IGT_TEST_DESCRIPTION("Read and verify drm client memory consumption using fdinfo");
+
+/* Subtests */
+static void test_active(int fd, struct drm_xe_engine_class_instance *eci)
+{
+        struct drm_client_fdinfo info = { };
+	uint32_t vm;
+        uint64_t addr = 0x1a0000;
+        struct drm_xe_sync sync[2] = {
+                { .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+                { .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+        };
+        struct drm_xe_exec exec = {
+                .num_batch_buffer = 1,
+                .num_syncs = 2,
+                .syncs = to_user_pointer(sync),
+        };
+#define N_EXEC_QUEUES   2
+        uint32_t exec_queues[N_EXEC_QUEUES];
+        uint32_t bind_exec_queues[N_EXEC_QUEUES];
+        uint32_t syncobjs[N_EXEC_QUEUES + 1];
+        size_t bo_size;
+        uint32_t bo = 0;
+	int region = 0x2; /* VRAM 0 */
+        struct {
+                struct xe_spin spin;
+                uint32_t batch[16];
+                uint64_t pad;
+                uint32_t data;
+        } *data;
+        int i, b;
+
+        vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+        bo_size = sizeof(*data) * N_EXEC_QUEUES;
+        bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+                        xe_get_default_alignment(fd));
+        bo = xe_bo_create_flags(fd, vm, bo_size,
+                                region);
+        data = xe_bo_map(fd, bo, bo_size);
+
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                exec_queues[i] = xe_exec_queue_create(fd, vm, eci, 0);
+                bind_exec_queues[i] = xe_bind_exec_queue_create(fd, vm, 0);
+                syncobjs[i] = syncobj_create(fd, 0);
+        }
+        syncobjs[N_EXEC_QUEUES] = syncobj_create(fd, 0);
+
+        sync[0].handle = syncobj_create(fd, 0);
+        xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr, bo_size,
+                         sync, 1);
+
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                uint64_t spin_offset = (char *)&data[i].spin - (char *)data;
+                uint64_t spin_addr = addr + spin_offset;
+                int e = i;
+
+                if (i == 0) {
+                        xe_spin_init(&data[i].spin, spin_addr, true);
+                        exec.exec_queue_id = exec_queues[e];
+                        exec.address = spin_addr;
+                        sync[0].flags &= ~DRM_XE_SYNC_SIGNAL;
+                        sync[1].flags |= DRM_XE_SYNC_SIGNAL;
+                        sync[1].handle = syncobjs[e];
+                        xe_exec(fd, &exec);
+                        xe_spin_wait_started(&data[i].spin);
+
+                        addr += bo_size;
+                        sync[1].flags &= ~DRM_XE_SYNC_SIGNAL;
+                        sync[1].handle = syncobjs[e];
+                        xe_vm_bind_async(fd, vm, bind_exec_queues[e], bo, 0, addr,
+                                         bo_size, sync + 1, 1);
+                        addr += bo_size;
+                } else {
+                        sync[0].flags |= DRM_XE_SYNC_SIGNAL;
+                        xe_vm_bind_async(fd, vm, bind_exec_queues[e], bo, 0, addr,
+                                         bo_size, sync, 1);
+                }
+
+		b = igt_parse_drm_fdinfo(fd, &info, NULL, 0, NULL, 0);
+		igt_assert(b);
+
+		/* Client memory consumption includes public objects
+		 * as well as internal objects hence if bo is active on
+		 * N_EXEC_QUEUES consumption should be
+		 * >= bo_size + bo_size * N_EXEC_QUEUES */
+		printf("info.total:%ld active:%ld bo_size:%ld\n",
+		       info.region_mem[region].total,
+		       info.region_mem[region].active, bo_size);
+		igt_assert(info.region_mem[region].active >=
+			      bo_size + bo_size * N_EXEC_QUEUES);
+        }
+	xe_spin_end(&data[0].spin);
+
+	syncobj_destroy(fd, sync[0].handle);
+        sync[0].handle = syncobj_create(fd, 0);
+        sync[0].flags |= DRM_XE_SYNC_SIGNAL;
+        xe_vm_unbind_all_async(fd, vm, 0, bo, sync, 1);
+        igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
+
+        syncobj_destroy(fd, sync[0].handle);
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                syncobj_destroy(fd, syncobjs[i]);
+                xe_exec_queue_destroy(fd, exec_queues[i]);
+                xe_exec_queue_destroy(fd, bind_exec_queues[i]);
+        }
+
+        munmap(data, bo_size);
+        gem_close(fd, bo);
+        xe_vm_destroy(fd, vm);
+}
+
+static void test_shared(int xe)
+{
+        struct drm_client_fdinfo info = { };
+        struct drm_gem_flink flink;
+        struct drm_gem_open open_struct;
+	uint32_t bo;
+	int region = 0x1;
+        int ret;
+
+	bo = xe_bo_create_flags(xe, 0, 4096, region);
+
+        flink.handle = bo;
+        ret = igt_ioctl(xe, DRM_IOCTL_GEM_FLINK, &flink);
+        igt_assert_eq(ret, 0);
+
+        open_struct.name = flink.name;
+        ret = igt_ioctl(xe, DRM_IOCTL_GEM_OPEN, &open_struct);
+        igt_assert_eq(ret, 0);
+        igt_assert(open_struct.handle != 0);
+
+	ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+	igt_assert(ret);
+
+	printf("info.total:%ld shared:%ld\n",
+			info.region_mem[region].total,
+			info.region_mem[region].shared);
+	igt_assert_eq(info.region_mem[region].shared,
+			2 * 4096);
+
+	gem_close(xe, bo);
+}
+
+static void test_total_resident(int xe)
+{
+        struct drm_xe_query_mem_region *memregion;
+        uint64_t memreg = all_memory_regions(xe), region;
+        struct drm_client_fdinfo info = { };
+        uint32_t vm;
+        uint32_t handle;
+	uint64_t addr = 0x1a0000;
+        int ret;
+
+        vm = xe_vm_create(xe, DRM_XE_VM_CREATE_SCRATCH_PAGE, 0);
+
+        xe_for_each_mem_region(xe, memreg, region) {
+                memregion = xe_mem_region(xe, region);
+
+		handle = xe_bo_create_flags(xe, vm, memregion->min_page_size, region);
+		xe_vm_bind_sync(xe, vm, handle, 0, addr, memregion->min_page_size);
+
+		ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+		igt_assert(ret);
+		/* currently xe KMD maps I915_MEMORY_CLASS_SYSTEM region to
+		 * XE_PL_TT thus we need memregion->instance + 1 */
+		printf("info.total:%ld resident:%ld for instance: %d bo_size:%d\n",
+		       info.region_mem[memregion->instance + 1].total,
+		       info.region_mem[memregion->instance + 1].resident,
+		       memregion->instance, memregion->min_page_size);
+		/* Client memory consumption includes public objects
+		 * as well as internal objects hence it should be
+		 * >= memregion->min_page_size */
+		igt_assert(info.region_mem[memregion->instance + 1].total >=
+			   memregion->min_page_size);
+		igt_assert(info.region_mem[memregion->instance + 1].resident >=
+			   memregion->min_page_size);
+		xe_vm_unbind_sync(xe, vm, 0, addr, memregion->min_page_size);
+		gem_close(xe, handle);
+        }
+
+        xe_vm_destroy(xe, vm);
+}
+
+static void basic(int xe)
+{
+        struct drm_client_fdinfo info = { };
+        unsigned int ret;
+
+        ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+        igt_assert(ret);
+
+        igt_assert(!strcmp(info.driver, "xe"));
+}
+
+igt_main
+{
+        int xe;
+
+        igt_fixture {
+                struct drm_client_fdinfo info = { };
+
+		xe = drm_open_driver(DRIVER_XE);
+		igt_require_xe(xe);
+                igt_require(igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0));
+        }
+
+	igt_describe("Check if basic fdinfo content is present");
+        igt_subtest("basic")
+                basic(xe);
+
+	igt_describe("Create and compare total and resident memory consumption by client");
+        igt_subtest("drm-total-resident")
+                test_total_resident(xe);
+
+	igt_describe("Create and compare shared memory consumption by client");
+	igt_subtest("drm-shared")
+                test_shared(xe);
+
+	igt_describe("Create and compare active memory consumption by client");
+	igt_subtest("drm-active")
+		test_active(xe, xe_hw_engine(xe, 0));
+
+	igt_fixture
+                drm_close_driver(xe);
+}
tests/meson.build +1 -0
index aa8e3434c..f5f495050 100644
@@ -275,6 +275,7 @@ intel_xe_progs = [
 	'xe_compute',
 	'xe_dma_buf_sync',
 	'xe_debugfs',
+	'xe_drm_fdinfo',
 	'xe_evict',
 	'xe_exec_balancer',
 	'xe_exec_basic',
Signature · 1 line
2.25.1
#1 lore raw

[igt-dev] ✗ GitLab.Pipeline: warning for tests/xe: Add tests to read and verify fdinfo

== Series Details ==

== Series Details ==

Series: tests/xe: Add tests to read and verify fdinfo
URL : https://patchwork.freedesktop.org/series/123249/
State : warning

== Summary ==

Pipeline status: FAILED.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/977355 for the overview.

build-containers:build-debian has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/48488920):
section_end:1693833733:prepare_executor
section_start:1693833733:prepare_script
Preparing environment
Running on runner-m5dzqx4r-project-3185-concurrent-0 via 15ca4cde06bd... section_end:1693833734:prepare_script
section_start:1693833734:get_sources
Getting source from Git repository

  $ /host/bin/curl -s -L --cacert /host/ca-certificates.crt --retry 4 -f --retry-delay 60 https://gitlab.freedesktop.org/freedesktop/helm-gitlab-infra/-/raw/main/runner-gating/runner-gating.sh | sh -s -- pre_get_sources_script
  Checking if the user of the pipeline is allowed...
  Checking if the job's project is part of a well-known group...
  Thank you for contributing to freedesktop.org
  Fetching changes...
  Reinitialized existing Git repository in /builds/gfx-ci/igt-ci-tags/.git/
  fatal: unable to access 'https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags.git/': Failed to connect to gitlab.freedesktop.org port 443 after 128842 ms: Couldn't connect to server
  section_end:1693833864:get_sources
  section_start:1693833864:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1693833864:cleanup_file_variables
  ERROR: Job failed: exit code 1

build-containers:build-debian-arm64 has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/48488922):
time="2023-09-04T13:22:48Z" level=fatal msg="pinging docker registry returned: Get https://registry.freedesktop.org/v2/: dial tcp 147.75.198.156:443: i/o timeout"
Building!
STEP 1: FROM debian:buster
Getting image source signatures
Copying blob sha256:d6b7393fb4f375905c31c483d81ce2a2905f88aba8cb198874da2b54035bc41d
Copying config sha256:de08540e8ff0e470ff7956df4bed403725a5f45c186e9bf495da5344ff8fbe84
Writing manifest to image destination
Storing signatures
STEP 2: RUN apt-get update
error running container: error creating container for [/bin/sh -c apt-get update]: time="2023-09-04T13:22:52Z" level=warning msg="signal: killed"
time="2023-09-04T13:22:52Z" level=error msg="container_linux.go:346: starting container process caused \"process_linux.go:297: applying cgroup configuration for process caused \\\"mountpoint for cgroup not found\\\"\"\n" container_linux.go:346: starting container process caused "process_linux.go:297: applying cgroup configuration for process caused \"mountpoint for cgroup not found\""
: exit status 1
Error: error building at STEP "RUN apt-get update": error while running runtime: exit status 1
section_end:1693833773:step_script
section_start:1693833773:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1693833773:cleanup_file_variables
ERROR: Job failed: exit code 1

build-containers:build-debian-armhf has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/48488921):

      "DockerVersion": "",
      "Labels": {},
      "Architecture": "amd64",
      "Os": "linux",
      "Layers": [
          "sha256:45252bb38c9c74dfe76c4b3808269db61d3b2aebe5e26bf7fcd85e48b93e16f9"
      ]

}
Skipping, already built
Getting image source signatures
Copying blob sha256:45252bb38c9c74dfe76c4b3808269db61d3b2aebe5e26bf7fcd85e48b93e16f9
Copying config sha256:4a4103f1a476d355d866b481ff96ac05a32a3a715cefcc1cbc1356a8959fb5f8
Writing manifest to image destination
time="2023-09-04T13:23:01Z" level=fatal msg="Error writing manifest: Put https://registry.freedesktop.org/v2/gfx-ci/igt-ci-tags/build-debian-armhf/manifests/commit-b46d794a03b73bf8ab877c7240b58f1e17575fd2: dial tcp: lookup registry.freedesktop.org on 147.75.207.208:53: read udp 10.88.199.218:53108->147.75.207.208:53: i/o timeout" section_end:1693833782:step_script
section_start:1693833782:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1693833782:cleanup_file_variables
ERROR: Job failed: exit code 1

build-containers:build-debian-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/48488923):
time="2023-09-04T13:23:03Z" level=fatal msg="Error determining repository tags: Get https://registry.freedesktop.org/v2/gfx-ci/igt-ci-tags/build-debian-mips/tags/list?last=commit-86ad7feeadba42668b7d8f1c822526515a0767a8&n=100: dial tcp 147.75.198.156:443: i/o timeout" Building!
STEP 1: FROM debian:buster
Getting image source signatures
Copying blob sha256:d6b7393fb4f375905c31c483d81ce2a2905f88aba8cb198874da2b54035bc41d
Copying config sha256:de08540e8ff0e470ff7956df4bed403725a5f45c186e9bf495da5344ff8fbe84
Writing manifest to image destination
Storing signatures
STEP 2: RUN apt-get update
error running container: error creating container for [/bin/sh -c apt-get update]: time="2023-09-04T13:23:22Z" level=warning msg="signal: killed"
time="2023-09-04T13:23:22Z" level=error msg="container_linux.go:346: starting container process caused \"process_linux.go:297: applying cgroup configuration for process caused \\\"mountpoint for cgroup not found\\\"\"\n" container_linux.go:346: starting container process caused "process_linux.go:297: applying cgroup configuration for process caused \"mountpoint for cgroup not found\""
: exit status 1
Error: error building at STEP "RUN apt-get update": error while running runtime: exit status 1
section_end:1693833803:step_script
section_start:1693833803:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1693833803:cleanup_file_variables
ERROR: Job failed: exit code 1

build-containers:build-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/48488924):
time="2023-09-04T13:22:55Z" level=fatal msg="Error determining repository tags: Get https://registry.freedesktop.org/v2/gfx-ci/igt-ci-tags/build-fedora/tags/list?last=commit-2824470eeed46d448ccc8111f96736da3abe66b5&n=100: dial tcp 147.75.198.156:443: i/o timeout" Building!
STEP 1: FROM fedora:31
Getting image source signatures
Copying blob sha256:c28ace6b0c4ae099f6f81091731bdf41d9771d28bad96ae4a3507fe950560930
Copying config sha256:a7a37f74ff864eec55891b64ad360d07020827486e30a92ea81d16459645b26a
Writing manifest to image destination
Storing signatures
STEP 2: RUN dnf install -y gcc flex bison libatomic meson ninja-build xdotool 'pkgconfig(libdrm)' 'pkgconfig(pciaccess)' 'pkgconfig(libkmod)' 'pkgconfig(libprocps)' 'pkgconfig(libunwind)' 'pkgconfig(libdw)' 'pkgconfig(pixman-1)' 'pkgconfig(valgrind)' 'pkgconfig(cairo)' 'pkgconfig(libudev)' 'pkgconfig(glib-2.0)' 'pkgconfig(gsl)' 'pkgconfig(alsa)' 'pkgconfig(xmlrpc)' 'pkgconfig(xmlrpc_util)' 'pkgconfig(xmlrpc_client)' 'pkgconfig(json-c)' 'pkgconfig(gtk-doc)' 'pkgconfig(xv)' 'pkgconfig(xrandr)' python3-docutils
error running container: error creating container for [/bin/sh -c dnf install -y gcc flex bison libatomic meson ninja-build xdotool 'pkgconfig(libdrm)' 'pkgconfig(pciaccess)' 'pkgconfig(libkmod)' 'pkgconfig(libprocps)' 'pkgconfig(libunwind)' 'pkgconfig(libdw)' 'pkgconfig(pixman-1)' 'pkgconfig(valgrind)' 'pkgconfig(cairo)' 'pkgconfig(libudev)' 'pkgconfig(glib-2.0)' 'pkgconfig(gsl)' 'pkgconfig(alsa)' 'pkgconfig(xmlrpc)' 'pkgconfig(xmlrpc_util)' 'pkgconfig(xmlrpc_client)' 'pkgconfig(json-c)' 'pkgconfig(gtk-doc)' 'pkgconfig(xv)' 'pkgconfig(xrandr)' python3-docutils]: time="2023-09-04T13:23:43Z" level=warning msg="signal: killed"
time="2023-09-04T13:23:43Z" level=error msg="container_linux.go:346: starting container process caused \"process_linux.go:297: applying cgroup configuration for process caused \\\"mountpoint for cgroup not found\\\"\"\n" container_linux.go:346: starting container process caused "process_linux.go:297: applying cgroup configuration for process caused \"mountpoint for cgroup not found\""
: exit status 1
Error: error building at STEP "RUN dnf install -y gcc flex bison libatomic meson ninja-build xdotool 'pkgconfig(libdrm)' 'pkgconfig(pciaccess)' 'pkgconfig(libkmod)' 'pkgconfig(libprocps)' 'pkgconfig(libunwind)' 'pkgconfig(libdw)' 'pkgconfig(pixman-1)' 'pkgconfig(valgrind)' 'pkgconfig(cairo)' 'pkgconfig(libudev)' 'pkgconfig(glib-2.0)' 'pkgconfig(gsl)' 'pkgconfig(alsa)' 'pkgconfig(xmlrpc)' 'pkgconfig(xmlrpc_util)' 'pkgconfig(xmlrpc_client)' 'pkgconfig(json-c)' 'pkgconfig(gtk-doc)' 'pkgconfig(xv)' 'pkgconfig(xrandr)' python3-docutils": error while running runtime: exit status 1
section_end:1693833823:step_script
section_start:1693833823:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1693833823:cleanup_file_variables
ERROR: Job failed: exit code 1

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/977355

#2 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for tests/xe: Add tests to read and verify fdinfo

In reply to Tejas Upadhyay
== Series Details ==

== Series Details ==

Series: tests/xe: Add tests to read and verify fdinfo
URL : https://patchwork.freedesktop.org/series/123249/
State : failure

== Summary ==

CI Bug Log - changes from IGT_7467 -> IGTPW_9711
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_9711 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_9711, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/index.html

Participating hosts (39 -> 37)
------------------------------

Missing (2): fi-hsw-4770 fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_9711:

### IGT changes ###

#### Possible regressions ####

* igt@i915_module_load@load:
- bat-adlp-11: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-adlp-11/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-adlp-11/igt@[email protected]

Known issues
------------

Here are the changes found in IGTPW_9711 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_module_load@reload:
- fi-apl-guc: [PASS][3] -> [DMESG-WARN][4] ([i915#180] / [i915#1982] / [i915#7634])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/fi-apl-guc/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/fi-apl-guc/igt@[email protected]

* igt@i915_pm_rpm@basic-pci-d3-state:
- bat-adlp-11: NOTRUN -> [ABORT][5] ([i915#7977] / [i915#8469] / [i915#8668])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-adlp-11/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-apl-guc: [PASS][6] -> [DMESG-WARN][7] ([i915#180] / [i915#7634] / [i915#8585])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/fi-apl-guc/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/fi-apl-guc/igt@[email protected]

* igt@i915_selftest@live@reset:
- fi-apl-guc: [PASS][8] -> [DMESG-WARN][9] ([i915#7634]) +36 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/fi-apl-guc/igt@i915_selftest@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/fi-apl-guc/igt@i915_selftest@[email protected]

* igt@i915_suspend@basic-s2idle-without-i915:
- fi-apl-guc: [PASS][10] -> [DMESG-WARN][11] ([i915#180] / [i915#7634])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/fi-apl-guc/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/fi-apl-guc/igt@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@a-dp6:
- bat-adlp-11: [PASS][12] -> [FAIL][13] ([i915#6121]) +5 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-adlp-11/igt@kms_flip@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-adlp-11/igt@kms_flip@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@b-dp5:
- bat-adlp-11: [PASS][14] -> [DMESG-WARN][15] ([i915#6868])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-adlp-11/igt@kms_flip@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-adlp-11/igt@kms_flip@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence:
- bat-dg2-11: NOTRUN -> [SKIP][16] ([i915#1845])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-dg2-11/igt@[email protected]

* igt@kms_psr@primary_page_flip:
- bat-rplp-1: NOTRUN -> [ABORT][17] ([i915#8442] / [i915#8668] / [i915#8860])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-rplp-1/igt@kms_psr@primary_page_flip.html

#### Possible fixes ####

* igt@gem_exec_suspend@basic-s0@smem:
- bat-dg2-9: [INCOMPLETE][18] ([i915#6311]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-dg2-9/igt@gem_exec_suspend@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-dg2-9/igt@gem_exec_suspend@[email protected]

* igt@kms_chamelium_edid@hdmi-edid-read:
- {bat-dg2-13}: [DMESG-WARN][20] ([i915#7952]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-dg2-13/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-dg2-13/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [ABORT][22] ([i915#8442] / [i915#8668]) -> [PASS][23]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]

#### Warnings ####

* igt@i915_pm_backlight@basic-brightness:
- bat-adlp-11: [ABORT][24] ([i915#8668]) -> [SKIP][25] ([i915#3546] / [i915#7561])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7467/bat-adlp-11/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/bat-adlp-11/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#6121]: https://gitlab.freedesktop.org/drm/intel/issues/6121
[i915#6311]: https://gitlab.freedesktop.org/drm/intel/issues/6311
[i915#6868]: https://gitlab.freedesktop.org/drm/intel/issues/6868
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7634]: https://gitlab.freedesktop.org/drm/intel/issues/7634
[i915#7952]: https://gitlab.freedesktop.org/drm/intel/issues/7952
[i915#7977]: https://gitlab.freedesktop.org/drm/intel/issues/7977
[i915#8442]: https://gitlab.freedesktop.org/drm/intel/issues/8442
[i915#8469]: https://gitlab.freedesktop.org/drm/intel/issues/8469
[i915#8585]: https://gitlab.freedesktop.org/drm/intel/issues/8585
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#8860]: https://gitlab.freedesktop.org/drm/intel/issues/8860

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_7467 -> IGTPW_9711

CI-20190529: 20190529
CI_DRM_13593: 70c5bfd28eab769b048876075fc3561c3f04a54a @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9711: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/index.html
IGT_7467: 7467

Testlist changes
----------------

+igt@xe_drm_fdinfo@basic
+igt@xe_drm_fdinfo@drm-active
+igt@xe_drm_fdinfo@drm-shared
+igt@xe_drm_fdinfo@drm-total-resident
-igt@xe_copy_basic@mem-copy
-igt@xe_copy_basic@mem-set

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/index.html

#3 lore raw

[igt-dev] ✓ CI.xeBAT: success for tests/xe: Add tests to read and verify fdinfo

In reply to Tejas Upadhyay
== Series Details ==

== Series Details ==

Series: tests/xe: Add tests to read and verify fdinfo
URL : https://patchwork.freedesktop.org/series/123249/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7467_BAT -> XEIGTPW_9711_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (4 -> 4)
------------------------------

No changes in participating hosts

Known issues
------------

Here are the changes found in XEIGTPW_9711_BAT that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_flip@basic-flip-vs-wf_vblank@d-edp1:
- bat-adlp-7: [PASS][1] -> [FAIL][2] ([Intel XE#480]) +1 similar issue
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7467/bat-adlp-7/igt@kms_flip@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9711/bat-adlp-7/igt@kms_flip@[email protected]

[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480

Build changes
-------------

* IGT: IGT_7467 -> IGTPW_9711

IGTPW_9711: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9711/index.html
IGT_7467: 7467
xe-354-7ec520d3a63b6e95174329108cd44359a70907ba: 7ec520d3a63b6e95174329108cd44359a70907ba

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9711/index.html

#4 lore raw

[Intel-xe] ✗ CI.Patch_applied: failure for tests/xe: Add tests to read and verify fdinfo

In reply to Tejas Upadhyay
== Series Details ==

== Series Details ==

Series: tests/xe: Add tests to read and verify fdinfo
URL : https://patchwork.freedesktop.org/series/123248/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: === Base commit: 7ec520d3a drm/xe/selftests: make eviction test tile centric === git am output follows ===
error: tests/meson.build: does not exist in index
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: tests/xe: Add tests to read and verify fdinfo Patch failed at 0001 tests/xe: Add tests to read and verify fdinfo When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

#5 lore raw
In reply to Tejas Upadhyay

Hi Tejas,

Quoted 1 line · Tejas Upadhyay

This test verifies fdinfo published by xe KMD with

-- ^^^^^^^^^^^^^^^^^
Added tests to verify

Quoted 1 line

following tests :

------------^ ---^
s/tests :/subtests:/

Quoted 6 lines

@basic
@drm-total-residents
@drm-shared
@drm-active

TODO : drm-purgeable test is not possbile as we consider objects in

----- ^
Remove space before ':'

Quoted 51 lines

system memory to be purgeable but current xe KMD does not allow BOs to be created in system memory (instead KMD creates it in XE_PL_TT which is VRAM backed system memory).

---
 tests/intel/xe_drm_fdinfo.c | 285 ++++++++++++++++++++++++++++++++++++
 tests/meson.build           |   1 +
 2 files changed, 286 insertions(+)
 create mode 100644 tests/intel/xe_drm_fdinfo.c
tests/intel/xe_drm_fdinfo.c new file +34 -0
new file mode 100644
index 000000000..4f9dcdb66
@@ -0,0 +1,285 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_core.h"
+#include "igt_device.h"
+#include "igt_drm_fdinfo.h"
+#include "lib/igt_syncobj.h"
+#include "xe_drm.h"
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
+#include "xe/xe_spin.h"
+/**
+ * TEST: xe drm fdinfo
+ * Description: Read and verify drm client memory consumption using fdinfo
+ * Feature: SMI, core
+ *
+ * SUBTEST: basic
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Check if basic fdinfo content is present
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-total-resident
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare total and resident memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan

tests/intel/xe_drm_fdinfo.c line 44

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+ *
+ * SUBTEST: drm-shared
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare shared memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-shared

----- ^
This is copy-paste, you already have 'drm-shared' above, remove this.

Quoted 4 lines
tests/intel/xe_drm_fdinfo.c new file +4 -0
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare shared memory consumption by client
+ * Functionality: Per client memory statistics

tests/intel/xe_drm_fdinfo.c line 58

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-active
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare active memory consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan

For all fields which are the same for every subtest, you may just add them into TEST: description and remove from SUBTEST:
This will make it more compact.

tests/intel/xe_drm_fdinfo.c line 66

Quoted 8 lines
tests/intel/xe_drm_fdinfo.c new file +8 -0
+ */
+
+IGT_TEST_DESCRIPTION("Read and verify drm client memory consumption using fdinfo");
+
+/* Subtests */
+static void test_active(int fd, struct drm_xe_engine_class_instance *eci)
+{
+        struct drm_client_fdinfo info = { };

-- ^^^^^^^^
Replace spaces from begin of line with tabs, there are too many to list that all, use checkpatch.pl script from linux kernel.

Sample output from checkpatch:

ERROR: code indent should use tabs where possible
#97: FILE: tests/intel/xe_drm_fdinfo.c:66:
+ struct drm_client_fdinfo info = { };$

Quoted 64 lines
tests/intel/xe_drm_fdinfo.c new file +64 -0
+	uint32_t vm;
+        uint64_t addr = 0x1a0000;
+        struct drm_xe_sync sync[2] = {
+                { .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+                { .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+        };
+        struct drm_xe_exec exec = {
+                .num_batch_buffer = 1,
+                .num_syncs = 2,
+                .syncs = to_user_pointer(sync),
+        };
+#define N_EXEC_QUEUES   2
+        uint32_t exec_queues[N_EXEC_QUEUES];
+        uint32_t bind_exec_queues[N_EXEC_QUEUES];
+        uint32_t syncobjs[N_EXEC_QUEUES + 1];
+        size_t bo_size;
+        uint32_t bo = 0;
+	int region = 0x2; /* VRAM 0 */
+        struct {
+                struct xe_spin spin;
+                uint32_t batch[16];
+                uint64_t pad;
+                uint32_t data;
+        } *data;
+        int i, b;
+
+        vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+        bo_size = sizeof(*data) * N_EXEC_QUEUES;
+        bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+                        xe_get_default_alignment(fd));
+        bo = xe_bo_create_flags(fd, vm, bo_size,
+                                region);
+        data = xe_bo_map(fd, bo, bo_size);
+
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                exec_queues[i] = xe_exec_queue_create(fd, vm, eci, 0);
+                bind_exec_queues[i] = xe_bind_exec_queue_create(fd, vm, 0);
+                syncobjs[i] = syncobj_create(fd, 0);
+        }
+        syncobjs[N_EXEC_QUEUES] = syncobj_create(fd, 0);
+
+        sync[0].handle = syncobj_create(fd, 0);
+        xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr, bo_size,
+                         sync, 1);
+
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                uint64_t spin_offset = (char *)&data[i].spin - (char *)data;
+                uint64_t spin_addr = addr + spin_offset;
+                int e = i;
+
+                if (i == 0) {
+                        xe_spin_init(&data[i].spin, spin_addr, true);
+                        exec.exec_queue_id = exec_queues[e];
+                        exec.address = spin_addr;
+                        sync[0].flags &= ~DRM_XE_SYNC_SIGNAL;
+                        sync[1].flags |= DRM_XE_SYNC_SIGNAL;
+                        sync[1].handle = syncobjs[e];
+                        xe_exec(fd, &exec);
+                        xe_spin_wait_started(&data[i].spin);
+
+                        addr += bo_size;
+                        sync[1].flags &= ~DRM_XE_SYNC_SIGNAL;
+                        sync[1].handle = syncobjs[e];
+                        xe_vm_bind_async(fd, vm, bind_exec_queues[e], bo, 0, addr,

tests/intel/xe_drm_fdinfo.c line 140

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+                                         bo_size, sync + 1, 1);
+                        addr += bo_size;
+                } else {
+                        sync[0].flags |= DRM_XE_SYNC_SIGNAL;
+                        xe_vm_bind_async(fd, vm, bind_exec_queues[e], bo, 0, addr,
+                                         bo_size, sync, 1);
+                }
+
+		b = igt_parse_drm_fdinfo(fd, &info, NULL, 0, NULL, 0);
+		igt_assert(b);

Use igt_erorr_f and print here errno.

tests/intel/xe_drm_fdinfo.c line 146

Quoted 6 lines
tests/intel/xe_drm_fdinfo.c new file +6 -0
+
+		/* Client memory consumption includes public objects
+		 * as well as internal objects hence if bo is active on
+		 * N_EXEC_QUEUES consumption should be
+		 * >= bo_size + bo_size * N_EXEC_QUEUES */
+		printf("info.total:%ld active:%ld bo_size:%ld\n",

------- ^
Use igt_debug or igt_info.

Quoted 39 lines
tests/intel/xe_drm_fdinfo.c new file +39 -0
+		       info.region_mem[region].total,
+		       info.region_mem[region].active, bo_size);
+		igt_assert(info.region_mem[region].active >=
+			      bo_size + bo_size * N_EXEC_QUEUES);
+        }
+	xe_spin_end(&data[0].spin);
+
+	syncobj_destroy(fd, sync[0].handle);
+        sync[0].handle = syncobj_create(fd, 0);
+        sync[0].flags |= DRM_XE_SYNC_SIGNAL;
+        xe_vm_unbind_all_async(fd, vm, 0, bo, sync, 1);
+        igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
+
+        syncobj_destroy(fd, sync[0].handle);
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                syncobj_destroy(fd, syncobjs[i]);
+                xe_exec_queue_destroy(fd, exec_queues[i]);
+                xe_exec_queue_destroy(fd, bind_exec_queues[i]);
+        }
+
+        munmap(data, bo_size);
+        gem_close(fd, bo);
+        xe_vm_destroy(fd, vm);
+}
+
+static void test_shared(int xe)
+{
+        struct drm_client_fdinfo info = { };
+        struct drm_gem_flink flink;
+        struct drm_gem_open open_struct;
+	uint32_t bo;
+	int region = 0x1;
+        int ret;
+
+	bo = xe_bo_create_flags(xe, 0, 4096, region);
+
+        flink.handle = bo;
+        ret = igt_ioctl(xe, DRM_IOCTL_GEM_FLINK, &flink);
+        igt_assert_eq(ret, 0);

tests/intel/xe_drm_fdinfo.c line 195

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+
+        open_struct.name = flink.name;
+        ret = igt_ioctl(xe, DRM_IOCTL_GEM_OPEN, &open_struct);
+        igt_assert_eq(ret, 0);
+        igt_assert(open_struct.handle != 0);
+
+	ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+	igt_assert(ret);
+
+	printf("info.total:%ld shared:%ld\n",

--- ^
Same here, igt_info

Quoted 19 lines
tests/intel/xe_drm_fdinfo.c new file +19 -0
+			info.region_mem[region].total,
+			info.region_mem[region].shared);
+	igt_assert_eq(info.region_mem[region].shared,
+			2 * 4096);
+
+	gem_close(xe, bo);
+}
+
+static void test_total_resident(int xe)
+{
+        struct drm_xe_query_mem_region *memregion;
+        uint64_t memreg = all_memory_regions(xe), region;
+        struct drm_client_fdinfo info = { };
+        uint32_t vm;
+        uint32_t handle;
+	uint64_t addr = 0x1a0000;
+        int ret;
+
+        vm = xe_vm_create(xe, DRM_XE_VM_CREATE_SCRATCH_PAGE, 0);

tests/intel/xe_drm_fdinfo.c line 224

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+
+        xe_for_each_mem_region(xe, memreg, region) {
+                memregion = xe_mem_region(xe, region);
+
+		handle = xe_bo_create_flags(xe, vm, memregion->min_page_size, region);
+		xe_vm_bind_sync(xe, vm, handle, 0, addr, memregion->min_page_size);
+
+		ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+		igt_assert(ret);
+		/* currently xe KMD maps I915_MEMORY_CLASS_SYSTEM region to

-------------------------------- ^^^^
Is this correct? Should it be XE?

Quoted 16 lines
tests/intel/xe_drm_fdinfo.c new file +16 -0
+		 * XE_PL_TT thus we need memregion->instance + 1 */
+		printf("info.total:%ld resident:%ld for instance: %d bo_size:%d\n",
+		       info.region_mem[memregion->instance + 1].total,
+		       info.region_mem[memregion->instance + 1].resident,
+		       memregion->instance, memregion->min_page_size);
+		/* Client memory consumption includes public objects
+		 * as well as internal objects hence it should be
+		 * >= memregion->min_page_size */
+		igt_assert(info.region_mem[memregion->instance + 1].total >=
+			   memregion->min_page_size);
+		igt_assert(info.region_mem[memregion->instance + 1].resident >=
+			   memregion->min_page_size);
+		xe_vm_unbind_sync(xe, vm, 0, addr, memregion->min_page_size);
+		gem_close(xe, handle);
+        }
+

tests/intel/xe_drm_fdinfo.c line 250

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+        xe_vm_destroy(xe, vm);
+}
+
+static void basic(int xe)
+{
+        struct drm_client_fdinfo info = { };
+        unsigned int ret;
+
+        ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+        igt_assert(ret);

-----------^
Use: igt_assert_eq(ret, 0) or better igt_assert_f(ret == 0, "failed with err:%d\n", errno);

tests/intel/xe_drm_fdinfo.c line 252

Quoted 2 lines
tests/intel/xe_drm_fdinfo.c new file +2 -0
+
+        igt_assert(!strcmp(info.driver, "xe"));

Why do you need this here? You got this with:

		xe = drm_open_driver(DRIVER_XE);

tests/intel/xe_drm_fdinfo.c line 264

Quoted 12 lines
tests/intel/xe_drm_fdinfo.c new file +12 -0
+}
+
+igt_main
+{
+        int xe;
+
+        igt_fixture {
+                struct drm_client_fdinfo info = { };
+
+		xe = drm_open_driver(DRIVER_XE);
+		igt_require_xe(xe);
+                igt_require(igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0));

------------------ ^ --------- ^
Why this code here?
This is duplicated in basic() subtest.

Regards,
Kamil

Quoted 36 lines
tests/intel/xe_drm_fdinfo.c new file +21 -0
+        }
+
+	igt_describe("Check if basic fdinfo content is present");
+        igt_subtest("basic")
+                basic(xe);
+
+	igt_describe("Create and compare total and resident memory consumption by client");
+        igt_subtest("drm-total-resident")
+                test_total_resident(xe);
+
+	igt_describe("Create and compare shared memory consumption by client");
+	igt_subtest("drm-shared")
+                test_shared(xe);
+
+	igt_describe("Create and compare active memory consumption by client");
+	igt_subtest("drm-active")
+		test_active(xe, xe_hw_engine(xe, 0));
+
+	igt_fixture
+                drm_close_driver(xe);
+}
tests/meson.build +1 -0
index aa8e3434c..f5f495050 100644
@@ -275,6 +275,7 @@ intel_xe_progs = [
 	'xe_compute',
 	'xe_dma_buf_sync',
 	'xe_debugfs',
+	'xe_drm_fdinfo',
 	'xe_evict',
 	'xe_exec_balancer',
 	'xe_exec_basic',
Signature · 1 line
2.25.1
#6 lore raw
Quoted 12 lines

-----Original Message-----
From: Kamil Konieczny <[email protected]>
Sent: Thursday, September 7, 2023 7:40 PM
To: [email protected]
Cc: Upadhyay, Tejas <[email protected]>; intel- [email protected]
Subject: Re: [igt-dev] [intel-xe] tests/xe: Add tests to read and verify fdinfo

Hi Tejas,

Quoted 8 lines
Quoted 1 line · Tejas Upadhyay

This test verifies fdinfo published by xe KMD with

-- ^^^^^^^^^^^^^^^^^
Added tests to verify

Quoted 1 line

following tests :

------------^ ---^
s/tests :/subtests:/

ok

Quoted 9 lines
Quoted 7 lines

@basic
@drm-total-residents
@drm-shared
@drm-active

TODO : drm-purgeable test is not possbile as we consider objects in

----- ^
Remove space before ':'

Sure

Quoted 58 lines
Quoted 8 lines

system memory to be purgeable but current xe KMD does not allow BOs to be created in system memory (instead KMD creates it in XE_PL_TT which is VRAM backed system memory).

---
 tests/intel/xe_drm_fdinfo.c | 285

++++++++++++++++++++++++++++++++++++

Quoted 49 lines
 tests/meson.build           |   1 +
 2 files changed, 286 insertions(+)
 create mode 100644 tests/intel/xe_drm_fdinfo.c
tests/intel/xe_drm_fdinfo.c new file +40 -0
new file mode 100644 index 000000000..4f9dcdb66
@@ -0,0 +1,285 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation  */
+
+#include "igt.h"
+#include "igt_core.h"
+#include "igt_device.h"
+#include "igt_drm_fdinfo.h"
+#include "lib/igt_syncobj.h"
+#include "xe_drm.h"
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
+#include "xe/xe_spin.h"
+/**
+ * TEST: xe drm fdinfo
+ * Description: Read and verify drm client memory consumption using
+fdinfo
+ * Feature: SMI, core
+ *
+ * SUBTEST: basic
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Check if basic fdinfo content is present
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-total-resident
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare total and resident memory
+consumption by client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-shared
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare shared memory consumption by
Quoted 8 lines

tests/intel/xe_drm_fdinfo.c line 36

Quoted 6 lines
tests/intel/xe_drm_fdinfo.c new file +6 -0
+client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-shared

----- ^
This is copy-paste, you already have 'drm-shared' above, remove this.

Yes sure.

Quoted 18 lines
Quoted 7 lines
tests/intel/xe_drm_fdinfo.c new file +6 -0
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare shared memory consumption by
+ client
+ * Functionality: Per client memory statistics
+ * Run type: FULL

tests/intel/xe_drm_fdinfo.c line 58

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+ * Test category: SysMan
+ *
+ * SUBTEST: drm-active
+ * Category: Software building block
+ * Sub-category: driver
+ * Description: Create and compare active memory consumption by
+ client
+ * Functionality: Per client memory statistics
+ * Run type: FULL
+ * Test category: SysMan
Quoted 3 lines

For all fields which are the same for every subtest, you may just add them into
TEST: description and remove from SUBTEST:
This will make it more compact.

I will do that.

Quoted 14 lines

tests/intel/xe_drm_fdinfo.c line 66

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +9 -0
+ */
+
+IGT_TEST_DESCRIPTION("Read and verify drm client memory consumption
+using fdinfo");
+
+/* Subtests */
+static void test_active(int fd, struct drm_xe_engine_class_instance
+*eci) {
+        struct drm_client_fdinfo info = { };

-- ^^^^^^^^
Replace spaces from begin of line with tabs, there are too many to list that all, use checkpatch.pl script from linux kernel.

Quoted 1 line

Sample output from checkpatch:

Yes I forgot to apply checkpatch. I will run it.

Quoted 73 lines

ERROR: code indent should use tabs where possible
#97: FILE: tests/intel/xe_drm_fdinfo.c:66:
+ struct drm_client_fdinfo info = { };$

Quoted 68 lines
tests/intel/xe_drm_fdinfo.c new file +68 -0
+	uint32_t vm;
+        uint64_t addr = 0x1a0000;
+        struct drm_xe_sync sync[2] = {
+                { .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+                { .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+        };
+        struct drm_xe_exec exec = {
+                .num_batch_buffer = 1,
+                .num_syncs = 2,
+                .syncs = to_user_pointer(sync),
+        };
+#define N_EXEC_QUEUES   2
+        uint32_t exec_queues[N_EXEC_QUEUES];
+        uint32_t bind_exec_queues[N_EXEC_QUEUES];
+        uint32_t syncobjs[N_EXEC_QUEUES + 1];
+        size_t bo_size;
+        uint32_t bo = 0;
+	int region = 0x2; /* VRAM 0 */
+        struct {
+                struct xe_spin spin;
+                uint32_t batch[16];
+                uint64_t pad;
+                uint32_t data;
+        } *data;
+        int i, b;
+
+        vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+        bo_size = sizeof(*data) * N_EXEC_QUEUES;
+        bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+                        xe_get_default_alignment(fd));
+        bo = xe_bo_create_flags(fd, vm, bo_size,
+                                region);
+        data = xe_bo_map(fd, bo, bo_size);
+
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                exec_queues[i] = xe_exec_queue_create(fd, vm, eci, 0);
+                bind_exec_queues[i] = xe_bind_exec_queue_create(fd, vm, 0);
+                syncobjs[i] = syncobj_create(fd, 0);
+        }
+        syncobjs[N_EXEC_QUEUES] = syncobj_create(fd, 0);
+
+        sync[0].handle = syncobj_create(fd, 0);
+        xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr, bo_size,
+                         sync, 1);
+
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                uint64_t spin_offset = (char *)&data[i].spin - (char *)data;
+                uint64_t spin_addr = addr + spin_offset;
+                int e = i;
+
+                if (i == 0) {
+                        xe_spin_init(&data[i].spin, spin_addr, true);
+                        exec.exec_queue_id = exec_queues[e];
+                        exec.address = spin_addr;
+                        sync[0].flags &= ~DRM_XE_SYNC_SIGNAL;
+                        sync[1].flags |= DRM_XE_SYNC_SIGNAL;
+                        sync[1].handle = syncobjs[e];
+                        xe_exec(fd, &exec);
+                        xe_spin_wait_started(&data[i].spin);
+
+                        addr += bo_size;
+                        sync[1].flags &= ~DRM_XE_SYNC_SIGNAL;
+                        sync[1].handle = syncobjs[e];
+                        xe_vm_bind_async(fd, vm, bind_exec_queues[e], bo, 0, addr,
+                                         bo_size, sync + 1, 1);
+                        addr += bo_size;
+                } else {
+                        sync[0].flags |= DRM_XE_SYNC_SIGNAL;
Quoted 8 lines

tests/intel/xe_drm_fdinfo.c line 140

Quoted 6 lines
tests/intel/xe_drm_fdinfo.c new file +6 -0
+                        xe_vm_bind_async(fd, vm, bind_exec_queues[e], bo, 0, addr,
+                                         bo_size, sync, 1);
+                }
+
+		b = igt_parse_drm_fdinfo(fd, &info, NULL, 0, NULL, 0);
+		igt_assert(b);

Use igt_erorr_f and print here errno.

Ok

Quoted 9 lines

tests/intel/xe_drm_fdinfo.c line 146

Quoted 7 lines
tests/intel/xe_drm_fdinfo.c new file +6 -0
+
+		/* Client memory consumption includes public objects
+		 * as well as internal objects hence if bo is active on
+		 * N_EXEC_QUEUES consumption should be
+		 * >= bo_size + bo_size * N_EXEC_QUEUES */
+		printf("info.total:%ld active:%ld bo_size:%ld\n",

------- ^
Use igt_debug or igt_info.

Sure

Quoted 45 lines
Quoted 45 lines
tests/intel/xe_drm_fdinfo.c new file +44 -0
+		       info.region_mem[region].total,
+		       info.region_mem[region].active, bo_size);
+		igt_assert(info.region_mem[region].active >=
+			      bo_size + bo_size * N_EXEC_QUEUES);
+        }
+	xe_spin_end(&data[0].spin);
+
+	syncobj_destroy(fd, sync[0].handle);
+        sync[0].handle = syncobj_create(fd, 0);
+        sync[0].flags |= DRM_XE_SYNC_SIGNAL;
+        xe_vm_unbind_all_async(fd, vm, 0, bo, sync, 1);
+        igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0,
+NULL));
+
+        syncobj_destroy(fd, sync[0].handle);
+        for (i = 0; i < N_EXEC_QUEUES; i++) {
+                syncobj_destroy(fd, syncobjs[i]);
+                xe_exec_queue_destroy(fd, exec_queues[i]);
+                xe_exec_queue_destroy(fd, bind_exec_queues[i]);
+        }
+
+        munmap(data, bo_size);
+        gem_close(fd, bo);
+        xe_vm_destroy(fd, vm);
+}
+
+static void test_shared(int xe)
+{
+        struct drm_client_fdinfo info = { };
+        struct drm_gem_flink flink;
+        struct drm_gem_open open_struct;
+	uint32_t bo;
+	int region = 0x1;
+        int ret;
+
+	bo = xe_bo_create_flags(xe, 0, 4096, region);
+
+        flink.handle = bo;
+        ret = igt_ioctl(xe, DRM_IOCTL_GEM_FLINK, &flink);
+        igt_assert_eq(ret, 0);
+
+        open_struct.name = flink.name;
+        ret = igt_ioctl(xe, DRM_IOCTL_GEM_OPEN, &open_struct);
+        igt_assert_eq(ret, 0);
Quoted 8 lines

tests/intel/xe_drm_fdinfo.c line 195

Quoted 6 lines
tests/intel/xe_drm_fdinfo.c new file +6 -0
+        igt_assert(open_struct.handle != 0);
+
+	ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+	igt_assert(ret);
+
+	printf("info.total:%ld shared:%ld\n",

--- ^
Same here, igt_info

Ok

Quoted 26 lines
Quoted 26 lines
tests/intel/xe_drm_fdinfo.c new file +23 -0
+			info.region_mem[region].total,
+			info.region_mem[region].shared);
+	igt_assert_eq(info.region_mem[region].shared,
+			2 * 4096);
+
+	gem_close(xe, bo);
+}
+
+static void test_total_resident(int xe) {
+        struct drm_xe_query_mem_region *memregion;
+        uint64_t memreg = all_memory_regions(xe), region;
+        struct drm_client_fdinfo info = { };
+        uint32_t vm;
+        uint32_t handle;
+	uint64_t addr = 0x1a0000;
+        int ret;
+
+        vm = xe_vm_create(xe, DRM_XE_VM_CREATE_SCRATCH_PAGE, 0);
+
+        xe_for_each_mem_region(xe, memreg, region) {
+                memregion = xe_mem_region(xe, region);
+
+		handle = xe_bo_create_flags(xe, vm, memregion-

min_page_size, region);

tests/intel/xe_drm_fdinfo.c new file +1 -0
+		xe_vm_bind_sync(xe, vm, handle, 0, addr, memregion-
Quoted 8 lines

tests/intel/xe_drm_fdinfo.c

Quoted 5 lines

min_page_size);

tests/intel/xe_drm_fdinfo.c new file +4 -0
+
+		ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+		igt_assert(ret);
+		/* currently xe KMD maps I915_MEMORY_CLASS_SYSTEM

region to
-------------------------------- ^^^^
Is this correct? Should it be XE?

Only macro available right now, how ever I can just name it in xe term as it is just comment.

Quoted 35 lines

tests/intel/xe_drm_fdinfo.c

Quoted 3 lines
tests/intel/xe_drm_fdinfo.c new file +2 -0
+		 * XE_PL_TT thus we need memregion->instance + 1 */
+		printf("info.total:%ld resident:%ld for instance: %d

bo_size:%d\n",

tests/intel/xe_drm_fdinfo.c

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +7 -0
+		       info.region_mem[memregion->instance + 1].total,
+		       info.region_mem[memregion->instance + 1].resident,
+		       memregion->instance, memregion->min_page_size);
+		/* Client memory consumption includes public objects
+		 * as well as internal objects hence it should be
+		 * >= memregion->min_page_size */
+		igt_assert(info.region_mem[memregion->instance + 1].total

=

tests/intel/xe_drm_fdinfo.c new file +2 -0
+			   memregion->min_page_size);
+		igt_assert(info.region_mem[memregion->instance +

1].resident >=

Quoted 6 lines
tests/intel/xe_drm_fdinfo.c new file +2 -0
+			   memregion->min_page_size);
+		xe_vm_unbind_sync(xe, vm, 0, addr, memregion-

min_page_size);

tests/intel/xe_drm_fdinfo.c new file +3 -0
+		gem_close(xe, handle);
+        }
+

tests/intel/xe_drm_fdinfo.c line 250

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+        xe_vm_destroy(xe, vm);
+}
+
+static void basic(int xe)
+{
+        struct drm_client_fdinfo info = { };
+        unsigned int ret;
+
+        ret = igt_parse_drm_fdinfo(xe, &info, NULL, 0, NULL, 0);
+        igt_assert(ret);

-----------^
Use: igt_assert_eq(ret, 0) or better igt_assert_f(ret == 0, "failed with err:%d\n", errno);

Quoted 5 lines

tests/intel/xe_drm_fdinfo.c

Quoted 2 lines
tests/intel/xe_drm_fdinfo.c new file +2 -0
+
+        igt_assert(!strcmp(info.driver, "xe"));

Why do you need this here? You got this with:

		xe = drm_open_driver(DRIVER_XE);

Fdinfo is populated with all memory stats as well as driver info which we read through procfs file system. This is just making sure that whatever we read from fdinfo procfs also reflecting same driver.

Quoted 17 lines
Quoted 4 lines
tests/intel/xe_drm_fdinfo.c new file +3 -0
+}
+
+igt_main

tests/intel/xe_drm_fdinfo.c

Quoted 10 lines
tests/intel/xe_drm_fdinfo.c new file +10 -0
+{
+        int xe;
+
+        igt_fixture {
+                struct drm_client_fdinfo info = { };
+
+		xe = drm_open_driver(DRIVER_XE);
+		igt_require_xe(xe);
+                igt_require(igt_parse_drm_fdinfo(xe, &info, NULL, 0,
+NULL, 0));

------------------ ^ --------- ^
Why this code here?
This is duplicated in basic() subtest.

Agree this is the fixure which just checks if we can read or not. Without it none of test can be done. While basic test is validating info apart from just reading it.

Thanks,
Tejas

Quoted 42 lines

Regards,
Kamil

tests/intel/xe_drm_fdinfo.c

Quoted 7 lines
tests/intel/xe_drm_fdinfo.c new file +7 -0
+        }
+
+	igt_describe("Check if basic fdinfo content is present");
+        igt_subtest("basic")
+                basic(xe);
+
+	igt_describe("Create and compare total and resident memory

consumption by client");

tests/intel/xe_drm_fdinfo.c

Quoted 4 lines
tests/intel/xe_drm_fdinfo.c new file +4 -0
+        igt_subtest("drm-total-resident")
+                test_total_resident(xe);
+
+	igt_describe("Create and compare shared memory consumption by

client");

tests/intel/xe_drm_fdinfo.c

Quoted 4 lines
tests/intel/xe_drm_fdinfo.c new file +4 -0
+	igt_subtest("drm-shared")
+                test_shared(xe);
+
+	igt_describe("Create and compare active memory consumption by

client");

Quoted 20 lines
tests/intel/xe_drm_fdinfo.c new file +5 -0
+	igt_subtest("drm-active")
+		test_active(xe, xe_hw_engine(xe, 0));
+
+	igt_fixture
+                drm_close_driver(xe); }
tests/meson.build index renamed from tests/meson.build +0 -0

aa8e3434c..f5f495050 100644

tests/meson.build +1 -1
@@ -275,6 +275,7 @@ intel_xe_progs = [
 	'xe_compute',
 	'xe_dma_buf_sync',
 	'xe_debugfs',
+	'xe_drm_fdinfo',
 	'xe_evict',
 	'xe_exec_balancer',
 	'xe_exec_basic',
--

2.25.1