public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v3] runner: Show kernel state on detecting test timeout
Date: Fri, 11 Oct 2019 14:22:37 +0100	[thread overview]
Message-ID: <20191011132237.28035-1-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20191011131836.27778-1-chris@chris-wilson.co.uk>

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@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 runner/executor.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/runner/executor.c b/runner/executor.c
index 1a00237fc..2bb828278 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -638,6 +638,25 @@ 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;
+}
+
+static void show_kernel_task_state(void)
+{
+	sysrq('t');
+}
+
 /*
  * Returns:
  *  =0 - Success
@@ -728,6 +747,8 @@ static int monitor_output(pid_t child,
 
 			switch (killed) {
 			case 0:
+				show_kernel_task_state();
+
 				if (settings->log_level >= LOG_LEVEL_NORMAL) {
 					outf("Timeout. Killing the current test with SIGQUIT.\n");
 					fflush(stdout);
-- 
2.23.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-10-11 13:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 13:18 [igt-dev] [PATCH i-g-t] runner: Show kernel state on detecting test timeout Chris Wilson
2019-10-11 13:20 ` [igt-dev] [PATCH i-g-t v2] " Chris Wilson
2019-10-11 13:22 ` Chris Wilson [this message]
2019-10-14  6:58   ` [igt-dev] [PATCH i-g-t v3] " Petri Latvala
2019-10-14  7:12     ` Chris Wilson
2019-10-14 12:53       ` Petri Latvala
2019-10-11 15:19 ` [igt-dev] ✓ Fi.CI.BAT: success for runner: Show kernel state on detecting test timeout (rev3) Patchwork
2019-10-11 23:40 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20191011132237.28035-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@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