tests/intel/xe_sysfs_preempt_timeout: Porting sysfs preempt test in xe
PATCH v7 1/1 tests/intel/xe_sysfs_preempt_timeout: Porting sysfs preempt test in xe
From: Nakshtra Goyal <[email protected]>
Adding preempt_timeout test in xe similar to i915 to check preemption for different preemption_timeout like 50 ms, 100 ms
v6: correcting allignment and argument for subtest as per IGT documentations
--- tests/intel/xe_sysfs_preempt_timeout.c | 216 +++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 217 insertions(+) create mode 100644 tests/intel/xe_sysfs_preempt_timeout.c
tests/intel/xe_sysfs_preempt_timeout.c new file +216 -0
@@ -0,0 +1,216 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2024 Intel Corporation +*/ + +/** +* TEST: sysfs preempt timeout +* Category: Core +* Mega feature: SysMan +* Sub-category: SysMan tests +* Functionality: sysfs preempt timeout +* Feature: SMI, context +* Test category: SysMan +* +* SUBTEST: preempt timeout us-timeout +* Description: Test to measure the delay from requesting the preemption to its +* completion. Send down some non-preemptable workloads and then +* request a switch to a higher priority context. The HW will not +* be able to respond, so the kernel will be forced to reset the hog. +* Test category: functionality test +* +*/ + +#include <fcntl.h> + +#include "igt.h" +#include "igt_syncobj.h" +#include "igt_sysfs.h" +#include "xe/xe_ioctl.h" +#include "xe/xe_spin.h" + +#define ATTR "preempt_timeout_us" + +static void set_preempt_timeout (int engine,unsigned int value) +{ +unsigned int delay; + +igt_assert_lte (0 ,igt_sysfs_printf (engine,ATTR ,"%u" , value)); +igt_sysfs_scanf (engine,ATTR ,"%u" , &delay); +igt_assert_eq (delay, value); +} + +static uint64_t __test_timeout (int fd,int engine,unsigned int timeout,uint16_t gt,int class) +{ +struct drm_xe_sync sync = { + .handle =syncobj_create (fd,0 ), + .type =DRM_XE_SYNC_TYPE_SYNCOBJ , + .flags =DRM_XE_SYNC_FLAG_SIGNAL , + }; + +struct drm_xe_exec exec = { + .num_batch_buffer =1 , + .num_syncs =1 , + .syncs =to_user_pointer (&sync), + }; +/* high priority property */ +struct drm_xe_ext_set_property ext = { + .base.next_extension =0 , + .base.name =DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY , + .property =DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY , + .value =2 ,/* High priority */ + }; +struct drm_xe_engine_class_instance *hwe =NULL , *_hwe; +uint64_t ahnd[2 ]; +uint32_t exec_queues[2 ]; +uint32_t vm[2 ]; +uint32_t bo[2 ]; +size_t bo_size; +struct xe_spin *spin[2 ]; +struct timespec ts = {}; +double elapsed; +uint64_t addr1 =0x1a0000 , addr2 =0x100000 ; + +xe_for_each_engine (fd, _hwe) +if (_hwe->engine_class == class && _hwe->gt_id == gt) + hwe = _hwe; + +if (!hwe) +return -1 ; + +/* set preempt timeout*/ +set_preempt_timeout (engine, timeout); + vm[0 ] =xe_vm_create (fd,0 ,0 ); + vm[1 ] =xe_vm_create (fd,0 ,0 ); + exec_queues[0 ] =xe_exec_queue_create (fd, vm[0 ], hwe,0 ); + exec_queues[1 ] =xe_exec_queue_create (fd, vm[1 ], hwe,to_user_pointer (&ext)); + ahnd[0 ] =intel_allocator_open (fd,0 ,INTEL_ALLOCATOR_RELOC ); + bo_size =xe_bb_size (fd,sizeof (*spin)); + bo[0 ] =xe_bo_create (fd, vm[0 ], bo_size,vram_if_possible (fd,0 ),0 ); + spin[0 ] =xe_bo_map (fd, bo[0 ], bo_size); +xe_vm_bind_async (fd, vm[0 ],0 , bo[0 ],0 , addr1, bo_size, &sync,1 ); + xe_spin_init_opts(spin[0], .addr = addr1, + .preempt = false); + exec.address = addr1; + exec.exec_queue_id = exec_queues[0 ]; +xe_exec (fd, &exec); +xe_spin_wait_started (spin[0 ]); + +igt_nsec_elapsed (&ts); + ahnd[1 ] =intel_allocator_open (fd,0 ,INTEL_ALLOCATOR_RELOC ); + bo[1 ] =xe_bo_create (fd, vm[1 ], bo_size,vram_if_possible (fd,0 ),0 ); + spin[1 ] =xe_bo_map (fd, bo[1 ], bo_size); +xe_vm_bind_sync (fd, vm[1 ], bo[1 ],0 , addr2, bo_size); + xe_spin_init_opts(spin[1], .addr = addr2); + exec.address = addr2; + exec.exec_queue_id = exec_queues[1 ]; +xe_exec (fd, &exec); +xe_spin_wait_started (spin[1 ]); + elapsed =igt_nsec_elapsed (&ts); +xe_spin_end (spin[1 ]); + +xe_vm_unbind_async (fd, vm[0 ],0 ,0 , addr1, bo_size, &sync,1 ); +igt_assert (syncobj_wait (fd, &sync.handle,1 ,INT64_MAX ,0 ,NULL )); + +xe_spin_end (spin[0 ]); +xe_vm_unbind_sync (fd, vm[1 ],0 , addr2, bo_size); +syncobj_destroy (fd, sync.handle); + +xe_exec_queue_destroy (fd, exec_queues[0 ]); +xe_vm_destroy (fd, vm[0 ]); +xe_exec_queue_destroy (fd, exec_queues[1 ]); +xe_vm_destroy (fd, vm[1 ]); + +put_ahnd (ahnd[1 ]); +put_ahnd (ahnd[0 ]); + +return elapsed; +} + +static void test_timeout (int fd,int engine,const char **property,uint16_t class,int gt) +{ +uint64_t delays[] = {1000 ,50000 ,100000 ,500000 }; +unsigned int saved; +uint64_t elapsed; +uint64_t epsilon; + +/* +* Send down some non-preemptable workloads and then request a +* switch to a higher priority context. The HW will not be able to +* respond, so the kernel will be forced to reset the hog. This +* timeout should match our specification, and so we can measure +* the delay from requesting the preemption to its completion. +*/ + +igt_assert (igt_sysfs_scanf (engine, property[0 ],"%u" , &saved) ==1 ); +igt_debug ("Initial %s:%u\n" , property[0 ], saved); + + elapsed =__test_timeout (fd, engine,1000 , gt, class); + epsilon =2 * elapsed /1000 ; +if (epsilon <50000 ) + epsilon =50000 ; +igt_info ("Minimum timeout measured as %.3fus; setting error threshold to %" PRId64"us\n" , + elapsed *1e-3 , epsilon); +igt_require (epsilon <10000000 ); + +for (int i =0 ; i <ARRAY_SIZE (delays); i++) { + elapsed =__test_timeout (fd, engine, delays[i], gt, class); +igt_info ("%s:%ld, elapsed=%.3fus\n" , + property[0 ], delays[i], elapsed *1e-3 ); + +/* +* We need to give a couple of jiffies slack for the scheduler +* timeouts and then a little more slack for the overhead in +* submitting and measuring. +*/ +igt_assert_f (elapsed /1000 < delays[i] + epsilon, +"Forced preemption timeout exceeded request!\n" ); + } + +set_preempt_timeout (engine, saved); +} + +igt_main +{ +static const struct { +const char *name; +void (*fn)(int ,int ,const char **,uint16_t ,int ); + } tests[] = { + {"timeout" , test_timeout }, + { } + }; +const char *property[][3 ] = { {"preempt_timeout_us" , +"preempt_timeout_min" , +"preempt_timeout_max" }, }; +int count =sizeof (property) /sizeof (property[0 ]); +int fd =-1 , sys_fd, gt; +int engines_fd =-1 , gt_fd =-1 ; + + igt_fixture { + fd =drm_open_driver (DRIVER_XE ); + + sys_fd =igt_sysfs_open (fd); +igt_require (sys_fd !=-1 ); +close (sys_fd); + } + +for (int i =0 ; i < count; i++) { +for (typeof (*tests) *t = tests; t->name; t++) { + igt_subtest_with_dynamic_f("%s-%s", property[i][0], t->name) { +xe_for_each_gt (fd, gt) { + gt_fd =xe_sysfs_gt_open (fd, gt); +igt_require (gt_fd !=-1 ); + engines_fd =openat (gt_fd,"engines" ,O_RDONLY ); +igt_require (engines_fd !=-1 ); + +igt_sysfs_engines (fd, engines_fd, gt,1 , property[i], t->fn); +close (engines_fd); +close (gt_fd); + } + } + } + } + igt_fixture { +drm_close_driver (fd); + } +}
tests/meson.build +1 -0
@@ -314,6 +314,7 @@ intel_xe_progs = [ 'xe_waitfence', 'xe_spin_batch', 'xe_sysfs_defaults', + 'xe_sysfs_preempt_timeout', 'xe_sysfs_scheduler', ]
Signature · 1 line
2.34.1
Patchwork
CI✗ Fi.CI.BUILD: failure for tests/intel/xe_sysfs_preempt_timeout: Porting sysfs preempt test in xe (rev7)
== Series Details ==
== Series Details ==
Series: tests/intel/xe_sysfs_preempt_timeout: Porting sysfs preempt test in xe (rev7)
URL : https://patchwork.freedesktop.org/series/136449/
State : failure
== Summary ==
IGT patchset build failed on latest successful build c34e13f766d0ed48c8b62ad9d8c29f11a8441b8b tests/amdgpu: fix secure bounce test failure on APUs
Tail of build.log:
[1714/1761] Linking target tools/lsgpu.
[1715/1761] Linking target runner/igt_comms_decoder.
[1716/1761] Linking target tools/intel_residency.
[1717/1761] Linking target tools/msm_dp_compliance.
[1718/1761] Linking target tools/amd_hdmi_compliance.
[1719/1761] Linking target runner/testdata/successtest.
[1720/1761] Linking target tools/intel_vbt_decode.
[1721/1761] Linking target tools/intel_gvtg_test.
[1722/1761] Linking target runner/igt_results.
[1723/1761] Linking target tools/intel_stepping.
[1724/1761] Linking target tools/intel_gem_info.
[1725/1761] Linking target runner/testdata/abort-simple.
[1726/1761] Linking target tools/intel_l3_parity.
[1727/1761] Linking target runner/testdata/abort-dynamic.
[1728/1761] Linking target runner/testdata/dynamic.
[1729/1761] Linking target runner/igt_resume.
[1730/1761] Linking target runner/testdata/skippers.
[1731/1761] Linking target runner/testdata/abort.
[1732/1761] Linking target runner/testdata/no-subtests.
[1733/1761] Linking target runner/igt_runner.
[1734/1761] Linking target runner/runner_json_test.
[1735/1761] Generating gem_stress.testlist with a meson_exe.py custom command.
[1736/1761] Linking target runner/testdata/abort-fixture.
[1737/1761] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_mtlgt3.c.o'.
[1738/1761] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt1.c.o'.
[1739/1761] Compiling C object 'runner/527aa9f@@runner_test@exe/runner_tests.c.o'.
[1740/1761] Linking target runner/runner_test.
[1741/1761] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt2.c.o'.
[1742/1761] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt3.c.o'.
[1743/1761] Linking target lib/libi915_perf.so.1.5.
[1744/1761] Generating symbol file 'lib/76b5a35@@i915_perf@sha/libi915_perf.so.1.5.symbols'.
[1745/1761] Linking target tools/i915-perf/i915-perf-configs.
[1746/1761] Linking target tools/i915-perf/i915-perf-reader.
[1747/1761] Linking target tools/i915-perf/i915-perf-recorder.
[1748/1761] Linking target tests/core_hotunplug.
[1749/1761] Linking target tests/gem_barrier_race.
[1750/1761] Linking target tests/perf.
[1751/1761] Generating core_hotunplug.testlist with a meson_exe.py custom command.
[1752/1761] Generating gem_barrier_race.testlist with a meson_exe.py custom command.
[1753/1761] Generating perf.testlist with a meson_exe.py custom command.
[1754/1761] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst/usr/src/igt-gpu-tools/scripts/igt_doc.py --config /usr/src/igt-gpu-tools/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /opt/igt/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
[1755/1761] Generating i915_tests.rst with a custom command.
[1756/1761] Generating kms_tests.rst with a custom command.
[1757/1761] Generating intel-ci-tests with a custom command.
ninja: build stopped: subcommand failed.
Patchwork
CI✗ GitLab.Pipeline: warning for tests/intel/xe_sysfs_preempt_timeout: Porting sysfs preempt test in xe (rev7)
In reply to [email protected]== Series Details ==
== Series Details ==
Series: tests/intel/xe_sysfs_preempt_timeout: Porting sysfs preempt test in xe (rev7)
URL : https://patchwork.freedesktop.org/series/136449/
State : warning
== Summary ==
Pipeline status: FAILED.
see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1250399 for the overview.
build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/62332077):
ninja: build stopped: subcommand failed.
ninja: Entering directory `build'
[1/837] Generating version.h with a custom command.
[2/8] Linking target runner/runner_test.
[3/8] Linking target assembler/intel-gen4asm.
[4/8] Generating i915_tests.html with a custom command.
[5/8] Generating kms_tests.html with a custom command.
[6/8] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1723792489:step_script
section_start:1723792489:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1723792490:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/62332072):
ninja: Entering directory `build'
[1/839] Generating version.h with a custom command.
[2/8] Linking target runner/runner_test.
[3/8] Linking target assembler/intel-gen4asm.
[4/8] Generating kms_tests.html with a custom command.
[5/8] Generating i915_tests.html with a custom command.
[6/8] Generating intel-ci-tests with a custom command.
[7/8] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1723792498:step_script
section_start:1723792498:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1723792499:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/62332076):
[1886/1889] Generating intel-ci-tests with a custom command.
ninja: build stopped: subcommand failed.
ninja: Entering directory `build'
[1/839] Generating version.h with a custom command.
[2/6] Generating kms_tests.html with a custom command.
[3/6] Generating i915_tests.html with a custom command.
[4/6] Generating intel-ci-tests with a custom command.
[5/6] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1723792518:step_script
section_start:1723792518:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1723792519:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/62332075):
ninja: build stopped: subcommand failed.
ninja: Entering directory `build'
[1/788] Generating version.h with a custom command.
[2/7] Linking target runner/runner_test.
[3/7] Generating kms_tests.html with a custom command.
[4/7] Generating i915_tests.html with a custom command.
[5/7] Generating intel-ci-tests with a custom command.
[6/7] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1723792478:step_script
section_start:1723792478:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1723792479:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/62332073):
ninja: build stopped: subcommand failed.
ninja: Entering directory `build'
[1/839] Generating version.h with a custom command.
[2/7] Linking target runner/runner_test.
[3/7] Generating kms_tests.html with a custom command.
[4/7] Generating intel-ci-tests with a custom command.
[5/7] Generating i915_tests.html with a custom command.
[6/7] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1723792498:step_script
section_start:1723792498:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1723792499:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/62332074):
ninja: build stopped: subcommand failed.
ninja: Entering directory `build'
[1/839] Generating version.h with a custom command.
[2/7] Linking target runner/runner_test.
[3/7] Generating i915_tests.html with a custom command.
[4/7] Generating intel-ci-tests with a custom command.
[5/7] Generating kms_tests.html with a custom command.
[6/7] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: Documented igt@xe_sysfs_preempt_timeout@preempt timeout us-timeout doesn't exist on source files
Warning: Missing documentation for igt@xe_sysfs_preempt_timeout@preempt_timeout_us-timeout
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1723792478:step_script
section_start:1723792478:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1723792479:cleanup_file_variables
ERROR: Job failed: exit code 1
== Logs ==
For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1250399