linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix lockdep issues in writeback handling
       [not found] <CGME20250826131210eucas1p21a27a684042f37080b7a19599f479b7a@eucas1p2.samsung.com>
@ 2025-08-26 13:09 ` Marek Szyprowski
  2025-08-27 19:01   ` Joanne Koong
  2025-08-27 19:57   ` David Hildenbrand
  0 siblings, 2 replies; 7+ messages in thread
From: Marek Szyprowski @ 2025-08-26 13:09 UTC (permalink / raw)
  To: linux-fsdevel, linux-mm, linux-kernel
  Cc: Marek Szyprowski, Matthew Wilcox (Oracle), Andrew Morton,
	David Hildenbrand, Miklos Szeredi, Joanne Koong

Commit 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT") removed
BDI_CAP_WRITEBACK_ACCT flag and refactored code that depend on it.
Unfortunately it also moved some variable intialization out of guarded
scope in writeback handling, what triggers a true lockdep warning. Fix
this by moving initialization to the proper place.

Fixes: 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 mm/page-writeback.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 99e80bdb3084..3887ac2e6475 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2984,7 +2984,7 @@ bool __folio_end_writeback(struct folio *folio)
 
 	if (mapping && mapping_use_writeback_tags(mapping)) {
 		struct inode *inode = mapping->host;
-		struct bdi_writeback *wb = inode_to_wb(inode);
+		struct bdi_writeback *wb;
 		unsigned long flags;
 
 		xa_lock_irqsave(&mapping->i_pages, flags);
@@ -2992,6 +2992,7 @@ bool __folio_end_writeback(struct folio *folio)
 		__xa_clear_mark(&mapping->i_pages, folio_index(folio),
 					PAGECACHE_TAG_WRITEBACK);
 
+		wb = inode_to_wb(inode);
 		wb_stat_mod(wb, WB_WRITEBACK, -nr);
 		__wb_writeout_add(wb, nr);
 		if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
@@ -3024,7 +3025,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
 	if (mapping && mapping_use_writeback_tags(mapping)) {
 		XA_STATE(xas, &mapping->i_pages, folio_index(folio));
 		struct inode *inode = mapping->host;
-		struct bdi_writeback *wb = inode_to_wb(inode);
+		struct bdi_writeback *wb;
 		unsigned long flags;
 		bool on_wblist;
 
@@ -3035,6 +3036,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
 		on_wblist = mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK);
 
 		xas_set_mark(&xas, PAGECACHE_TAG_WRITEBACK);
+		wb = inode_to_wb(inode);
 		wb_stat_mod(wb, WB_WRITEBACK, nr);
 		if (!on_wblist) {
 			wb_inode_writeback_start(wb);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: fix lockdep issues in writeback handling
  2025-08-26 13:09 ` [PATCH] mm: fix lockdep issues in writeback handling Marek Szyprowski
@ 2025-08-27 19:01   ` Joanne Koong
  2025-08-27 19:57   ` David Hildenbrand
  1 sibling, 0 replies; 7+ messages in thread
From: Joanne Koong @ 2025-08-27 19:01 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: linux-fsdevel, linux-mm, linux-kernel, Matthew Wilcox (Oracle),
	Andrew Morton, David Hildenbrand, Miklos Szeredi

On Tue, Aug 26, 2025 at 6:12 AM Marek Szyprowski
<m.szyprowski@samsung.com> wrote:
>
> Commit 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT") removed
> BDI_CAP_WRITEBACK_ACCT flag and refactored code that depend on it.
> Unfortunately it also moved some variable intialization out of guarded
> scope in writeback handling, what triggers a true lockdep warning. Fix
> this by moving initialization to the proper place.
>
> Fixes: 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT")
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

This LGTM. It reverts the initialization back to the lines where it
was originally initialized.

Sorry for missing this, I had assumed inode_to_wb() was just a
straightforward inode->i_wb pointer following and hadn't bothered to
look. I'll be more careful next time.

Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
> ---
>  mm/page-writeback.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 99e80bdb3084..3887ac2e6475 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2984,7 +2984,7 @@ bool __folio_end_writeback(struct folio *folio)
>
>         if (mapping && mapping_use_writeback_tags(mapping)) {
>                 struct inode *inode = mapping->host;
> -               struct bdi_writeback *wb = inode_to_wb(inode);
> +               struct bdi_writeback *wb;
>                 unsigned long flags;
>
>                 xa_lock_irqsave(&mapping->i_pages, flags);
> @@ -2992,6 +2992,7 @@ bool __folio_end_writeback(struct folio *folio)
>                 __xa_clear_mark(&mapping->i_pages, folio_index(folio),
>                                         PAGECACHE_TAG_WRITEBACK);
>
> +               wb = inode_to_wb(inode);
>                 wb_stat_mod(wb, WB_WRITEBACK, -nr);
>                 __wb_writeout_add(wb, nr);
>                 if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
> @@ -3024,7 +3025,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
>         if (mapping && mapping_use_writeback_tags(mapping)) {
>                 XA_STATE(xas, &mapping->i_pages, folio_index(folio));
>                 struct inode *inode = mapping->host;
> -               struct bdi_writeback *wb = inode_to_wb(inode);
> +               struct bdi_writeback *wb;
>                 unsigned long flags;
>                 bool on_wblist;
>
> @@ -3035,6 +3036,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
>                 on_wblist = mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK);
>
>                 xas_set_mark(&xas, PAGECACHE_TAG_WRITEBACK);
> +               wb = inode_to_wb(inode);
>                 wb_stat_mod(wb, WB_WRITEBACK, nr);
>                 if (!on_wblist) {
>                         wb_inode_writeback_start(wb);
> --
> 2.34.1
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: fix lockdep issues in writeback handling
  2025-08-26 13:09 ` [PATCH] mm: fix lockdep issues in writeback handling Marek Szyprowski
  2025-08-27 19:01   ` Joanne Koong
@ 2025-08-27 19:57   ` David Hildenbrand
  2025-09-02  9:52     ` Aleksandr Nogikh
  1 sibling, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2025-08-27 19:57 UTC (permalink / raw)
  To: Marek Szyprowski, linux-fsdevel, linux-mm, linux-kernel
  Cc: Matthew Wilcox (Oracle), Andrew Morton, Miklos Szeredi,
	Joanne Koong

On 26.08.25 15:09, Marek Szyprowski wrote:
> Commit 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT") removed
> BDI_CAP_WRITEBACK_ACCT flag and refactored code that depend on it.
> Unfortunately it also moved some variable intialization out of guarded
> scope in writeback handling, what triggers a true lockdep warning. Fix
> this by moving initialization to the proper place.

Nasty

> 
> Fixes: 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT")
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Re: [PATCH] mm: fix lockdep issues in writeback handling
  2025-08-27 19:57   ` David Hildenbrand
@ 2025-09-02  9:52     ` Aleksandr Nogikh
  2025-09-02 22:40       ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Aleksandr Nogikh @ 2025-09-02  9:52 UTC (permalink / raw)
  To: david
  Cc: akpm, joannelkoong, linux-fsdevel, linux-kernel, linux-mm,
	m.szyprowski, mszeredi, willy, syzkaller-bugs

Hi,

When can the patch be expected to reach linux-next?
Syzbot can't build/boot the tree for more than 12 days already :(

-- 
Aleksandr

On 27.08.25, David Hildenbrand wrote:
> On 26.08.25 15:09, Marek Szyprowski wrote:
> > Commit 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT") removed
> > BDI_CAP_WRITEBACK_ACCT flag and refactored code that depend on it.
> > Unfortunately it also moved some variable intialization out of guarded
> > scope in writeback handling, what triggers a true lockdep warning. Fix
> > this by moving initialization to the proper place.
> 
> Nasty
> 
> > 
> > Fixes: 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT")
> > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > ---
> 
> Acked-by: David Hildenbrand <david@redhat.com>
> 
> -- 
> Cheers
> 
> David / dhildenb


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: fix lockdep issues in writeback handling
  2025-09-02  9:52     ` Aleksandr Nogikh
@ 2025-09-02 22:40       ` Andrew Morton
  2025-09-02 23:09         ` Stephen Rothwell
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2025-09-02 22:40 UTC (permalink / raw)
  To: Aleksandr Nogikh
  Cc: david, joannelkoong, linux-fsdevel, linux-kernel, linux-mm,
	m.szyprowski, mszeredi, willy, syzkaller-bugs, Stephen Rothwell

On Tue,  2 Sep 2025 11:52:50 +0200 Aleksandr Nogikh <nogikh@google.com> wrote:

> Hi,
> 
> When can the patch be expected to reach linux-next?
> Syzbot can't build/boot the tree for more than 12 days already :(

Please don't top-post - it messes things up so much.

There's nothing I can reasonably do about this - it's fixing an issue
that's coming in from Miklos's tree and perhaps he's offline.

Perhaps Stephen can directly add it to linux-next for a while?

From: Marek Szyprowski <m.szyprowski@samsung.com>
To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Marek Szyprowski <m.szyprowski@samsung.com>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, David Hildenbrand <david@redhat.com>, Miklos Szeredi <mszeredi@redhat.com>, Joanne Koong <joannelkoong@gmail.com>
Subject: [PATCH] mm: fix lockdep issues in writeback handling
Date: Tue, 26 Aug 2025 15:09:48 +0200
Sender: owner-linux-mm@kvack.org
X-Mailer: git-send-email 2.34.1

Commit 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT") removed
BDI_CAP_WRITEBACK_ACCT flag and refactored code that depend on it.
Unfortunately it also moved some variable intialization out of guarded
scope in writeback handling, what triggers a true lockdep warning. Fix
this by moving initialization to the proper place.

Fixes: 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 mm/page-writeback.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 99e80bdb3084..3887ac2e6475 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2984,7 +2984,7 @@ bool __folio_end_writeback(struct folio *folio)
 
 	if (mapping && mapping_use_writeback_tags(mapping)) {
 		struct inode *inode = mapping->host;
-		struct bdi_writeback *wb = inode_to_wb(inode);
+		struct bdi_writeback *wb;
 		unsigned long flags;
 
 		xa_lock_irqsave(&mapping->i_pages, flags);
@@ -2992,6 +2992,7 @@ bool __folio_end_writeback(struct folio *folio)
 		__xa_clear_mark(&mapping->i_pages, folio_index(folio),
 					PAGECACHE_TAG_WRITEBACK);
 
+		wb = inode_to_wb(inode);
 		wb_stat_mod(wb, WB_WRITEBACK, -nr);
 		__wb_writeout_add(wb, nr);
 		if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
@@ -3024,7 +3025,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
 	if (mapping && mapping_use_writeback_tags(mapping)) {
 		XA_STATE(xas, &mapping->i_pages, folio_index(folio));
 		struct inode *inode = mapping->host;
-		struct bdi_writeback *wb = inode_to_wb(inode);
+		struct bdi_writeback *wb;
 		unsigned long flags;
 		bool on_wblist;
 
@@ -3035,6 +3036,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
 		on_wblist = mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK);
 
 		xas_set_mark(&xas, PAGECACHE_TAG_WRITEBACK);
+		wb = inode_to_wb(inode);
 		wb_stat_mod(wb, WB_WRITEBACK, nr);
 		if (!on_wblist) {
 			wb_inode_writeback_start(wb);
-- 
2.34.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: fix lockdep issues in writeback handling
  2025-09-02 22:40       ` Andrew Morton
@ 2025-09-02 23:09         ` Stephen Rothwell
  2025-09-03  8:28           ` Miklos Szeredi
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Rothwell @ 2025-09-02 23:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Aleksandr Nogikh, david, joannelkoong, linux-fsdevel,
	linux-kernel, linux-mm, m.szyprowski, mszeredi, willy,
	syzkaller-bugs

[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]

Hi Andrew,

On Tue, 2 Sep 2025 15:40:43 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> Perhaps Stephen can directly add it to linux-next for a while?

I will add it to linux-next from today (until Miklos sorts it out).
Note that the fuse tree was updated since yesterday's linux-next, but
this patch is still not included.

> From: Marek Szyprowski <m.szyprowski@samsung.com>
> To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, David Hildenbrand <david@redhat.com>, Miklos Szeredi <mszeredi@redhat.com>, Joanne Koong <joannelkoong@gmail.com>
> Subject: [PATCH] mm: fix lockdep issues in writeback handling
> Date: Tue, 26 Aug 2025 15:09:48 +0200
> Sender: owner-linux-mm@kvack.org
> X-Mailer: git-send-email 2.34.1
> 
> Commit 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT") removed
> BDI_CAP_WRITEBACK_ACCT flag and refactored code that depend on it.
> Unfortunately it also moved some variable intialization out of guarded
> scope in writeback handling, what triggers a true lockdep warning. Fix
> this by moving initialization to the proper place.
> 
> Fixes: 167f21a81a9c ("mm: remove BDI_CAP_WRITEBACK_ACCT")

This is now commit

  2841808f35ee ("mm: remove BDI_CAP_WRITEBACK_ACCT")

in the fuse tree.

> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm: fix lockdep issues in writeback handling
  2025-09-02 23:09         ` Stephen Rothwell
@ 2025-09-03  8:28           ` Miklos Szeredi
  0 siblings, 0 replies; 7+ messages in thread
From: Miklos Szeredi @ 2025-09-03  8:28 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Andrew Morton, Aleksandr Nogikh, david, joannelkoong,
	linux-fsdevel, linux-kernel, linux-mm, m.szyprowski, willy,
	syzkaller-bugs

On Wed, Sep 3, 2025 at 1:16 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Hi Andrew,
>
> On Tue, 2 Sep 2025 15:40:43 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > Perhaps Stephen can directly add it to linux-next for a while?
>
> I will add it to linux-next from today (until Miklos sorts it out).
> Note that the fuse tree was updated since yesterday's linux-next, but
> this patch is still not included.

Sorry, I just didn't realize this was fixing a patch in my tree.

Added now.

Thanks,
Miklos



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-03  8:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250826131210eucas1p21a27a684042f37080b7a19599f479b7a@eucas1p2.samsung.com>
2025-08-26 13:09 ` [PATCH] mm: fix lockdep issues in writeback handling Marek Szyprowski
2025-08-27 19:01   ` Joanne Koong
2025-08-27 19:57   ` David Hildenbrand
2025-09-02  9:52     ` Aleksandr Nogikh
2025-09-02 22:40       ` Andrew Morton
2025-09-02 23:09         ` Stephen Rothwell
2025-09-03  8:28           ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).