public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org, zbigniew.kempczynski@intel.com
Cc: Sobin Thomas <sobin.thomas@intel.com>
Subject: [PATCH i-g-t 1/1] runner/executor: Adaptive dmesg disk write
Date: Tue, 13 Jan 2026 08:06:25 +0000	[thread overview]
Message-ID: <20260113080625.208986-2-sobin.thomas@intel.com> (raw)
In-Reply-To: <20260113080625.208986-1-sobin.thomas@intel.com>

In current scenario  when disk usage limit is exceeded during a test, in
batch mode the test exits abruptly.  Implement a logging suppression
mechanism that drains kernel messages without writing to disk, allowing
the test to complete.

- Add suppress parameter to dump_dmesg() to control disk write
- Return 0 bytes written when suppression enabled (prevents disk writes)
- Write status message when limit is reached, then continue test

Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
 runner/executor.c | 65 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 54 insertions(+), 11 deletions(-)

diff --git a/runner/executor.c b/runner/executor.c
index 847abe481..9fc148d4b 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -638,7 +638,7 @@ const char *get_out_filename(int fid)
 }
 
 /* Returns the number of bytes written to disk, or a negative number on error */
-static long dump_dmesg(int kmsgfd, int outfd, ssize_t size)
+static long dump_dmesg(int kmsgfd, int outfd, ssize_t size, bool suppress)
 {
 	/*
 	 * Write kernel messages to the log file until we reach
@@ -656,6 +656,7 @@ static long dump_dmesg(int kmsgfd, int outfd, ssize_t size)
 	char buf[2048];
 	ssize_t r;
 	long written = 0;
+	long drained = 0;
 
 	if (kmsgfd < 0)
 		return 0;
@@ -703,16 +704,23 @@ static long dump_dmesg(int kmsgfd, int outfd, ssize_t size)
 				continue;
 			} else if (errno != EAGAIN) {
 				errf("Error reading from kmsg: %m\n");
+				if (comparefd >= 0)
+					close(comparefd);
 				return -errno;
 			}
 
 			/* EAGAIN, so we're done dumping */
-			close(comparefd);
-			return written;
+			if (comparefd >= 0)
+				close(comparefd);
+			return suppress ? 0 : written;
 		}
 
-		write(outfd, buf, r);
-		written += r;
+		if (!suppress) {
+			write(outfd, buf, r);
+			written += r;
+		} else {
+			drained += r;
+		}
 
 		if (comparefd < 0 && sscanf(buf, "%u,%llu,%llu,%c;",
 					    &flags, &seq, &usec, &cont) == 4) {
@@ -722,15 +730,20 @@ static long dump_dmesg(int kmsgfd, int outfd, ssize_t size)
 			 * enough.
 			 */
 			if (seq >= cmpseq)
-				return written;
+				return suppress ? 0 : written;
 		}
 
-		if (size && written >= size) {
+		if (!suppress && size && written >= size) {
 			if (comparefd >= 0)
 				close(comparefd);
 
 			return written;
 		}
+		if (suppress && size && drained >= size) {
+			if (comparefd >= 0)
+				close(comparefd);
+			return 0;
+		}
 	}
 }
 
@@ -984,6 +997,8 @@ static int monitor_output(pid_t child,
 	long dmesgwritten;
 	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 */
+	bool logging_disabled = false;
+	bool suppress_logging = false;
 
 	runner_gettime(&time_beg);
 	time_last_activity = time_last_subtest = time_killed = time_beg;
@@ -1309,7 +1324,8 @@ static int monitor_output(pid_t child,
 		if (kmsgfd >= 0 && FD_ISSET(kmsgfd, &set)) {
 			time_last_activity = time_now;
 
-			dmesgwritten = dump_dmesg(kmsgfd, outputs[_F_DMESG], dmsg_chunk_size);
+			dmesgwritten = dump_dmesg(kmsgfd, outputs[_F_DMESG], dmsg_chunk_size,
+						  suppress_logging);
 			if (settings->sync)
 				fdatasync(outputs[_F_DMESG]);
 
@@ -1321,6 +1337,32 @@ static int monitor_output(pid_t child,
 			}
 		}
 
+		/* Check if we need to disable logging due to disk usage limit */
+
+		if (!logging_disabled && disk_usage_limit_exceeded(settings, disk_usage)) {
+			char msg[256];
+
+			suppress_logging = true;
+			logging_disabled = true;
+
+			/* Write warning message to output files */
+			snprintf(msg, sizeof(msg),
+				 "\n[RUNNER] Disk usage limit reached (%zu/%zu bytes). "
+				 "Disabling further logging and DRM debug. Test continues.\n ",
+				 disk_usage, settings->disk_usage_limit);
+
+			write(outputs[_F_OUT], msg, strlen(msg));
+			write(outputs[_F_ERR], msg, strlen(msg));
+
+			if (settings->log_level >= LOG_LEVEL_NORMAL)
+				fprintf(stderr, "%s", msg);
+
+			if (settings->sync) {
+				fdatasync(outputs[_F_OUT]);
+				fdatasync(outputs[_F_ERR]);
+			}
+		}
+
 		if (sigfd >= 0 && FD_ISSET(sigfd, &set)) {
 			double time;
 
@@ -1539,7 +1581,7 @@ static int monitor_output(pid_t child,
 						 igt_time_elapsed(&time_killed, &time_now),
 						 disk_usage);
 
-		if (timeout_reason) {
+		if (timeout_reason && !suppress_logging) {
 			if (killed == SIGKILL) {
 				/* Nothing that can be done, really. Let's tell the caller we want to abort. */
 
@@ -1553,7 +1595,8 @@ static int monitor_output(pid_t child,
 				}
 
 				dmsg_chunk_size = calc_last_dmesg_chunk(settings->disk_usage_limit, disk_usage);
-				dump_dmesg(kmsgfd, outputs[_F_DMESG], dmsg_chunk_size);
+				dump_dmesg(kmsgfd, outputs[_F_DMESG], dmsg_chunk_size,
+					   suppress_logging);
 				if (settings->sync)
 					fdatasync(outputs[_F_DMESG]);
 
@@ -1584,7 +1627,7 @@ static int monitor_output(pid_t child,
 	}
 
 	dmsg_chunk_size = calc_last_dmesg_chunk(settings->disk_usage_limit, disk_usage);
-	dmesgwritten = dump_dmesg(kmsgfd, outputs[_F_DMESG], dmsg_chunk_size);
+	dmesgwritten = dump_dmesg(kmsgfd, outputs[_F_DMESG], dmsg_chunk_size, suppress_logging);
 	if (settings->sync)
 		fdatasync(outputs[_F_DMESG]);
 	if (dmesgwritten > 0) {
-- 
2.51.0


  reply	other threads:[~2026-01-13  8:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13  8:06 [PATCH i-g-t 0/1] runner/executor: Adaptive dmesg disk write Sobin Thomas
2026-01-13  8:06 ` Sobin Thomas [this message]
2026-01-16 16:34   ` [PATCH i-g-t 1/1] " Kamil Konieczny
2026-01-13  9:01 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-01-13  9:21 ` ✓ i915.CI.BAT: " Patchwork
2026-01-13 13:08 ` ✓ i915.CI.Full: " Patchwork
2026-01-13 14:44 ` ✗ 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=20260113080625.208986-2-sobin.thomas@intel.com \
    --to=sobin.thomas@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@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