From 81df3cf70bfc9bb1e1174ebc9ee68d1bb4bf9e82 Mon Sep 17 00:00:00 2001 From: Olav Haugan Date: Fri, 24 Oct 2014 08:52:18 -0700 Subject: [PATCH] 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 --- drivers/block/zram/zram_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 2d67680a9afc..d6bff78ce8da 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -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; }