Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Ewelina Musial <ewelina.musial@intel.com>,
	Petri Latvala <adrinael@adrinael.net>,
	Karol Krol <karol.krol@intel.com>
Subject: [PATCH i-g-t v1 1/1] runner/executor: Use bootime for time checks
Date: Fri, 28 Mar 2025 17:33:42 +0100	[thread overview]
Message-ID: <20250328163342.119140-2-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20250328163342.119140-1-kamil.konieczny@linux.intel.com>

Runner is printing time to stdout/stderr with CLOCK_BOOTTIME but
when measuring time for a test it is using an igt library which
uses CLOCK_MONOTONIC. This leads to an errors when calculating
time left for tests using suspend or hibernate. For example log:

[77.376851] [020/123] (932s left) kms_flip (2x-flip-vs-suspend)
[77.592412] Starting subtest: 2x-flip-vs-suspend
[77.604996] Starting dynamic subtest: AB-DP2-HDMI-A3
[115.135795] Dynamic subtest AB-DP2-HDMI-A3: SUCCESS (6.776s)

shows test runs for around 6 seconds, while wall time shows
it took around 38 seconds.

  Create a separate, runner specific function for time measure
and use it where current time is needed.

Cc: Ewelina Musial <ewelina.musial@intel.com>
Cc: Petri Latvala <adrinael@adrinael.net>
Reported-by: Karol Krol <karol.krol@intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 runner/executor.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/runner/executor.c b/runner/executor.c
index 9c8bf90f0..30e2420af 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -47,6 +47,12 @@ static struct {
 	size_t num_dogs;
 } watchdogs;
 
+static void runner_gettime(struct timespec *tv)
+{
+	if (clock_gettime(CLOCK_BOOTTIME, tv))
+		clock_gettime(CLOCK_REALTIME, tv);
+}
+
 __attribute__((format(printf, 2, 3)))
 static void __logf__(FILE *stream, const char *fmt, ...)
 {
@@ -54,8 +60,7 @@ static void __logf__(FILE *stream, const char *fmt, ...)
 	struct timespec tv;
 	va_list ap;
 
-	if (clock_gettime(CLOCK_BOOTTIME, &tv))
-		clock_gettime(CLOCK_REALTIME, &tv);
+	runner_gettime(&tv);
 	fprintf(stream, "[%ld.%06ld] ", tv.tv_sec, tv.tv_nsec / 1000);
 
 	va_start(ap, fmt);
@@ -961,7 +966,7 @@ static int monitor_output(pid_t child,
 	bool socket_comms_used = false; /* whether the test actually uses comms */
 	bool results_received = false; /* whether we already have test results that might need overriding if we detect an abort condition */
 
-	igt_gettime(&time_beg);
+	runner_gettime(&time_beg);
 	time_last_activity = time_last_subtest = time_killed = time_beg;
 
 	if (errfd > nfds)
@@ -1024,7 +1029,7 @@ static int monitor_output(pid_t child,
 			return -1;
 		}
 
-		igt_gettime(&time_now);
+		runner_gettime(&time_now);
 
 		/* TODO: Refactor these handlers to their own functions */
 		if (outfd >= 0 && FD_ISSET(outfd, &set)) {
-- 
2.49.0


  reply	other threads:[~2025-03-28 16:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-28 16:33 [PATCH i-g-t v1 0/1] runner: Use BOOTTIME for time checks Kamil Konieczny
2025-03-28 16:33 ` Kamil Konieczny [this message]
2025-04-02 10:17   ` [PATCH i-g-t v1 1/1] runner/executor: Use bootime " Piatkowski, Dominik Karol
2025-04-02 11:15   ` Peter Senna Tschudin
2025-03-29  2:42 ` ✓ Xe.CI.BAT: success for runner: Use BOOTTIME " Patchwork
2025-03-29  2:56 ` ✓ i915.CI.BAT: " Patchwork
2025-03-29  8:13 ` ✗ i915.CI.Full: failure " Patchwork
2025-03-29 21:16 ` ✗ Xe.CI.Full: " Patchwork
2025-04-06 20:03 ` 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=20250328163342.119140-2-kamil.konieczny@linux.intel.com \
    --to=kamil.konieczny@linux.intel.com \
    --cc=adrinael@adrinael.net \
    --cc=ewelina.musial@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=karol.krol@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