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>
This commit is contained in:
Olav Haugan 2014-10-24 08:52:18 -07:00 committed by David Keitel
parent d722a1a4e9
commit 81df3cf70b

View file

@ -656,6 +656,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
struct zram_meta *meta = zram->meta;
struct zcomp_strm *zstrm = NULL;
unsigned long alloced_pages;
static unsigned long zram_rs_time;
page = bvec->bv_page;
if (is_partial_io(bvec)) {
@ -719,8 +720,11 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
handle = zs_malloc(meta->mem_pool, clen);
if (!handle) {
pr_err("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;
}