fuse/mm: remove BDI_CAP_WRITEBACK_ACCT
Subsystems (5)
v2 cover fuse/mm: remove BDI_CAP_WRITEBACK_ACCT
With the changes in commit 0c58a97f919c ("fuse: remove tmp folio for writebacks and internal rb tree") which removed using temp folios for dirty page writeback, fuse can now use the default writeback accounting instead of doing its own accounting. This allows us to get rid of BDI_CAP_WRITEBACK_ACCT altogether.
Changelog
---------
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/
v1 -> v2:
* Get rid of unused variable declarations (kernel test robot)
* Add David's acked-by
Joanne Koong (2):
fuse: use default writeback accounting
mm: remove BDI_CAP_WRITEBACK_ACCT
fs/fuse/file.c | 9 +------- fs/fuse/inode.c | 2 -- include/linux/backing-dev.h | 14 +----------- mm/backing-dev.c | 2 +- mm/page-writeback.c | 43 ++++++++++++++++--------------------- 5 files changed, 21 insertions(+), 49 deletions(-)
Signature · 1 line
2.47.1
PATCH v2 1/2 fuse: use default writeback accounting
commit 0c58a97f919c ("fuse: remove tmp folio for writebacks and internal rb tree") removed temp folios for dirty page writeback. Consequently, fuse can now use the default writeback accounting.
With switching fuse to use default writeback accounting, there are some added benefits. This updates wb->writeback_inodes tracking as well now and updates writeback throughput estimates after writeback completion.
This commit also removes inc_wb_stat() and dec_wb_stat(). These have no callers anymore now that fuse does not call them.
--- fs/fuse/file.c | 9 +-------- fs/fuse/inode.c | 2 -- include/linux/backing-dev.h | 10 ---------- 3 files changed, 1 insertion(+), 20 deletions(-)
fs/fuse/file.c +1 -8
@@ -1784,19 +1784,15 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa)struct fuse_args_pages *ap = &wpa->ia.ap;struct inode *inode = wpa->inode;struct fuse_inode *fi =get_fuse_inode (inode); -struct backing_dev_info *bdi =inode_to_bdi (inode);int i; -for (i =0 ; i < ap->num_folios; i++) { +for (i =0 ; i < ap->num_folios; i++)/* * Benchmarks showed that ending writeback within the * scope of the fi->lock alleviates xarray lock * contention and noticeably improves performance. */ folio_end_writeback (ap->folios[i]); -dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -wb_writeout_inc (&bdi->wb); - }wake_up (&fi->page_waitq); }
@@ -1982,14 +1978,11 @@ static void fuse_writepage_add_to_bucket(struct fuse_conn *fc,static void fuse_writepage_args_page_fill (struct fuse_writepage_args *wpa,struct folio *folio,uint32_t folio_index) { -struct inode *inode = folio->mapping->host;struct fuse_args_pages *ap = &wpa->ia.ap; ap->folios[folio_index] = folio; ap->descs[folio_index].offset =0 ; ap->descs[folio_index].length =folio_size (folio); - -inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); } static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio,
fs/fuse/inode.c +0 -2
@@ -1557,8 +1557,6 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb)if (err)return err; -/* fuse does it's own writeback accounting */ - sb->s_bdi->capabilities &= ~BDI_CAP_WRITEBACK_ACCT ; sb->s_bdi->capabilities |=BDI_CAP_STRICTLIMIT ;/*
include/linux/backing-dev.h +0 -10
@@ -66,16 +66,6 @@ static inline void wb_stat_mod(struct bdi_writeback *wb,percpu_counter_add_batch (&wb->stat[item], amount,WB_STAT_BATCH ); } -static inline void inc_wb_stat (struct bdi_writeback *wb,enum wb_stat_item item) -{ -wb_stat_mod (wb, item,1 ); -} - -static inline void dec_wb_stat (struct bdi_writeback *wb,enum wb_stat_item item) -{ -wb_stat_mod (wb, item,-1 ); -} -static inline s64 wb_stat (struct bdi_writeback *wb,enum wb_stat_item item) {return percpu_counter_read_positive (&wb->stat[item]);
Signature · 1 line
2.47.1
Re: [PATCH v2 1/2] fuse: use default writeback accounting
Quoted 30 lines · Joanne Koong
commit
0c58a97f919c("fuse: remove tmp folio for writebacks and internal rb tree") removed temp folios for dirty page writeback. Consequently, fuse can now use the default writeback accounting.With switching fuse to use default writeback accounting, there are some added benefits. This updates
wb->writeback_inodestracking as well now and updates writeback throughput estimates after writeback completion.This commit also removes
inc_wb_stat()anddec_wb_stat(). These have no callers anymore now that fuse does not call them.Signed-off-by Joanne Koong <[email protected]>--- fs/fuse/file.c | 9 +-------- fs/fuse/inode.c | 2 -- include/linux/backing-dev.h | 10 ---------- 3 files changed, 1 insertion(+), 20 deletions(-)fs/fuse/file.c +0
-2@@ -1784,19 +1784,15 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa)struct fuse_args_pages *ap = &wpa->ia.ap;struct inode *inode = wpa->inode;struct fuse_inode *fi =get_fuse_inode (inode); -struct backing_dev_info *bdi =inode_to_bdi (inode);int i; -for (i =0 ; i < ap->num_folios; i++) {
fs/fuse/file.c static void fuse_writepage_finish(struct fuse_writepage_args *wpa) · line 1799
Quoted 10 lines
fs/fuse/file.c +1
-3+for (i =0 ; i < ap->num_folios; i++)/* * Benchmarks showed that ending writeback within the * scope of the fi->lock alleviates xarray lock * contention and noticeably improves performance. */ folio_end_writeback (ap->folios[i]); -dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -wb_writeout_inc (&bdi->wb); - }
Probably, just my own style, personally I keep the braces when there are comments.
Quoted 42 lines
fs/fuse/file.c +0
-3wake_up (&fi->page_waitq); }@@ -1982,14 +1978,11 @@ static void fuse_writepage_add_to_bucket(struct fuse_conn *fc,static void fuse_writepage_args_page_fill (struct fuse_writepage_args *wpa,struct folio *folio,uint32_t folio_index) { -struct inode *inode = folio->mapping->host;struct fuse_args_pages *ap = &wpa->ia.ap; ap->folios[folio_index] = folio; ap->descs[folio_index].offset =0 ; ap->descs[folio_index].length =folio_size (folio); - -inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); } static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio,fs/fuse/inode.c +0
-2@@ -1557,8 +1557,6 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb)if (err)return err; -/* fuse does it's own writeback accounting */ - sb->s_bdi->capabilities &= ~BDI_CAP_WRITEBACK_ACCT ; sb->s_bdi->capabilities |=BDI_CAP_STRICTLIMIT ;/* include/linux/backing-dev.h +0
-3@@ -66,16 +66,6 @@ static inline void wb_stat_mod(struct bdi_writeback *wb,percpu_counter_add_batch (&wb->stat[item], amount,WB_STAT_BATCH ); } -static inline void inc_wb_stat (struct bdi_writeback *wb,enum wb_stat_item item) -{ -wb_stat_mod (wb, item,1 );
include/linux/backing-dev.h static inline void wb_stat_mod(struct bdi_writeback *wb, · line 71
Quoted 10 lines
include/linux/backing-dev.h +0
-7-} - -static inline void dec_wb_stat (struct bdi_writeback *wb,enum wb_stat_item item) -{ -wb_stat_mod (wb, item,-1 ); -} -static inline s64 wb_stat (struct bdi_writeback *wb,enum wb_stat_item item) {return percpu_counter_read_positive (&wb->stat[item]);
David Hildenbrand
Reviewed-byRe: [PATCH v2 1/2] fuse: use default writeback accounting
Quoted 32 lines · Bernd Schubert
Quoted 29 lines · Joanne Koong
commit
0c58a97f919c("fuse: remove tmp folio for writebacks and internal rb tree") removed temp folios for dirty page writeback. Consequently, fuse can now use the default writeback accounting.With switching fuse to use default writeback accounting, there are some added benefits. This updates
wb->writeback_inodestracking as well now and updates writeback throughput estimates after writeback completion.This commit also removes
inc_wb_stat()anddec_wb_stat(). These have no callers anymore now that fuse does not call them.Signed-off-by Joanne Koong <[email protected]>--- fs/fuse/file.c | 9 +-------- fs/fuse/inode.c | 2 -- include/linux/backing-dev.h | 10 ---------- 3 files changed, 1 insertion(+), 20 deletions(-)fs/fuse/file.c +0
-1@@ -1784,19 +1784,15 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa)struct fuse_args_pages *ap = &wpa->ia.ap;struct inode *inode = wpa->inode;struct fuse_inode *fi =get_fuse_inode (inode); -struct backing_dev_info *bdi =inode_to_bdi (inode);int i;
Quoted 14 lines
fs/fuse/file.c static void fuse_writepage_finish(struct fuse_writepage_args *wpa) · line 1799
Quoted 11 lines
fs/fuse/file.c +1
-4-for (i =0 ; i < ap->num_folios; i++) { +for (i =0 ; i < ap->num_folios; i++)/* * Benchmarks showed that ending writeback within the * scope of the fi->lock alleviates xarray lock * contention and noticeably improves performance. */ folio_end_writeback (ap->folios[i]); -dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -wb_writeout_inc (&bdi->wb); - }Probably, just my own style, personally I keep the braces when there are comments.
Yeah, sometimes it can aid readability. I tend to keep them on multi-line comments IIRC.
Signature · 3 lines
Cheers, David / dhildenb
PATCH v2 2/2 mm: remove BDI_CAP_WRITEBACK_ACCT
In reply to Joanne KoongThere 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.
--- include/linux/backing-dev.h | 4 +--- mm/backing-dev.c | 2 +- mm/page-writeback.c | 43 ++++++++++++++++--------------------- 3 files changed, 20 insertions(+), 29 deletions(-)
include/linux/backing-dev.h +1 -3
@@ -108,12 +108,10 @@ int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit* * BDI_CAP_WRITEBACK: Supports dirty page writeback, and dirty pages * should contribute to accounting -* BDI_CAP_WRITEBACK_ACCT: Automatically account writeback pages * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold */ #define BDI_CAP_WRITEBACK (1 << 0) -#define BDI_CAP_WRITEBACK_ACCT (1 << 1) -#define BDI_CAP_STRICTLIMIT (1 << 2) +#define BDI_CAP_STRICTLIMIT (1 << 1)extern struct backing_dev_info noop_backing_dev_info;
mm/backing-dev.c +1 -1
@@ -1026,7 +1026,7 @@ struct backing_dev_info *bdi_alloc(int node_id)kfree (bdi);return NULL ; } - bdi->capabilities =BDI_CAP_WRITEBACK |BDI_CAP_WRITEBACK_ACCT ; + bdi->capabilities =BDI_CAP_WRITEBACK ; bdi->ra_pages =VM_READAHEAD_PAGES ; bdi->io_pages =VM_READAHEAD_PAGES ;timer_setup (&bdi->laptop_mode_wb_timer, laptop_mode_timer_fn,0 );
mm/page-writeback.c +18 -25
72 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH v2 2/2] mm: remove BDI_CAP_WRITEBACK_ACCT
Quoted 6 lines · Joanne Koong
There are no users of
BDI_CAP_WRITEBACK_ACCTnow that fuse doesn't do its own writeback accounting. This commit removesBDI_CAP_WRITEBACK_ACCT.Signed-off-by Joanne Koong <[email protected]>
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 ]---
Quoted 106 lines
--- include/linux/backing-dev.h | 4 +--- mm/backing-dev.c | 2 +- mm/page-writeback.c | 43 ++++++++++++++++--------------------- 3 files changed, 20 insertions(+), 29 deletions(-)include/linux/backing-dev.h +1
-3@@ -108,12 +108,10 @@ int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit* * BDI_CAP_WRITEBACK: Supports dirty page writeback, and dirty pages * should contribute to accounting -* BDI_CAP_WRITEBACK_ACCT: Automatically account writeback pages * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold */ #define BDI_CAP_WRITEBACK (1 << 0) -#define BDI_CAP_WRITEBACK_ACCT (1 << 1) -#define BDI_CAP_STRICTLIMIT (1 << 2) +#define BDI_CAP_STRICTLIMIT (1 << 1)extern struct backing_dev_info noop_backing_dev_info;mm/backing-dev.c +1
-1@@ -1026,7 +1026,7 @@ struct backing_dev_info *bdi_alloc(int node_id)kfree (bdi);return NULL ; } - bdi->capabilities =BDI_CAP_WRITEBACK |BDI_CAP_WRITEBACK_ACCT ; + bdi->capabilities =BDI_CAP_WRITEBACK ; bdi->ra_pages =VM_READAHEAD_PAGES ; bdi->io_pages =VM_READAHEAD_PAGES ;timer_setup (&bdi->laptop_mode_wb_timer, laptop_mode_timer_fn,0 );mm/page-writeback.c +18
-18@@ -3016,26 +3016,22 @@ bool __folio_end_writeback(struct folio *folio)if (mapping &&mapping_use_writeback_tags (mapping)) {struct inode *inode = mapping->host; -struct backing_dev_info *bdi =inode_to_bdi (inode); +struct bdi_writeback *wb =inode_to_wb (inode);unsigned long flags;xa_lock_irqsave (&mapping->i_pages, flags); ret =folio_xor_flags_has_waiters (folio,1 << PG_writeback);__xa_clear_mark (&mapping->i_pages,folio_index (folio),PAGECACHE_TAG_WRITEBACK ); -if (bdi->capabilities &BDI_CAP_WRITEBACK_ACCT ) { -struct bdi_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 )) -wb_inode_writeback_end (wb); +wb_stat_mod (wb,WB_WRITEBACK , -nr); +__wb_writeout_add (wb, nr); +if (!mapping_tagged (mapping,PAGECACHE_TAG_WRITEBACK )) { +wb_inode_writeback_end (wb); +if (mapping->host) +sb_clear_inode_writeback (mapping->host); } -if (mapping->host && !mapping_tagged (mapping, -PAGECACHE_TAG_WRITEBACK )) -sb_clear_inode_writeback (mapping->host); -xa_unlock_irqrestore (&mapping->i_pages, flags); }else { ret =folio_xor_flags_has_waiters (folio,1 << PG_writeback);@@ -3060,7 +3056,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 backing_dev_info *bdi =inode_to_bdi (inode); +struct bdi_writeback *wb =inode_to_wb (inode);unsigned long flags;bool on_wblist;@@ -3071,21 +3067,18 @@ 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 ); -if (bdi->capabilities &BDI_CAP_WRITEBACK_ACCT ) { -struct bdi_writeback *wb =inode_to_wb (inode); - -wb_stat_mod (wb,WB_WRITEBACK , nr); -if (!on_wblist) -wb_inode_writeback_start (wb); +wb_stat_mod (wb,WB_WRITEBACK , nr); +if (!on_wblist) { +wb_inode_writeback_start (wb); +/* +* We can come through here when swapping anonymous +* folios, so we don't necessarily have an inode to +* track for sync. +*/ +if (mapping->host) +sb_mark_inode_writeback (mapping->host); }
mm/page-writeback.c void __folio_start_writeback(struct folio *folio, bool keep_write) · line 3084
Quoted 10 lines
mm/page-writeback.c +0
-7-/* -* We can come through here when swapping anonymous -* folios, so we don't necessarily have an inode to -* track for sync. -*/ -if (mapping->host && !on_wblist) -sb_mark_inode_writeback (mapping->host);if (!folio_test_dirty (folio))xas_clear_mark (&xas,PAGECACHE_TAG_DIRTY );if (!keep_write)
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Re: [PATCH v2 2/2] mm: remove BDI_CAP_WRITEBACK_ACCT
Quoted 50 lines · Marek Szyprowski
Quoted 6 lines · Joanne Koong
There are no users of
BDI_CAP_WRITEBACK_ACCTnow that fuse doesn't do its own writeback accounting. This commit removesBDI_CAP_WRITEBACK_ACCT.Signed-off-by Joanne Koong <[email protected]>This patch landed recently in linux-next as commit
167f21a81a9c("mm:
removeBDI_CAP_WRITEBACK_ACCT"). In my tests I found that it triggers the./include/linux/backing-dev.h:239warning. 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: 159263hardirqs last enabled at (159263): [<
ffffffff805e7e4a>]
Quoted 8 lines
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:
mm/page-writeback.c +2 -1
@@ -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);
Quoted 1 line
...
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Re: [PATCH v2 2/2] mm: remove BDI_CAP_WRITEBACK_ACCT
Quoted 61 lines · Marek Szyprowski
Quoted 50 lines · Marek Szyprowski
Quoted 6 lines · Joanne Koong
There are no users of
BDI_CAP_WRITEBACK_ACCTnow that fuse doesn't do its own writeback accounting. This commit removesBDI_CAP_WRITEBACK_ACCT.Signed-off-by Joanne Koong <[email protected]>This patch landed recently in linux-next as commit
167f21a81a9c("mm:
removeBDI_CAP_WRITEBACK_ACCT"). In my tests I found that it triggers the./include/linux/backing-dev.h:239warning. 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>]Quoted 8 lines
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 ]---
Quoted 3 lines
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_writebackis 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.
Quoted 51 lines
mm/page-writeback.c +4
-2@@ -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);Quoted 1 line
...
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
Quoted 20 lines · Joanne Koong
With the changes in commit
0c58a97f919c("fuse: remove tmp folio for writebacks and internal rb tree") which removed using temp folios for dirty page writeback, fuse can now use the default writeback accounting instead of doing its own accounting. This allows us to get rid ofBDI_CAP_WRITEBACK_ACCTaltogether.Changelog
---------
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/
v1 -> v2:
* Get rid of unused variable declarations (kernel test robot)
* Add David's acked-byJoanne Koong (2):
fuse: use default writeback accounting
mm: removeBDI_CAP_WRITEBACK_ACCT
Quoted 7 lines
fs/fuse/file.c | 9 +------- fs/fuse/inode.c | 2 -- include/linux/backing-dev.h | 14 +----------- mm/backing-dev.c | 2 +- mm/page-writeback.c | 43 ++++++++++++++++--------------------- 5 files changed, 21 insertions(+), 49 deletions(-)
Hi Miklos,
Do you find this patchset acceptable for the fuse tree?
Thanks,
Joanne
Quoted 3 lines
--
2.47.1
Quoted 6 lines · Joanne Koong
With the changes in commit
0c58a97f919c("fuse: remove tmp folio for writebacks and internal rb tree") which removed using temp folios for dirty page writeback, fuse can now use the default writeback accounting instead of doing its own accounting. This allows us to get rid ofBDI_CAP_WRITEBACK_ACCTaltogether.
Applied, thanks.
Miklos