Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: riana.tauro@intel.com, anshuman.gupta@intel.com,
	umesh.nerlige.ramappa@intel.com, lucas.demarchi@intel.com,
	michal.wajdeczko@intel.com, soham.purkait@intel.com
Subject: [PATCH i-g-t v2 2/2] tests/intel/xe_pmu: Add a test to validate engine activity on a function
Date: Wed, 12 Mar 2025 11:54:31 +0530	[thread overview]
Message-ID: <20250312062431.2238409-3-riana.tauro@intel.com> (raw)
In-Reply-To: <20250312062431.2238409-1-riana.tauro@intel.com>

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.

Signed-off-by: Riana Tauro <riana.tauro@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);
+
 		igt_fixture
 			igt_sriov_disable_vfs(fd);
 	}
-- 
2.47.1


  parent reply	other threads:[~2025-03-12  6:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12  6:24 [PATCH i-g-t v2 0/2] Add engine activity tests for functions Riana Tauro
2025-03-12  6:24 ` [PATCH i-g-t v2 1/2] tests/intel/xe_pmu: Add engine activity test for all functions Riana Tauro
2025-03-19 22:22   ` Umesh Nerlige Ramappa
2025-03-19 23:11     ` Umesh Nerlige Ramappa
2025-03-20 13:51       ` Riana Tauro
2025-03-12  6:24 ` Riana Tauro [this message]
2025-03-19 23:17   ` [PATCH i-g-t v2 2/2] tests/intel/xe_pmu: Add a test to validate engine activity on a function Umesh Nerlige Ramappa
2025-03-12  8:41 ` ✓ Xe.CI.BAT: success for Add engine activity tests for functions Patchwork
2025-03-12  8:59 ` ✓ i915.CI.BAT: " Patchwork
2025-03-12 16:12 ` ✓ i915.CI.Full: " Patchwork
2025-03-12 23:19 ` ✗ Xe.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250312062431.2238409-3-riana.tauro@intel.com \
    --to=riana.tauro@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=soham.purkait@intel.com \
    --cc=umesh.nerlige.ramappa@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox