summaryrefslogtreecommitdiff
path: root/runner
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-04-07 09:28:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-04-07 19:38:42 +0100
commit797849120b164bf8930a1cc65c8a09c6650c6a3d (patch)
treebafdecd5f6bcf89effa75bbebfed811ef0f2ba2f /runner
parent75641939835558eb3e338a70f12025c19afcb896 (diff)
runner: Show why we dump the task state
Include the reason why we are dumping the task state (test timeout) in the kmsg log prior to the task state. Hopefully this helps when reading the dump. v2: Use asprintf to combine the strings into one to avoid error prone manual string handling and enjoy one single write() into the kmsg. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'runner')
-rw-r--r--runner/executor.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/runner/executor.c b/runner/executor.c
index 1b69f9c5..b85cdb44 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -27,6 +27,9 @@
#include "executor.h"
#include "output_strings.h"
+#define KMSG_HEADER "[IGT] "
+#define KMSG_WARN 4
+
static struct {
int *fds;
size_t num_dogs;
@@ -678,9 +681,30 @@ static bool sysrq(char cmd)
return success;
}
-static void show_kernel_task_state(void)
+static void kmsg_log(int severity, const char *msg)
{
+ char *str = NULL;
+ int len, fd;
+
+ len = asprintf(&str, "<%d>%s%s", severity, KMSG_HEADER, msg);
+ if (!str)
+ return;
+
+ fd = open("/dev/kmsg", O_WRONLY);
+ if (fd != -1) {
+ write(fd, str, len);
+ close(fd);
+ }
+
+ free(str);
+}
+
+static const char *show_kernel_task_state(const char *msg)
+{
+ kmsg_log(KMSG_WARN, msg);
sysrq('t');
+
+ return msg;
}
static const char *need_to_timeout(struct settings *settings,
@@ -725,16 +749,12 @@ static const char *need_to_timeout(struct settings *settings,
return "Killing the test because the kernel is tainted.\n";
if (settings->per_test_timeout != 0 &&
- time_since_subtest > settings->per_test_timeout) {
- show_kernel_task_state();
- return "Per-test timeout exceeded. Killing the current test with SIGQUIT.\n";
- }
+ time_since_subtest > settings->per_test_timeout)
+ return show_kernel_task_state("Per-test timeout exceeded. Killing the current test with SIGQUIT.\n");
if (settings->inactivity_timeout != 0 &&
- time_since_activity > settings->inactivity_timeout) {
- show_kernel_task_state();
- return "Inactivity timeout exceeded. Killing the current test with SIGQUIT.\n";
- }
+ time_since_activity > settings->inactivity_timeout)
+ return show_kernel_task_state("Inactivity timeout exceeded. Killing the current test with SIGQUIT.\n");
return NULL;
}