From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: jonathan.cavitt@intel.com, saurabhg.gupta@intel.com,
alex.zuo@intel.com, kamil.konieczny@linux.intel.com,
vinay.belgaumkar@intel.com
Subject: [PATCH v5 3/3] tests/intel/xe_sysfs_timeslice_duration: Restore preempt timeout
Date: Thu, 7 Nov 2024 22:52:54 +0000 [thread overview]
Message-ID: <20241107225254.302010-4-jonathan.cavitt@intel.com> (raw)
In-Reply-To: <20241107225254.302010-1-jonathan.cavitt@intel.com>
The subtests of sysfs_timeslice_duration modify the preempt_timeout_us
and timeslice_duration_us values. However, while the test does restore
the timeslice_duration_us value at the end of execution, it does not do
the same for preempt_timeout_us. Because the value is not properly
restored, future tests can end up using the unexpected preempt timeout
value and thus have unexpected behavior.
Save and restore the preempt_timeout_us value during the test.
This fix does not apply to xe_sysfs_preempt_timeout because only the
preempt_timeout_us is modified during those tests, and the value is
correcty restored before the tests end.
v2: Also restore preempt_timeout_us on test failure (Kamil)
v3: Abort on restore failure (Kamil)
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2976
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
CC: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
CC: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
tests/intel/xe_sysfs_timeslice_duration.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/tests/intel/xe_sysfs_timeslice_duration.c b/tests/intel/xe_sysfs_timeslice_duration.c
index 6518086225..c4efd9e11b 100644
--- a/tests/intel/xe_sysfs_timeslice_duration.c
+++ b/tests/intel/xe_sysfs_timeslice_duration.c
@@ -115,10 +115,11 @@ static uint64_t __test_timeout(int fd, int engine, unsigned int timeout, uint16_
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;
+ unsigned int saved, old_pt;
uint64_t elapsed;
uint64_t epsilon;
+ igt_assert(igt_sysfs_scanf(engine, "preempt_timeout_us", "%u", &old_pt) == 1);
igt_require(igt_sysfs_printf(engine, "preempt_timeout_us", "%u", 1) == 1);
igt_assert(igt_sysfs_scanf(engine, property[0], "%u", &saved) == 1);
igt_debug("Initial %s:%u\n", property[0], saved);
@@ -140,6 +141,9 @@ static void test_timeout(int fd, int engine, const char **property, uint16_t cla
}
set_timeslice_duration(engine, saved);
+ igt_assert_lte(0, igt_sysfs_printf(engine, "preempt_timeout_us", "%u", old_pt));
+ igt_sysfs_scanf(engine, "preempt_timeout_us", "%u", &saved);
+ igt_assert_eq(saved, old_pt);
}
#define MAX_GTS 8
@@ -159,6 +163,7 @@ igt_main
int gt_count = 0;
int fd = -1, sys_fd, gt;
int engines_fd[MAX_GTS], gt_fd[MAX_GTS];
+ unsigned int pts[MAX_GTS][XE_MAX_ENGINE_INSTANCE];
unsigned int tds[MAX_GTS][XE_MAX_ENGINE_INSTANCE];
igt_fixture {
@@ -177,9 +182,14 @@ igt_main
engines_fd[gt_count] = openat(gt_fd[gt_count], "engines", O_RDONLY);
igt_require(engines_fd[gt_count] != -1);
- while (igt_sysfs_get_next_engine(engines_fd[gt_count], &engine))
+ while (igt_sysfs_get_next_engine(engines_fd[gt_count], &engine)) {
igt_require(igt_sysfs_scanf(engine, "timeslice_duration_us", "%u",
- &tds[gt_count][e_count++]) == 1);
+ &tds[gt_count][e_count]) == 1);
+ igt_require(igt_sysfs_scanf(engine, "preempt_timeout_us", "%u",
+ &pts[gt_count][e_count]) == 1);
+
+ e_count++;
+ }
igt_require(e_count > 0);
gt_count++;
@@ -206,6 +216,13 @@ igt_main
while (igt_sysfs_get_next_engine(engines_fd[i], &engine)) {
unsigned int store = UINT_MAX;
+ igt_assert_lte(0, igt_sysfs_printf(engine, "preempt_timeout_us",
+ "%u", pts[i][e_count]));
+ igt_sysfs_scanf(engine, "preempt_timeout_us", "%u", &store);
+ igt_abort_on_f(store != pts[i][e_count],
+ "preempt_timeout_us not restored!\n");
+
+ store = UINT_MAX;
igt_assert_lte(0, igt_sysfs_printf(engine, "timeslice_duration_us",
"%u", tds[i][e_count]));
igt_sysfs_scanf(engine, "timeslice_duration_us", "%u", &store);
--
2.43.0
next prev parent reply other threads:[~2024-11-07 22:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 22:52 [PATCH v5 0/3] test/intel/xe_sysfs: Restore sysfs params correctly Jonathan Cavitt
2024-11-07 22:52 ` [PATCH v5 1/3] lib/igt_sysfs: Add igt_sysfs_get_next_engine Jonathan Cavitt
2024-11-15 14:36 ` Kamil Konieczny
2024-11-15 16:23 ` Cavitt, Jonathan
2024-11-07 22:52 ` [PATCH v5 2/3] tests/intel/xe_sysfs*: Restore values on test failure Jonathan Cavitt
2024-11-07 22:52 ` Jonathan Cavitt [this message]
2024-11-07 23:14 ` ✗ GitLab.Pipeline: warning for test/intel/xe_sysfs: Restore sysfs params correctly Patchwork
2024-11-07 23:40 ` ✓ CI.xeBAT: success " Patchwork
2024-11-08 0:03 ` ✓ Fi.CI.BAT: " Patchwork
2024-11-08 3:10 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-11-09 6:11 ` ✗ 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=20241107225254.302010-4-jonathan.cavitt@intel.com \
--to=jonathan.cavitt@intel.com \
--cc=alex.zuo@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=saurabhg.gupta@intel.com \
--cc=vinay.belgaumkar@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