tests/xe_drm_fdinfo: Add tests to read and verify fdinfo
PATCH 1/1 tests/xe_drm_fdinfo: Add tests to read and verify fdinfo
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
@@ -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
@@ -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
Patchwork
CI[Intel-xe] ✗ CI.Patch_applied: failure for tests/xe_drm_fdinfo: Add tests to read and verify fdinfo
== Series Details ==
== Series Details ==
Series: tests/xe_drm_fdinfo: Add tests to read and verify fdinfo
URL : https://patchwork.freedesktop.org/series/123265/
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_drm_fdinfo: Add tests to read and verify fdinfo Patch failed at 0001 tests/xe_drm_fdinfo: 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".
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for tests/xe_drm_fdinfo: Add tests to read and verify fdinfo
In reply to Tejas Upadhyay== Series Details ==
== Series Details ==
Series: tests/xe_drm_fdinfo: Add tests to read and verify fdinfo
URL : https://patchwork.freedesktop.org/series/123264/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_13596 -> IGTPW_9715
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_9715 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_9715, please notify your bug team ([email protected]) 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_9715/index.html
Participating hosts (40 -> 37)
------------------------------
Missing (3): fi-kbl-soraka fi-hsw-4770 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_9715:
### IGT changes ###
#### Possible regressions ####
* igt@gem_busy@busy@all-engines:
- bat-mtlp-8: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13596/bat-mtlp-8/igt@gem_busy@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9715/bat-mtlp-8/igt@gem_busy@[email protected]
Known issues
------------
Here are the changes found in IGTPW_9715 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live@workarounds:
- bat-dg2-11: [PASS][3] -> [DMESG-FAIL][4] ([i915#7913])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13596/bat-dg2-11/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9715/bat-dg2-11/igt@i915_selftest@[email protected]
* igt@kms_hdmi_inject@inject-audio:
- fi-kbl-guc: [PASS][5] -> [FAIL][6] ([IGT#3] / [i915#6121])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13596/fi-kbl-guc/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9715/fi-kbl-guc/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[IGT#3]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/3
[i915#6121]: https://gitlab.freedesktop.org/drm/intel/issues/6121
[i915#7359]: https://gitlab.freedesktop.org/drm/intel/issues/7359
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#8981]: https://gitlab.freedesktop.org/drm/intel/issues/8981
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7468 -> IGTPW_9715
CI-20190529: 20190529
CI_DRM_13596: c79434429f2411f51da5de1ce729dd414c2a3e65 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9715: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9715/index.html
IGT_7468: 7468
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
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9715/index.html