[PATCH 6/6] nvram: Shrink our zlib_deflate workspace from 268K to 24K
Jim Keniston
jkenisto at us.ibm.com
Sun Nov 14 15:15:44 EST 2010
Exploit zlib_deflate_workspacesize2() to create a much smaller
zlib_deflate workspace when capturing oops/panic reports to NVRAM.
Signed-off-by: Jim Keniston <jkenisto at us.ibm.com>
---
arch/powerpc/platforms/pseries/nvram.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 8e5ed74..6409cb6 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -17,7 +17,6 @@
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
-#include <linux/vmalloc.h>
#include <linux/ctype.h>
#include <linux/kmsg_dump.h>
#include <linux/zlib.h>
@@ -94,6 +93,8 @@ static struct oops_parition_data {
} *little_oops_buf;
#define COMPR_LEVEL 6
+#define WINDOW_BITS 12
+#define MEM_LEVEL 4
static struct z_stream_s stream;
static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
@@ -408,7 +409,8 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
big_oops_buf_sz = (little_oops_buf_sz * 100) / 45;
big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
if (big_oops_buf) {
- stream.workspace = vmalloc(zlib_deflate_workspacesize());
+ stream.workspace = kmalloc(zlib_deflate_workspacesize2(
+ WINDOW_BITS, MEM_LEVEL), GFP_KERNEL);
if (!stream.workspace) {
pr_err("nvram: No memory for compression workspace; "
"skipping compression of %s partition data\n",
@@ -427,7 +429,7 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
pr_err("nvram: kmsg_dump_register() failed; returned %d\n", rc);
kfree(little_oops_buf);
kfree(big_oops_buf);
- vfree(stream.workspace);
+ kfree(stream.workspace);
}
}
@@ -625,7 +627,8 @@ static int nvram_compress(const void *in, void *out, size_t inlen,
int err, ret;
ret = -EIO;
- err = zlib_deflateInit(&stream, COMPR_LEVEL);
+ err = zlib_deflateInit2(&stream, COMPR_LEVEL, Z_DEFLATED, WINDOW_BITS,
+ MEM_LEVEL, Z_DEFAULT_STRATEGY);
if (err != Z_OK)
goto error;
More information about the Linuxppc-dev
mailing list