aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorOlav Haugan <ohaugan@codeaurora.org>2013-10-31 17:53:41 -0700
committerSimon Shields <keepcalm444@gmail.com>2016-06-12 21:19:47 +1000
commitb8a2bd16924eebba1f5cf10a54c20eac981fa3cd (patch)
treee9f222ec4485bf704dc48632e5772ccf78505f16 /drivers/staging
parentc32d11d7bfc35f379da6983537bc221c27bd7b26 (diff)
downloadkernel_samsung_smdk4412-b8a2bd16924eebba1f5cf10a54c20eac981fa3cd.zip
kernel_samsung_smdk4412-b8a2bd16924eebba1f5cf10a54c20eac981fa3cd.tar.gz
kernel_samsung_smdk4412-b8a2bd16924eebba1f5cf10a54c20eac981fa3cd.tar.bz2
staging: zram: Rate limit memory allocation errors
If an error occurs allocating memory for zram we will not be able to fullfill the request to store the page in zram. The swap subsystem still continues to try to swap out pages to zram even when this error occurs since there is currently no facility to stop the swap subsystem from swapping out during such errors. This can cause the system to be overflowed with logging errors. Reduce the amount of logging to prevent the kernel log from being filled with these error messages. Change-Id: I54b920337749ece59d9ca78fa8b29345ec7b976b Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/zram/zram_drv.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 72fbf05..6063c11 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -32,6 +32,7 @@
#include <linux/lzo.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
+#include <linux/ratelimit.h>
#include "zram_drv.h"
@@ -39,6 +40,12 @@
static int zram_major;
static struct zram *zram_devices;
+/*
+ * We don't need to see memory allocation errors more than once every 1
+ * second to know that a problem is occurring.
+ */
+#define ALLOC_ERROR_LOG_RATE_MS 1000
+
/* Module params (documentation at end) */
static unsigned int num_devices = 1;
@@ -400,6 +407,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
struct page *page;
unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
struct zram_meta *meta = zram->meta;
+ static unsigned long zram_rs_time;
page = bvec->bv_page;
src = meta->compress_buffer;
@@ -473,8 +481,10 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
handle = zs_malloc(meta->mem_pool, clen);
if (!handle) {
- pr_info("Error allocating memory for compressed page: %u, size=%zu\n",
- index, clen);
+ if (printk_timed_ratelimit(&zram_rs_time,
+ ALLOC_ERROR_LOG_RATE_MS))
+ pr_info("Error allocating memory for compressed page: %u, size=%zu\n",
+ index, clen);
ret = -ENOMEM;
goto out;
}