Skip to contentSkip to conversation

Assert that pages being written back are locked

PATCH In review Matthew Wilcox 2 participants 3 messages Oct 27, 2020 – Nov 11, 2020

Subsystems (2)
lore
Share & tools
lore

Matthew Wilcox

author maintainer
#0 lore raw

PATCH 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
index 3671568d433f..f83dd855594d 100644
@@ -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));
author maintainer
#1 lore raw

Anyone 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.

mm/page-writeback.c +2 -0
index 3671568d433f..f83dd855594d 100644
@@ -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));
Reviewed-by on v1 1/1
#2 lore raw
In reply to Matthew Wilcox

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.

mm/page-writeback.c +2 -0
index 3671568d433f..f83dd855594d 100644
@@ -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));