Assert that pages being written back are locked
Subsystems (2)
Matthew Wilcox
maintainerPATCH 1/1 Assert that pages being written back are locked
From: Matthew Wilcox (Oracle) <[email protected]>
In write_cache_pages(), we rely on PageLock to prevent writeback from starting on locked pages. I'm not sure if we document anywhere that pages that we're starting writes on must be locked, but having an assertion will make it clear to users that this is required.
mm/page-writeback.c +2 -0
@@ -2774,6 +2774,8 @@ int __test_set_page_writeback(struct page *page, bool keep_write)struct address_space *mapping =page_mapping (page);int ret, access_ret; +VM_BUG_ON_PGFLAGS (!PageLocked (page), page); +lock_page_memcg (page);if (mapping &&mapping_use_writeback_tags (mapping)) {XA_STATE (xas, &mapping->i_pages,page_index (page));
Matthew Wilcox
maintainerAnyone want to review this for me?
Quoted 23 lines · Matthew Wilcox
From: Matthew Wilcox (Oracle) <[email protected]>
In
write_cache_pages(), we rely on PageLock to prevent writeback from starting on locked pages. I'm not sure if we document anywhere that pages that we're starting writes on must be locked, but having an assertion will make it clear to users that this is required.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>mm/page-writeback.c +2
-0@@ -2774,6 +2774,8 @@ int __test_set_page_writeback(struct page *page, bool keep_write)struct address_space *mapping =page_mapping (page);int ret, access_ret; +VM_BUG_ON_PGFLAGS (!PageLocked (page), page); +lock_page_memcg (page);if (mapping &&mapping_use_writeback_tags (mapping)) {XA_STATE (xas, &mapping->i_pages,page_index (page));
Looks good.
Quoted 25 lines · Matthew Wilcox
From: Matthew Wilcox (Oracle) <[email protected]>
In
write_cache_pages(), we rely on PageLock to prevent writeback from starting on locked pages. I'm not sure if we document anywhere that pages that we're starting writes on must be locked, but having an assertion will make it clear to users that this is required.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>mm/page-writeback.c +2
-0@@ -2774,6 +2774,8 @@ int __test_set_page_writeback(struct page *page, bool keep_write)struct address_space *mapping =page_mapping (page);int ret, access_ret; +VM_BUG_ON_PGFLAGS (!PageLocked (page), page); +lock_page_memcg (page);if (mapping &&mapping_use_writeback_tags (mapping)) {XA_STATE (xas, &mapping->i_pages,page_index (page));