[igt-dev] [PATCH i-g-t v2] runner: Show kernel state on detecting test timeout

Chris Wilson chris at chris-wilson.co.uk
Fri Oct 11 13:20:13 UTC 2019


When our watchdog expires and we declare the test has timed out, we send
it a signal to terminate. The test will produce a backtrace upon receipt
of that signal, but often times (especially as we do test and debug the
kernel), the test is hung inside the kernel. So we need the kernel state
to see where the live/deadlock is occuring. Enter sysrq-t to show the
backtraces of all processes (as the one we are searching for may be
sleeping).

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala at intel.com>
---
 runner/executor.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/runner/executor.c b/runner/executor.c
index 1a00237fc..74102fab9 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -638,6 +638,20 @@ static const char *get_cmdline(pid_t pid, char *buf, ssize_t len)
 	return buf;
 }
 
+static bool sysrq(char cmd)
+{
+	bool success = false;
+	int fd;
+
+	fd = open("/proc/sysrq-trigger", O_WRONLY);
+	if (fd >= 0) {
+		success = write(fd, cmd, 1) == 1;
+		close(fd);
+	}
+
+	return success;
+}
+
 /*
  * Returns:
  *  =0 - Success
@@ -728,6 +742,8 @@ static int monitor_output(pid_t child,
 
 			switch (killed) {
 			case 0:
+				sysrq('t'); /* show task state */
+
 				if (settings->log_level >= LOG_LEVEL_NORMAL) {
 					outf("Timeout. Killing the current test with SIGQUIT.\n");
 					fflush(stdout);
-- 
2.23.0



More information about the igt-dev mailing list