Re: [PATCH v2 2/2] mm: remove BDI_CAP_WRITEBACK_ACCT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 22, 2025 at 2:42 PM Marek Szyprowski
<m.szyprowski@xxxxxxxxxxx> wrote:
>
> On 22.08.2025 13:01, Marek Szyprowski wrote:
> > On 08.07.2025 01:46, Joanne Koong wrote:
> >> There are no users of BDI_CAP_WRITEBACK_ACCT now that fuse doesn't do
> >> its own writeback accounting. This commit removes
> >> BDI_CAP_WRITEBACK_ACCT.
> >>
> >> Signed-off-by: Joanne Koong <joannelkoong@xxxxxxxxx>
> >> Acked-by: David Hildenbrand <david@xxxxxxxxxx>
> >
> > This patch landed recently in linux-next as commit 167f21a81a9c ("mm:
> > remove BDI_CAP_WRITEBACK_ACCT"). In my tests I found that it triggers
> > the ./include/linux/backing-dev.h:239 warning. Reverting $subject on
> > top of current linux-next fixes/hides this issue. Here is a detailed log:
> >
> > ------------[ cut here ]------------
> > WARNING: ./include/linux/backing-dev.h:239 at
> > __folio_start_writeback+0x25a/0x26a, CPU#1: swapper/0/1
> > Modules linked in:
> > CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> > 6.17.0-rc2-next-20250822 #10852 NONE
> > Hardware name: StarFive VisionFive 2 v1.2A (DT)
> > epc : __folio_start_writeback+0x25a/0x26a
> >  ra : __folio_start_writeback+0x258/0x26a
> >
> > [<ffffffff80202222>] __folio_start_writeback+0x25a/0x26a
> > [<ffffffff802f3260>] __block_write_full_folio+0x124/0x39c
> > [<ffffffff802f4b6e>] block_write_full_folio+0x8a/0xbc
> > [<ffffffff804dbf42>] blkdev_writepages+0x3e/0x8a
> > [<ffffffff802030fa>] do_writepages+0x78/0x11a
> > [<ffffffff801f2e0e>] filemap_fdatawrite_wbc+0x4a/0x62
> > [<ffffffff801f6d66>] __filemap_fdatawrite_range+0x52/0x78
> > [<ffffffff801f6fdc>] filemap_write_and_wait_range+0x40/0x68
> > [<ffffffff804dacae>] set_blocksize+0xd8/0x152
> > [<ffffffff804dae18>] sb_min_blocksize+0x44/0xce
> > [<ffffffff803a0c7a>] ext4_fill_super+0x182/0x2914
> > [<ffffffff802a72e6>] get_tree_bdev_flags+0xf0/0x168
> > [<ffffffff802a736c>] get_tree_bdev+0xe/0x16
> > [<ffffffff8039a09e>] ext4_get_tree+0x14/0x1c
> > [<ffffffff802a5062>] vfs_get_tree+0x1a/0xa4
> > [<ffffffff802d17d4>] path_mount+0x23a/0x8ae
> > [<ffffffff80c20cd4>] init_mount+0x4e/0x86
> > [<ffffffff80c01622>] do_mount_root+0xe0/0x166
> > [<ffffffff80c01814>] mount_root_generic+0x11e/0x2d6
> > [<ffffffff80c02746>] initrd_load+0xf8/0x2b6
> > [<ffffffff80c01d38>] prepare_namespace+0x150/0x258
> > [<ffffffff80c01310>] kernel_init_freeable+0x2f2/0x316
> > [<ffffffff80b6d896>] kernel_init+0x1e/0x13a
> > [<ffffffff80012288>] ret_from_fork_kernel+0x14/0x208
> > [<ffffffff80b79392>] ret_from_fork_kernel_asm+0x16/0x18
> > irq event stamp: 159263
> > hardirqs last  enabled at (159263): [<ffffffff805e7e4a>]
> > percpu_counter_add_batch+0xa6/0xda
> > hardirqs last disabled at (159262): [<ffffffff805e7e40>]
> > percpu_counter_add_batch+0x9c/0xda
> > softirqs last  enabled at (159248): [<ffffffff8002e972>]
> > handle_softirqs+0x3ca/0x462
> > softirqs last disabled at (159241): [<ffffffff8002eb72>]
> > __irq_exit_rcu+0xe2/0x10c
> > ---[ end trace 0000000000000000 ]---
>
> I've played a bit with the code modified by the $subject patch and it
> looks that the following change fixes the issue, although I didn't
> analyze exactly where struct bdi_writeback is being modified:

Hi Marek,

Thank you for the report and analysis.

The comment in the warning you linked to
(./include/linux/backing-dev.h:239) says:
"The caller [of inode_to_wb()] must be holding either @inode->i_lock,
the i_pages lock, or the associated wb's list_lock". (This was added
in commit aaa2cacf8184 "writeback: add lockdep annotation to
inode_to_wb()").

The original code before my change set "wb = inode_to_wb(inode);" only
after the inode->i_mapping->i_pages.xa_lock was held, so your patch
below which reverts it back to this behavior, fixes the lockdep
warning. That looks correct to me. Thanks for the fix.


>
> 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);
>
>
> > ...
>
> Best regards
> --
> Marek Szyprowski, PhD
> Samsung R&D Institute Poland
>





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux