[Crash-utility] [PATCH] crash: Show kernel tainted status in display_sys_stats()

Aaron Tomlin atomlin at redhat.com
Fri Nov 21 15:10:39 UTC 2014


The sys command displays essential system information and it is often
shown by default when crash is started in non-silent mode. It might be
considered helpful to report if the kernel is tainted or not when
sys is run without any arguments. This patch makes this change.
The intended output is as follows:

      KERNEL: /usr/lib/debug/lib/modules/3.16.4-200.fc20.x86_64/vmlinux
    DUMPFILE: /dev/crash
        CPUS: 4
        DATE: Fri Nov 21 15:02:56 2014
      UPTIME: 6 days, 07:41:22
LOAD AVERAGE: 0.29, 0.20, 0.15
       TASKS: 397
    NODENAME: atomlin.usersys.redhat.com
     RELEASE: 3.16.4-200.fc20.x86_64
     VERSION: #1 SMP Mon Oct 6 12:57:00 UTC 2014
     TAINTED: YES
     MACHINE: x86_64  (2693 Mhz)
      MEMORY: 7.7 GB
         PID: 12172
     COMMAND: "crash"
        TASK: ffff8801b0aacf00  [THREAD_INFO: ffff8801b1e1c000]
         CPU: 0
       STATE: TASK_RUNNING (ACTIVE)

If the tainted_mask or tainted symbol does not exist then nothing is
displayed.

Signed-off-by: Aaron Tomlin <atomlin at redhat.com>
---
 kernel.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel.c b/kernel.c
index 1cb0967..a22ce60 100644
--- a/kernel.c
+++ b/kernel.c
@@ -4691,8 +4691,12 @@ display_sys_stats(void)
 {
         struct new_utsname *uts;
         char buf[BUFSIZE];
+	ulong tainted_mask;
+	int tainted;
 	ulong mhz;
 
+	tainted_mask = tainted = 0;
+
 	uts = &kt->utsname;
 
 //	if (!(pc->flags & RUNTIME) && !DUMPFILE() && !GDB_PATCHED())
@@ -4834,6 +4838,13 @@ display_sys_stats(void)
 	fprintf(fp, "    NODENAME: %s\n", uts->nodename); 
         fprintf(fp, "     RELEASE: %s\n", uts->release); 
 	fprintf(fp, "     VERSION: %s\n", uts->version); 
+	if (kernel_symbol_exists("tainted_mask")) {
+		get_symbol_data("tainted_mask", sizeof(ulong), &tainted_mask);
+		fprintf(fp, "     TAINTED: %s\n", tainted_mask ? "YES" : "NO");
+	} else if (kernel_symbol_exists("tainted")) {
+		get_symbol_data("tainted", sizeof(int), &tainted);
+		fprintf(fp, "     TAINTED: %s\n", tainted ? "YES" : "NO");
+	}
 	fprintf(fp, "     MACHINE: %s  ", uts->machine);
 	if ((mhz = machdep->processor_speed()))
 		fprintf(fp, "(%ld Mhz)\n", mhz);
-- 
1.9.3




More information about the Crash-utility mailing list