[PATCH i-g-t v2 2/2] tests/intel/xe_pmu: Add a test to validate engine activity on a function
Umesh Nerlige Ramappa
umesh.nerlige.ramappa at intel.com
Wed Mar 19 23:17:21 UTC 2025
On Wed, Mar 12, 2025 at 11:54:31AM +0530, Riana Tauro wrote:
>Provision and enable 2 VFs with execution quantum and scheduling policy
>set. Run workload on one function at a time. With sched_if_idle set to
>false, workload uses the execution quantum of idle functions.
I think part of this ^ description should be moved to patch 1 since you
are provisioning it there.
>
>Signed-off-by: Riana Tauro <riana.tauro at intel.com>
>---
> tests/intel/xe_pmu.c | 67 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 67 insertions(+)
>
>diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
>index a95ee1777..be4d17ed2 100644
>--- a/tests/intel/xe_pmu.c
>+++ b/tests/intel/xe_pmu.c
>@@ -263,6 +263,68 @@ static void engine_activity_all_fn(int fd, struct drm_xe_engine_class_instance *
> }
> }
>
>+/**
>+ * SUBTEST: fn-engine-activity-load
>+ * Description: Test to validate engine activity by running load on a function
>+ */
>+static void engine_activity_fn(int fd, struct drm_xe_engine_class_instance *eci, int function)
>+{
>+ uint64_t config, engine_active_ticks, engine_total_ticks, before[2], after[2];
>+ struct xe_cork *cork = NULL;
>+ uint32_t vm;
>+ int pmu_fd[2], fn_fd;
>+ double busy_percent, exec_quantum_ratio;
>+
>+ if (function > 0) {
>+ fn_fd = igt_sriov_open_vf_drm_device(fd, function);
>+ igt_assert_fd(fn_fd);
>+ } else {
>+ fn_fd = fd;
>+ }
>+
>+ config = get_event_config_fn(eci->gt_id, function, eci, "engine-active-ticks");
>+ pmu_fd[0] = open_group(fd, config, -1);
>+
>+ config = get_event_config_fn(eci->gt_id, function, eci, "engine-total-ticks");
>+ pmu_fd[1] = open_group(fd, config, pmu_fd[0]);
>+
>+ vm = xe_vm_create(fn_fd, 0, 0);
>+ cork = xe_cork_create_opts(fn_fd, eci, vm, 1, 1);
>+ xe_cork_sync_start(fn_fd, cork);
>+
>+ pmu_read_multi(pmu_fd[0], 2, before);
>+ usleep(SLEEP_DURATION * USEC_PER_SEC);
>+ pmu_read_multi(pmu_fd[0], 2, after);
>+
>+ xe_cork_sync_end(fn_fd, cork);
>+
>+ engine_active_ticks = after[0] - before[0];
>+ engine_total_ticks = after[1] - before[1];
>+
>+ igt_debug("[%d] Engine active ticks: after %ld, before %ld delta %ld\n", function,
>+ after[0], before[0], engine_active_ticks);
>+ igt_debug("[%d] Engine total ticks: after %ld, before %ld delta %ld\n", function,
>+ after[1], before[1], engine_total_ticks);
>+
>+ busy_percent = (double)engine_active_ticks / engine_total_ticks;
>+ exec_quantum_ratio = (double)TOTAL_EXEC_QUANTUM / xe_sriov_get_exec_quantum_ms(fd, function, eci->gt_id);
>+
>+ igt_debug("Percent %lf\n", busy_percent * 100);
>+
>+ if (cork)
>+ xe_cork_destroy(fn_fd, cork);
>+
>+ xe_vm_destroy(fn_fd, vm);
>+
>+ close(pmu_fd[0]);
>+ close(pmu_fd[1]);
>+
>+ if (function > 0)
>+ close(fn_fd);
>+
>+ assert_within_epsilon(busy_percent, exec_quantum_ratio, tolerance);
>+}
>+
> /**
> * SUBTEST: gt-c6-idle
> * Description: Basic residency test to validate idle residency
>@@ -360,6 +422,11 @@ igt_main
> test_each_engine("all-fn-engine-activity-load", fd, eci)
> engine_activity_all_fn(fd, eci, num_fns);
>
>+ igt_describe("Validate per-function engine activity");
>+ test_each_engine("fn-engine-activity-load", fd, eci)
>+ for (int fn = 0; fn < num_fns; fn++)
>+ engine_activity_fn(fd, eci, fn);
>+
Maybe add the sched_if_idle = 1 case here.
Rest looks good,
Thanks,
Umesh
> igt_fixture
> igt_sriov_disable_vfs(fd);
> }
>--
>2.47.1
>
More information about the igt-dev
mailing list