[igt-dev] [RFC PATCH i-g-t 6/6] lib/core: Use whitelist with kmsg filter
Petri Latvala
petri.latvala at intel.com
Wed Feb 21 15:19:35 UTC 2018
dmesg messages of level >=warn don't result in an IGT_LOG_WARN if they
match a whitelist regexp now.
The whitelist is not configureable without rebuilding, and it's not
even possible to use a different whitelist for different drivers;
launching the kmsg monitor happens way before opening the driver (if
any).
Signed-off-by: Petri Latvala <petri.latvala at intel.com>
---
lib/igt_core.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 5c93432d..d4495c3f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -55,6 +55,7 @@
#include <limits.h>
#include <locale.h>
#include <uwildmat/uwildmat.h>
+#include <regex.h>
#ifdef HAVE_GLIB
#include <glib.h>
#endif
@@ -581,6 +582,16 @@ static void oom_adjust_for_doom(void)
}
+const char IGT_DMESG_WHITELIST[] =
+ "IRQ [0-9]+: no longer affine to CPU[0-9]+"
+ "|IRQ fixup: irq [0-9]+ move in progress, old vector [0-9]+"
+ "|Setting dangerous option [a-z_]+ - tainting kernel"
+ "|Suspending console\\(s\\) \\(use no_console_suspend to debug\\)"
+ "|cache: parent cpu[0-9]+ should not be sleeping"
+ "|hpet[0-9]+: lost [0-9]+ rtc interrupts"
+ "|usb usb[0-9]+: root hub lost power or was reset"
+ ;
+
static void *kmsg_capture(void *arg)
{
/*
@@ -593,6 +604,13 @@ static void *kmsg_capture(void *arg)
char *line = NULL;
size_t line_len = 0;
ssize_t read;
+ regex_t re;
+
+ if (regcomp(&re, IGT_DMESG_WHITELIST, REG_EXTENDED | REG_NOSUB) != 0) {
+ igt_warn("Cannot compile dmesg whitelist regexp\n");
+ fclose(kmsg_file);
+ return NULL;
+ }
while ((read = getline(&line, &line_len, kmsg_file))) {
int s;
@@ -613,7 +631,8 @@ static void *kmsg_capture(void *arg)
&seq, &ts_usec, &continuation);
if (s == 4) {
- if ((flags & 0x7) <= 4)
+ if ((flags & 0x7) <= 4 &&
+ regexec(&re, line, (size_t)0, NULL, 0))
level = IGT_LOG_WARN;
else
level = IGT_LOG_DEBUG;
--
2.14.1
More information about the igt-dev
mailing list