public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] runner: Make taint aborts more verbose
@ 2018-11-26  8:52 Arkadiusz Hiler
  2018-11-26  9:12 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Arkadiusz Hiler @ 2018-11-26  8:52 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Martin Peres

Provide the reader with the taint names and a short explanation, as well
as point in the direction of the dmesg for more details.

Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Martin Peres <martin.peres@linux.intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 runner/executor.c | 42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/runner/executor.c b/runner/executor.c
index 2038c3fd..954cd9a7 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -139,24 +139,46 @@ static char *handle_lockdep(void)
 
 static char *handle_taint(void)
 {
-	const unsigned long bad_taints =
-		0x20  | /* TAINT_PAGE */
-		0x80  | /* TAINT_DIE */
-		0x200; /* TAINT_OOPS */
-	unsigned long taints = 0;
+	/* see Linux's include/linux/kernel.h */
+	static const struct {
+		unsigned long bit;
+		const char *explanation;
+	} taints[] = {
+	  {(1 << 5), "TAINT_BAD_PAGE: Bad page reference or an unexpected page flags."},
+	  {(1 << 7), "TAINT_DIE: Kernel has died - BUG/OOPS."},
+	  {(1 << 9), "TAINT_WARN: WARN_ON has happened."},
+	  {0, 0}};
+
+	unsigned long system_taints = 0;
 	char *reason = NULL;
 	FILE *f;
 
+	unsigned long bad_taints = 0;
+	for (typeof(*taints) *taint = taints; taint->bit; taint++)
+		bad_taints |= taint->bit;
+
 	f = fopen("/proc/sys/kernel/tainted", "r");
 	if (f) {
-		fscanf(f, "%lu", &taints);
+		fscanf(f, "%lu", &system_taints);
 		fclose(f);
 	}
 
-	if (taints & bad_taints)
-		asprintf(&reason,
-			 "Kernel tainted (%#lx -- %lx)",
-			 taints, taints & bad_taints);
+	if (system_taints & bad_taints) {
+		asprintf(&reason, "Kernel badly tainted (%#lx) "
+			 "(check dmesg for details if possible):\n",
+			 system_taints);
+
+		for (typeof(*taints) *taint = taints; taint->bit; taint++) {
+			if (taint->bit & system_taints) {
+				char *old_reason = reason;
+				asprintf(&reason, "%s\t(%#lx) %s\n",
+						old_reason,
+						taint->bit,
+						taint->explanation);
+				free(old_reason);
+			}
+		}
+	}
 
 	return reason;
 }
-- 
2.19.1

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-03-27 11:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-26  8:52 [igt-dev] [PATCH i-g-t] runner: Make taint aborts more verbose Arkadiusz Hiler
2018-11-26  9:12 ` Chris Wilson
2018-11-26 10:36   ` Arkadiusz Hiler
2018-11-26 12:22     ` Petri Latvala
2019-03-27 11:19       ` Petri Latvala
2018-11-26 13:26 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-11-26 17:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox