diff mbox series

[v3,09/11] mm: Convert writeback BUG to WARN_ON

Message ID 20200416220130.13343-10-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Make PageWriteback use the PageLocked optimisation | expand

Commit Message

Matthew Wilcox (Oracle) April 16, 2020, 10:01 p.m. UTC
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

If this BUG() ever triggers, we'll have a dead system with no particular
information.  Dumping the page will give us a fighting chance of debugging
the problem, and I think it's safe for us to just continue if we try
to clear the writeback bit on a page which already has the writeback
bit clear.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/filemap.c        | 4 +---
 mm/page-writeback.c | 5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Jan Kara April 23, 2020, 3:58 p.m. UTC | #1
On Thu 16-04-20 15:01:28, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> If this BUG() ever triggers, we'll have a dead system with no particular
> information.  Dumping the page will give us a fighting chance of debugging
> the problem, and I think it's safe for us to just continue if we try
> to clear the writeback bit on a page which already has the writeback
> bit clear.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/filemap.c        | 4 +---
>  mm/page-writeback.c | 5 +++++
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index b7c5d2402370..401b24d980ba 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1293,9 +1293,7 @@ void end_page_writeback(struct page *page)
>  		rotate_reclaimable_page(page);
>  	}
>  
> -	if (!test_clear_page_writeback(page))
> -		BUG();
> -
> +	test_clear_page_writeback(page);
>  	smp_mb__after_atomic();
>  	wake_up_page(page, PG_writeback);
>  }
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 7326b54ab728..ebaf0d8263a6 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2718,6 +2718,11 @@ int test_clear_page_writeback(struct page *page)
>  	struct lruvec *lruvec;
>  	int ret;
>  
> +	if (WARN_ON(!PageWriteback(page))) {
> +		dump_page(page, "!writeback");
> +		return false;
> +	}
> +

WARN_ON_ONCE() here perhaps? I don't think dumping more pages will bring
that much value...

								Honza
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index b7c5d2402370..401b24d980ba 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1293,9 +1293,7 @@  void end_page_writeback(struct page *page)
 		rotate_reclaimable_page(page);
 	}
 
-	if (!test_clear_page_writeback(page))
-		BUG();
-
+	test_clear_page_writeback(page);
 	smp_mb__after_atomic();
 	wake_up_page(page, PG_writeback);
 }
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 7326b54ab728..ebaf0d8263a6 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2718,6 +2718,11 @@  int test_clear_page_writeback(struct page *page)
 	struct lruvec *lruvec;
 	int ret;
 
+	if (WARN_ON(!PageWriteback(page))) {
+		dump_page(page, "!writeback");
+		return false;
+	}
+
 	memcg = lock_page_memcg(page);
 	lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page));
 	if (mapping && mapping_use_writeback_tags(mapping)) {