summaryrefslogtreecommitdiff
path: root/include/linux/writeback.h
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2025-04-09 17:12:59 +0200
committerChristian Brauner <brauner@kernel.org>2025-09-19 13:11:00 +0200
commite1b849cfa6b61f1c866a908c9e8dd9b5aaab820b (patch)
treec4ec0f4d3e0ecfc88637d1ddb9fd5d4021890735 /include/linux/writeback.h
parent8f5ae30d69d7543eee0d70083daf4de8fe15d585 (diff)
downloadlwn-e1b849cfa6b61f1c866a908c9e8dd9b5aaab820b.tar.gz
lwn-e1b849cfa6b61f1c866a908c9e8dd9b5aaab820b.zip
writeback: Avoid contention on wb->list_lock when switching inodes
There can be multiple inode switch works that are trying to switch inodes to / from the same wb. This can happen in particular if some cgroup exits which owns many (thousands) inodes and we need to switch them all. In this case several inode_switch_wbs_work_fn() instances will be just spinning on the same wb->list_lock while only one of them makes forward progress. This wastes CPU cycles and quickly leads to softlockup reports and unusable system. Instead of running several inode_switch_wbs_work_fn() instances in parallel switching to the same wb and contending on wb->list_lock, run just one work item per wb and manage a queue of isw items switching to this wb. Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'include/linux/writeback.h')
-rw-r--r--include/linux/writeback.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index a2848d731a46..15a4bc4ab819 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -265,6 +265,8 @@ static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio)
bio_associate_blkg_from_css(bio, wbc->wb->blkcg_css);
}
+void inode_switch_wbs_work_fn(struct work_struct *work);
+
#else /* CONFIG_CGROUP_WRITEBACK */
static inline void inode_attach_wb(struct inode *inode, struct folio *folio)