From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH i-g-t v3 09/10] tests/intel/xe_drm_fdinfo: Use enum with expected load
Date: Tue, 27 Aug 2024 09:54:48 -0700 [thread overview]
Message-ID: <20240827165449.1706784-10-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20240827165449.1706784-1-lucas.demarchi@intel.com>
Do not let the execution flag dictate the result check, but rather be
explicit what's being checked: idle or full load.
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
tests/intel/xe_drm_fdinfo.c | 45 +++++++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/tests/intel/xe_drm_fdinfo.c b/tests/intel/xe_drm_fdinfo.c
index 23edeea40..d45e45c6b 100644
--- a/tests/intel/xe_drm_fdinfo.c
+++ b/tests/intel/xe_drm_fdinfo.c
@@ -68,6 +68,11 @@ IGT_TEST_DESCRIPTION("Read and verify drm client memory consumption and engine u
#define TEST_TRAILING_IDLE (1 << 1)
#define TEST_ISOLATION (1 << 2)
+enum expected_load {
+ EXPECTED_LOAD_IDLE,
+ EXPECTED_LOAD_FULL,
+};
+
struct pceu_cycles {
uint64_t cycles;
uint64_t total_cycles;
@@ -471,7 +476,7 @@ spin_ctx_destroy(int fd, struct spin_ctx *ctx)
static void
check_results(struct pceu_cycles *s1, struct pceu_cycles *s2,
- int class, unsigned int flags)
+ int class, enum expected_load expected_load)
{
double percent;
u64 den, num;
@@ -487,11 +492,18 @@ check_results(struct pceu_cycles *s1, struct pceu_cycles *s2,
igt_debug("%s: percent: %f\n", engine_map[class], percent);
- if (flags & TEST_BUSY) {
+ switch (expected_load) {
+ case EXPECTED_LOAD_IDLE:
+ igt_assert_eq(num, 0);
+ break;
+ case EXPECTED_LOAD_FULL:
+ /*
+ * We are still relying on CPU sleep time and there could be
+ * some imprecision when calculating the load. Use a 5% margin.
+ */
igt_assert_lt_double(95.0, percent);
igt_assert_lt_double(percent, 105.0);
- } else {
- igt_assert_eq(num, 0);
+ break;
}
}
@@ -501,6 +513,7 @@ single(int fd, struct drm_xe_engine_class_instance *hwe, unsigned int flags)
struct pceu_cycles pceu1[2][DRM_XE_ENGINE_CLASS_COMPUTE + 1];
struct pceu_cycles pceu2[2][DRM_XE_ENGINE_CLASS_COMPUTE + 1];
struct spin_ctx *ctx = NULL;
+ enum expected_load expected_load;
uint32_t vm;
int new_fd;
@@ -525,10 +538,16 @@ single(int fd, struct drm_xe_engine_class_instance *hwe, unsigned int flags)
if (flags & TEST_ISOLATION)
read_engine_cycles(new_fd, pceu2[1]);
- check_results(pceu1[0], pceu2[0], hwe->engine_class, flags);
+ expected_load = flags & TEST_BUSY ?
+ EXPECTED_LOAD_FULL : EXPECTED_LOAD_IDLE;
+ check_results(pceu1[0], pceu2[0], hwe->engine_class, expected_load);
if (flags & TEST_ISOLATION) {
- check_results(pceu1[1], pceu2[1], hwe->engine_class, 0);
+ /*
+ * Load from one client shouldn't spill on another,
+ * so check for idle
+ */
+ check_results(pceu1[1], pceu2[1], hwe->engine_class, EXPECTED_LOAD_IDLE);
close(new_fd);
}
@@ -557,9 +576,10 @@ busy_check_all(int fd, struct drm_xe_engine_class_instance *hwe)
read_engine_cycles(fd, pceu2);
xe_for_each_engine_class(class) {
- bool idle = hwe->engine_class != class;
+ enum expected_load expected_load = hwe->engine_class != class ?
+ EXPECTED_LOAD_IDLE : EXPECTED_LOAD_FULL;
- check_results(pceu1, pceu2, class, idle ? 0 : TEST_BUSY);
+ check_results(pceu1, pceu2, class, expected_load);
}
spin_sync_end(fd, ctx);
@@ -590,7 +610,7 @@ single_destroy_queue(int fd, struct drm_xe_engine_class_instance *hwe)
xe_vm_destroy(fd, vm);
- check_results(pceu1, pceu2, hwe->engine_class, TEST_BUSY);
+ check_results(pceu1, pceu2, hwe->engine_class, EXPECTED_LOAD_FULL);
}
static void
@@ -623,12 +643,13 @@ most_busy_check_all(int fd, struct drm_xe_engine_class_instance *hwe)
read_engine_cycles(fd, pceu2);
xe_for_each_engine_class(class) {
- bool idle = hwe->engine_class == class;
+ enum expected_load expected_load = hwe->engine_class == class ?
+ EXPECTED_LOAD_IDLE : EXPECTED_LOAD_FULL;
if (!ctx[class])
continue;
- check_results(pceu1, pceu2, class, idle ? 0 : TEST_BUSY);
+ check_results(pceu1, pceu2, class, expected_load);
spin_sync_end(fd, ctx[class]);
spin_ctx_destroy(fd, ctx[class]);
}
@@ -668,7 +689,7 @@ all_busy_check_all(int fd)
if (!ctx[class])
continue;
- check_results(pceu1, pceu2, class, TEST_BUSY);
+ check_results(pceu1, pceu2, class, EXPECTED_LOAD_FULL);
spin_sync_end(fd, ctx[class]);
spin_ctx_destroy(fd, ctx[class]);
}
--
2.43.0
next prev parent reply other threads:[~2024-08-27 16:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 16:54 [PATCH i-g-t v3 00/10] tests/intel/xe_drm_fdinfo: Fix noise and improve Lucas De Marchi
2024-08-27 16:54 ` [PATCH i-g-t v3 01/10] tests/intel/xe_drm_fdinfo: Extend mercy to the upper end Lucas De Marchi
2024-08-28 14:44 ` Nirmoy Das
2024-08-28 14:46 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 02/10] tests/intel/xe_drm_fdinfo: Print timestamp for debug Lucas De Marchi
2024-08-28 14:45 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 03/10] lib/igt_core: Add igt_assert_lt_double() Lucas De Marchi
2024-08-28 14:46 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 04/10] tests/intel/xe_drm_fdinfo: Use igt_assert_lt_double() Lucas De Marchi
2024-08-28 14:48 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 05/10] tests/intel/xe_drm_fdinfo: Be strict on == 0 comparison Lucas De Marchi
2024-08-28 14:51 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 06/10] tests/intel/xe_drm_fdinfo: Use usec for batch duration Lucas De Marchi
2024-08-28 14:51 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 07/10] tests/intel/xe_drm_fdinfo: Half the execution time Lucas De Marchi
2024-08-28 14:52 ` Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 08/10] tests/intel/xe_drm_fdinfo: Remove unused flags Lucas De Marchi
2024-08-28 15:00 ` Nirmoy Das
2024-08-27 16:54 ` Lucas De Marchi [this message]
2024-08-28 14:56 ` [PATCH i-g-t v3 09/10] tests/intel/xe_drm_fdinfo: Use enum with expected load Nirmoy Das
2024-08-27 16:54 ` [PATCH i-g-t v3 10/10] tests/intel/xe_drm_fdinfo: Rename and reorder tests Lucas De Marchi
2024-08-28 15:08 ` Nirmoy Das
2024-08-28 15:14 ` Nirmoy Das
2024-08-27 18:27 ` ✓ CI.xeBAT: success for tests/intel/xe_drm_fdinfo: Fix noise and improve (rev2) Patchwork
2024-08-27 18:38 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-08-28 4:05 ` ✗ CI.xeFULL: " 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=20240827165449.1706784-10-lucas.demarchi@intel.com \
--to=lucas.demarchi@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--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