Skip to content

crash: Add Snappy Compression Support

HATAYAMA Daisuke kexec 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest0 of 3 patches 0 repliesNew

Patches in v1 No applies recorded yet

None of the 3 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] crash: Add Snappy Compression Support

This patch series add snappy compression support for crash utility, applied on top of v6.0.8.

snappy is fast compressoin algorhythm like lzo, but it's more optimized than lzo on x86 machines and some other archs.

A lot of benchmark is available on the web. Here I only point at my benchmark I posted a few weeks ago,

- http://lists.infradead.org/pipermail/kexec/2012-June/006425.html

where snappy shows mostly as good performance as simple copying on the worst case that input data increases its data size during compression; this means we can use snappy with mostly NO risk.

How to get snappy libraries:

1) Use yum framework to get snappy and snappy-devel packages, or

2) Visit official website: http://code.google.com/p/snappy/,
download snappy-<version>.tar.gz and then build it.

How to build crash utility with snappy support:

1) Put -DSNAPPY in CFLAGS.extra file and put -lsnappy in LDFRAGS.extra file.

2) Do make as always.

---

HATAYAMA Daisuke (3):
Add uncompression processing
Add snappy supporting flag
Add dump header for snappy

defs.h | 4 ++++
diskdump.c | 34 ++++++++++++++++++++++++++++++++++ diskdump.h | 2 ++

3 files changed, 40 insertions(+), 0 deletions(-)

--

Thanks.
HATAYAMA, Daisuke

From a93539aee34d6abb9ef19f33a438f79b7d26efef Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <[email protected]>
Date: Tue, 3 Jul 2012 11:43:30 +0900
Subject: [PATCH 1/3] Add dump header for snappy

---
 diskdump.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diskdump.h +2 -0
index bd99fbd..83fe009 100644
@@ -74,6 +74,8 @@ struct kdump_sub_header {
 /* page flags */
 #define DUMP_DH_COMPRESSED_ZLIB	0x1	/* page is compressed with zlib */
 #define DUMP_DH_COMPRESSED_LZO	0x2	/* page is compressed with lzo */
+#define DUMP_DH_COMPRESSED_SNAPPY	0x4
+					/* page is compressed with snappy */
 
 /* descriptor of each page for vmcore */
 typedef struct page_desc {
Signature · 1 line
1.7.7.6

From f521776ba910dee7352ca8ec31fa305929e36758 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <[email protected]>
Date: Tue, 3 Jul 2012 11:43:30 +0900
Subject: [PATCH 2/3] Add snappy supporting flag

---
 defs.h     |    1 +
 diskdump.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
defs.h +1 -0
index caa87c0..8eebc52 100755
@@ -283,6 +283,7 @@ struct number_option {
 #define DUMPFILE_SPLIT      (0x10)
 #define NO_ELF_NOTES        (0x20)
 #define LZO_SUPPORTED       (0x40)
+#define SNAPPY_SUPPORTED    (0x80)
 #define DISKDUMP_VALID()    (dd->flags & DISKDUMP_LOCAL)
 #define KDUMP_CMPRS_VALID() (dd->flags & KDUMP_CMPRS_LOCAL)
 #define KDUMP_SPLIT()       (dd->flags & DUMPFILE_SPLIT)
diskdump.c +6 -0
index d80eea4..4d194c5 100644
@@ -682,6 +682,10 @@ is_diskdump(char *file)
 		dd->flags |= LZO_SUPPORTED;
 #endif
 
+#ifdef SNAPPY
+	dd->flags |= SNAPPY_SUPPORTED;
+#endif
+
 	return TRUE;
 }
 
@@ -1309,6 +1313,8 @@ __diskdump_memory_dump(FILE *fp)
 		fprintf(fp, "%sNO_ELF_NOTES", others++ ? "|" : "");
 	if (dd->flags & LZO_SUPPORTED)
 		fprintf(fp, "%sLZO_SUPPORTED", others++ ? "|" : "");
+	if (dd->flags & SNAPPY_SUPPORTED)
+		fprintf(fp, "%sSNAPPY_SUPPORTED", others++ ? "|" : "");
         fprintf(fp, ") %s\n", FLAT_FORMAT() ? "[FLAT]" : "");
         fprintf(fp, "               dfd: %d\n", dd->dfd);
         fprintf(fp, "               ofp: %lx\n", (ulong)dd->ofp);
Signature · 1 line
1.7.7.6

From 7bf06a5c3e2db2ab8a1e566dbdfcd46a57ad2a43 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <[email protected]>
Date: Tue, 3 Jul 2012 11:43:30 +0900
Subject: [PATCH 3/3] Add uncompression processing

---
 defs.h     |    3 +++
 diskdump.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
defs.h +3 -0
index 8eebc52..f938c8c 100755
@@ -51,6 +51,9 @@
 #ifdef LZO
 #include <lzo/lzo1x.h>
 #endif
+#ifdef SNAPPY
+#include <snappy-c.h>
+#endif
 
 #ifndef ATTRIBUTE_UNUSED
 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
diskdump.c +28 -0
index 4d194c5..39f4652 100644
@@ -874,6 +874,34 @@ cache_page(physaddr_t paddr)
 			return READ_ERROR;
 		}
 #endif
+	} else if (pd.flags & DUMP_DH_COMPRESSED_SNAPPY) {
+
+		if (!(dd->flags & SNAPPY_SUPPORTED)) {
+			error(INFO, "%s: uncompress failed: no snappy compression support\n",
+			      DISKDUMP_VALID() ? "diskdump" : "compressed kdump");
+			return READ_ERROR;
+		}
+
+#ifdef SNAPPY
+		ret = snappy_uncompressed_length((char *)dd->compressed_page,
+						 pd.size, &retlen);
+		if (ret != SNAPPY_OK) {
+			error(INFO, "%s: uncompress failed: %d\n",
+			      DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
+			      ret);
+			return READ_ERROR;
+		}
+
+		ret = snappy_uncompress((char *)dd->compressed_page, pd.size,
+					(char *)dd->page_cache_hdr[i].pg_bufptr,
+					&retlen);
+		if ((ret != SNAPPY_OK) || (retlen != block_size)) {
+			error(INFO, "%s: uncompress failed: %d\n", 
+			      DISKDUMP_VALID() ? "diskdump" : "compressed kdump",
+			      ret);
+			return READ_ERROR;
+		}
+#endif
 	} else
 		memcpy(dd->page_cache_hdr[i].pg_bufptr,
 		       dd->compressed_page, block_size);
Signature · 1 line
1.7.7.6

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec