Re: [RFC/PATCH] s390x: Add live dump detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Dave,

On Thu, 19 Apr 2012 14:44:43 -0400 (EDT)
Dave Anderson <anderson@xxxxxxxxxx> wrote:

[snip]

> I would have no problem with adding a new LIVE_DUMP flag to
> pc->flags2, and just checking it in display_sys_stats() and
> non_matching_kernel() as you've done below.  In dealing with
> dumpfiles generated from snap.so, the "bt" command is pretty
> much the only command that probably should be restricted.
> However, I don't restrict "bt" with snap.so vmcores because
> currently there's no magic/signature/whatever that indicates
> what kind of dump it is.  But if you implement a new LIVE_DUMP
> flag, I might do it there as well so we've got some consistency.
> 
> What do you think about that?

Sounds good. So what about introducing a new macro LIVE() that
indicates that the dump or live system is inconsistent.

Something like the following:
---
 defs.h   |    2 ++
 kernel.c |    9 +++++++--
 main.c   |    2 ++
 s390x.c  |   12 ++++++++++++
 4 files changed, 23 insertions(+), 2 deletions(-)

--- a/defs.h
+++ b/defs.h
@@ -203,6 +203,7 @@ struct number_option {
 
 #define ACTIVE()            (pc->flags & LIVE_SYSTEM)
 #define DUMPFILE()          (!(pc->flags & LIVE_SYSTEM))
+#define LIVE()              (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)
 #define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP)
 #define DUMPFILE_TYPES      (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP)
 #define REMOTE()            (pc->flags2 & REMOTE_DAEMON)
@@ -446,6 +447,7 @@ struct program_context {
 #define REMOTE_DAEMON  (0x08ULL)
 #define ERASEINFO_DATA (0x10ULL)
 #define GDB_CMD_MODE   (0x20ULL)
+#define LIVE_DUMP      (0x40ULL)
 #define FLAT_FORMAT() (pc->flags2 & FLAT)
 #define ELF_NOTES_VALID() (pc->flags2 & ELF_NOTES)
 	char *cleanup;
--- a/kernel.c
+++ b/kernel.c
@@ -992,6 +992,8 @@ non_matching_kernel(void)
                         else
                                 fprintf(fp, "%s", pc->dumpfile);
                 }
+		if (LIVE())
+			fprintf(fp, " [LIVE DUMP]");
         }
 
 	fprintf(fp, "\n\n");
@@ -2072,9 +2074,9 @@ else
 	}
 
 	if (active) {
-		if (ACTIVE())
+		if (LIVE())
 			error(FATAL, 
-			    "-a option not supported on a live system\n");
+			    "-a option not supported on a live system or live dump\n");
 
 		if (bt->flags & BT_THREAD_GROUP)
 			error(FATAL, 
@@ -4098,6 +4100,9 @@ display_sys_stats(void)
                 		fprintf(fp, "%s", pc->dumpfile);
 		}
 
+		if (LIVE())
+			fprintf(fp, "  [LIVE DUMP]");
+
 		if (NETDUMP_DUMPFILE() && is_partial_netdump())
 			fprintf(fp, "  [PARTIAL DUMP]");
 
--- a/main.c
+++ b/main.c
@@ -1110,6 +1110,8 @@ dump_program_context(void)
 	if (pc->flags & LIVE_SYSTEM)
 		sprintf(&buf[strlen(buf)], "%sLIVE_SYSTEM", 
 			others++ ? "|" : "");
+	if (pc->flags2 & LIVE_DUMP)
+		sprintf(&buf[strlen(buf)], "%sLIVE_DUMP", others++ ? "|" : "");
 	if (pc->flags & TTY)
 		sprintf(&buf[strlen(buf)], "%sTTY", others++ ? "|" : "");
         if (pc->flags & IN_FOREACH)
--- a/s390x.c
+++ b/s390x.c
@@ -328,6 +328,17 @@ static void s390x_process_elf_notes(void
 	}
 }
 
+static void s390x_check_live(void)
+{
+	unsigned long long live_magic;
+
+	readmem(0, KVADDR, &live_magic, sizeof(live_magic), "live_magic",
+		RETURN_ON_ERROR | QUIET);
+
+	if (live_magic == 0x4c49564544554d50ULL)
+		pc->flags2 |= LIVE_DUMP;
+}
+
 /*
  *  Do all necessary machine-specific setup here.  This is called several
  *  times during initialization.
@@ -402,6 +413,7 @@ s390x_init(int when)
 		break;
 
 	case POST_INIT:
+		s390x_check_live();
 		break;
 	}
 }
[RFC/PATCH] s390x: Add live dump detection

On s390 we will have a dump method that creates live dumps, similar to
the snap.so crash plugin. Because Linux is not stopped while the dump
is created, the resulting dump is not consistent. Therefore it is important
that the crash tool informs the user about this issue.

The dump tool writes a magic number (ASCII "LIVEDUMP") into the first 8
bytes of the dump memory. With this patch this is checked in POST_INIT by
the s390x backend crash code. If the magic is found, the new LIVE_DUMP
flag is set. This ensures that commands that do not work with /dev/mem also
fail with s390x live dumps.

Example:

crash> bt -a
bt: -a option not supported on a live system

In addition to that with this patch crash prints a "[LIVE DUMP]" info tag
for live dump files at startup (similar to [PARTIAL DUMP]):

$ crash livedump vmlinux
      KERNEL: /boot/vmlinux
    DUMPFILE: dump.s390 [LIVE DUMP]
---
 defs.h   |    2 ++
 kernel.c |    9 +++++++--
 main.c   |    2 ++
 s390x.c  |   12 ++++++++++++
 4 files changed, 23 insertions(+), 2 deletions(-)

--- a/defs.h
+++ b/defs.h
@@ -203,6 +203,7 @@ struct number_option {
 
 #define ACTIVE()            (pc->flags & LIVE_SYSTEM)
 #define DUMPFILE()          (!(pc->flags & LIVE_SYSTEM))
+#define LIVE()              (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)
 #define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP)
 #define DUMPFILE_TYPES      (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP)
 #define REMOTE()            (pc->flags2 & REMOTE_DAEMON)
@@ -446,6 +447,7 @@ struct program_context {
 #define REMOTE_DAEMON  (0x08ULL)
 #define ERASEINFO_DATA (0x10ULL)
 #define GDB_CMD_MODE   (0x20ULL)
+#define LIVE_DUMP      (0x40ULL)
 #define FLAT_FORMAT() (pc->flags2 & FLAT)
 #define ELF_NOTES_VALID() (pc->flags2 & ELF_NOTES)
 	char *cleanup;
--- a/kernel.c
+++ b/kernel.c
@@ -992,6 +992,8 @@ non_matching_kernel(void)
                         else
                                 fprintf(fp, "%s", pc->dumpfile);
                 }
+		if (LIVE())
+			fprintf(fp, " [LIVE DUMP]");
         }
 
 	fprintf(fp, "\n\n");
@@ -2072,9 +2074,9 @@ else
 	}
 
 	if (active) {
-		if (ACTIVE())
+		if (LIVE())
 			error(FATAL, 
-			    "-a option not supported on a live system\n");
+			    "-a option not supported on a live system or live dump\n");
 
 		if (bt->flags & BT_THREAD_GROUP)
 			error(FATAL, 
@@ -4098,6 +4100,9 @@ display_sys_stats(void)
                 		fprintf(fp, "%s", pc->dumpfile);
 		}
 
+		if (LIVE())
+			fprintf(fp, "  [LIVE DUMP]");
+
 		if (NETDUMP_DUMPFILE() && is_partial_netdump())
 			fprintf(fp, "  [PARTIAL DUMP]");
 
--- a/main.c
+++ b/main.c
@@ -1110,6 +1110,8 @@ dump_program_context(void)
 	if (pc->flags & LIVE_SYSTEM)
 		sprintf(&buf[strlen(buf)], "%sLIVE_SYSTEM", 
 			others++ ? "|" : "");
+	if (pc->flags2 & LIVE_DUMP)
+		sprintf(&buf[strlen(buf)], "%sLIVE_DUMP", others++ ? "|" : "");
 	if (pc->flags & TTY)
 		sprintf(&buf[strlen(buf)], "%sTTY", others++ ? "|" : "");
         if (pc->flags & IN_FOREACH)
--- a/s390x.c
+++ b/s390x.c
@@ -328,6 +328,17 @@ static void s390x_process_elf_notes(void
 	}
 }
 
+static void s390x_check_live(void)
+{
+	unsigned long long live_magic;
+
+	readmem(0, KVADDR, &live_magic, sizeof(live_magic), "live_magic",
+		RETURN_ON_ERROR | QUIET);
+
+	if (live_magic == 0x4c49564544554d50ULL)
+		pc->flags2 |= LIVE_DUMP;
+}
+
 /*
  *  Do all necessary machine-specific setup here.  This is called several
  *  times during initialization.
@@ -402,6 +413,7 @@ s390x_init(int when)
 		break;
 
 	case POST_INIT:
+		s390x_check_live();
 		break;
 	}
 }
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux