mm: swap: Rate limit swap write errors

If an error occurs in the swap subsystem when writing pages
out to a swap device the system might get overflowed with
logging errors because the mm subsystem will continously try
to swap out pages even in the event of error on the swap
device.

Reduce the amount of logging to prevent the kernel log
from being filled with these error messages.

Change-Id: Iddaf6c32ae87132817482cc4cb68b909a1c527e6
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
This commit is contained in:
Olav Haugan 2013-11-14 09:14:11 -08:00
parent 728d568258
commit 72ab04b8d1

View file

@ -22,8 +22,15 @@
#include <linux/frontswap.h>
#include <linux/aio.h>
#include <linux/blkdev.h>
#include <linux/ratelimit.h>
#include <asm/pgtable.h>
/*
* We don't need to see swap errors more than once every 1 second to know
* that a problem is occurring.
*/
#define SWAP_ERROR_LOG_RATE_MS 1000
static struct bio *get_swap_bio(gfp_t gfp_flags,
struct page *page, bio_end_io_t end_io)
{
@ -47,6 +54,7 @@ void end_swap_bio_write(struct bio *bio, int err)
{
const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct page *page = bio->bi_io_vec[0].bv_page;
static unsigned long swap_error_rs_time;
if (!uptodate) {
SetPageError(page);
@ -59,7 +67,9 @@ void end_swap_bio_write(struct bio *bio, int err)
* Also clear PG_reclaim to avoid rotate_reclaimable_page()
*/
set_page_dirty(page);
printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n",
if (printk_timed_ratelimit(&swap_error_rs_time,
SWAP_ERROR_LOG_RATE_MS))
printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n",
imajor(bio->bi_bdev->bd_inode),
iminor(bio->bi_bdev->bd_inode),
(unsigned long long)bio->bi_sector);