diff mbox series

mm/page_io: Use pr_alert_ratelimited for swap read/write errors

Message ID 20210201142055.29068-1-georgi.djakov@linaro.org (mailing list archive)
State New, archived
Headers show
Series mm/page_io: Use pr_alert_ratelimited for swap read/write errors | expand

Commit Message

Georgi Djakov Feb. 1, 2021, 2:20 p.m. UTC
If there are errors during swap read or write, they can easily fill
the log buffer and remove any previous messages that might be useful
for debugging, especially on systems that rely for logging only on
the kernel ring-buffer.

For example, on a systems using zram as swap, we are more likely to
see any page allocation errors preceding the swap write errors if the
alerts are ratelimited.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
---
 mm/page_io.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Minchan Kim Feb. 1, 2021, 6:43 p.m. UTC | #1
On Mon, Feb 01, 2021 at 04:20:55PM +0200, Georgi Djakov wrote:
> If there are errors during swap read or write, they can easily fill
> the log buffer and remove any previous messages that might be useful
> for debugging, especially on systems that rely for logging only on
> the kernel ring-buffer.
> 
> For example, on a systems using zram as swap, we are more likely to
> see any page allocation errors preceding the swap write errors if the
> alerts are ratelimited.
> 
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Miaohe Lin Feb. 2, 2021, 2:15 a.m. UTC | #2
Hi:
On 2021/2/1 22:20, Georgi Djakov wrote:
> If there are errors during swap read or write, they can easily fill
> the log buffer and remove any previous messages that might be useful
> for debugging, especially on systems that rely for logging only on
> the kernel ring-buffer.
> 
> For example, on a systems using zram as swap, we are more likely to
> see any page allocation errors preceding the swap write errors if the
> alerts are ratelimited.
> 
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

Make sense for me. Thanks.
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

> ---
>  mm/page_io.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/page_io.c b/mm/page_io.c
> index 92f7941c6d01..485fa5cca4a2 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -41,9 +41,9 @@ void end_swap_bio_write(struct bio *bio)
>  		 * Also clear PG_reclaim to avoid rotate_reclaimable_page()
>  		 */
>  		set_page_dirty(page);
> -		pr_alert("Write-error on swap-device (%u:%u:%llu)\n",
> -			 MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
> -			 (unsigned long long)bio->bi_iter.bi_sector);
> +		pr_alert_ratelimited("Write-error on swap-device (%u:%u:%llu)\n",
> +				     MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
> +				     (unsigned long long)bio->bi_iter.bi_sector);
>  		ClearPageReclaim(page);
>  	}
>  	end_page_writeback(page);
> @@ -106,9 +106,9 @@ static void end_swap_bio_read(struct bio *bio)
>  	if (bio->bi_status) {
>  		SetPageError(page);
>  		ClearPageUptodate(page);
> -		pr_alert("Read-error on swap-device (%u:%u:%llu)\n",
> -			 MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
> -			 (unsigned long long)bio->bi_iter.bi_sector);
> +		pr_alert_ratelimited("Read-error on swap-device (%u:%u:%llu)\n",
> +				     MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
> +				     (unsigned long long)bio->bi_iter.bi_sector);
>  		goto out;
>  	}
>  
> 
> .
>
diff mbox series

Patch

diff --git a/mm/page_io.c b/mm/page_io.c
index 92f7941c6d01..485fa5cca4a2 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -41,9 +41,9 @@  void end_swap_bio_write(struct bio *bio)
 		 * Also clear PG_reclaim to avoid rotate_reclaimable_page()
 		 */
 		set_page_dirty(page);
-		pr_alert("Write-error on swap-device (%u:%u:%llu)\n",
-			 MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
-			 (unsigned long long)bio->bi_iter.bi_sector);
+		pr_alert_ratelimited("Write-error on swap-device (%u:%u:%llu)\n",
+				     MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
+				     (unsigned long long)bio->bi_iter.bi_sector);
 		ClearPageReclaim(page);
 	}
 	end_page_writeback(page);
@@ -106,9 +106,9 @@  static void end_swap_bio_read(struct bio *bio)
 	if (bio->bi_status) {
 		SetPageError(page);
 		ClearPageUptodate(page);
-		pr_alert("Read-error on swap-device (%u:%u:%llu)\n",
-			 MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
-			 (unsigned long long)bio->bi_iter.bi_sector);
+		pr_alert_ratelimited("Read-error on swap-device (%u:%u:%llu)\n",
+				     MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
+				     (unsigned long long)bio->bi_iter.bi_sector);
 		goto out;
 	}