[PATCH i-g-t v3 4/5] tests/intel/xe_pmu: Add tests to validate engine activity on all engines
Umesh Nerlige Ramappa
umesh.nerlige.ramappa at intel.com
Wed May 14 22:42:06 UTC 2025
On Mon, May 12, 2025 at 12:35:50PM +0530, Riana Tauro wrote:
>Add tests to validate engine activity by running workload on
>all engines simultaneously.
>
>Also add trailing idle test.
>
>v2: use allocator
>v3: use flag per engine (Umesh)
>
>Signed-off-by: Riana Tauro <riana.tauro at intel.com>
>---
> tests/intel/xe_pmu.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 68 insertions(+)
>
>diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
>index cd56fcd54..1a9b015d9 100644
>--- a/tests/intel/xe_pmu.c
>+++ b/tests/intel/xe_pmu.c
>@@ -32,6 +32,14 @@
> * Description: Test to validate engine activity by running workload and trailing idle on one engine
> * and check if all other engines are idle
> *
>+ * SUBTEST: engine-activity-all-load
>+ * Description: Test to validate engine activity by running workload on all engines
>+ * simultaneously
>+ *
>+ * SUBTEST: engine-activity-all-load-idle
>+ * Description: Test to validate engine activity by running workload on all engines
>+ * simultaneously and trailing idle
>+ *
> * SUBTEST: all-fn-engine-activity-load
> * Description: Test to validate engine activity by running load on all functions simultaneously
> *
>@@ -307,6 +315,58 @@ static void engine_activity_load_single(int fd, int num_engines,
> check_all_engines(num_engines, flag, before, after);
> }
>
>+static void engine_activity_load_all(int fd, int num_engines, unsigned int flags)
>+{
>+ uint64_t ahnd, config, before[2 * num_engines], after[2 * num_engines];
>+ struct drm_xe_engine_class_instance *eci;
>+ struct xe_cork *cork[num_engines];
struct xe_cork *cork[num_engines] = { NULL };
relates to below comment.
>+ int idx = 0, engine_idx = 0;
>+ int pmu_fd[2 * num_engines], flag[num_engines];
>+ uint32_t vm;
>+
>+ pmu_fd[0] = -1;
>+ vm = xe_vm_create(fd, 0, 0);
>+ ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
>+
>+ xe_for_each_engine(fd, eci) {
>+ engine_idx = idx >> 1;
>+ flag[engine_idx] = TEST_LOAD;
>+
>+ config = get_event_config(eci->gt_id, eci, "engine-active-ticks");
>+ pmu_fd[idx++] = open_group(fd, config, pmu_fd[0]);
>+
>+ config = get_event_config(eci->gt_id, eci, "engine-total-ticks");
>+ pmu_fd[idx++] = open_group(fd, config, pmu_fd[0]);
>+
>+ if (flags & TEST_LOAD) {
>+ cork[engine_idx] = xe_cork_create_opts(fd, eci, vm, 1, 1, .ahnd = ahnd);
>+ xe_cork_sync_start(fd, cork[engine_idx]);
>+ }
>+ }
>+
>+ pmu_read_multi(pmu_fd[0], 2 * num_engines, before);
>+ usleep(SLEEP_DURATION * USEC_PER_SEC);
>+ if (flags & TEST_TRAILING_IDLE) {
>+ for (idx = 0; idx < num_engines; idx++)
>+ end_cork(fd, cork[idx]);
>+ }
>+ pmu_read_multi(pmu_fd[0], 2 * num_engines, after);
>+
>+ for (idx = 0; idx < num_engines * 2; idx += 2) {
>+ engine_idx = idx >> 1;
>+ if (flags & TEST_LOAD)
If you initialize the cork array to NULL, you can drop the if here.
With or without, LGTM,
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
Thanks,
Umesh
>+ end_cork(fd, cork[engine_idx]);
>+ xe_cork_destroy(fd, cork[engine_idx]);
>+ close(pmu_fd[idx]);
>+ close(pmu_fd[idx + 1]);
>+ }
>+
>+ xe_vm_destroy(fd, vm);
>+ put_ahnd(ahnd);
>+
>+ check_all_engines(num_engines, flag, before, after);
>+}
>+
> static void engine_activity_all_fn(int fd, struct drm_xe_engine_class_instance *eci, int num_fns)
> {
> uint64_t config, engine_active_ticks, engine_total_ticks;
>@@ -674,6 +734,14 @@ igt_main
> test_each_engine("engine-activity-single-load-idle", fd, eci)
> engine_activity_load_single(fd, num_engines, eci, TEST_LOAD | TEST_TRAILING_IDLE);
>
>+ igt_describe("Validate engine activity by loading all engines simultaenously");
>+ igt_subtest("engine-activity-all-load")
>+ engine_activity_load_all(fd, num_engines, TEST_LOAD);
>+
>+ igt_describe("Validate engine activity by loading all engines simultaenously and trailing idle");
>+ igt_subtest("engine-activity-all-load-idle")
>+ engine_activity_load_all(fd, num_engines, TEST_LOAD | TEST_TRAILING_IDLE);
>+
> igt_subtest_group {
> unsigned int num_fns;
>
>--
>2.47.1
>
More information about the igt-dev
mailing list