linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: linux-mm@kvack.org
Subject: [PATCH] Assert that pages being written back are locked
Date: Tue, 27 Oct 2020 22:46:45 +0000	[thread overview]
Message-ID: <20201027224645.GY20115@casper.infradead.org> (raw)

From: Matthew Wilcox (Oracle) <willy@infradead.org>

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) <willy@infradead.org>

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 3671568d433f..f83dd855594d 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -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));


             reply	other threads:[~2020-10-27 22:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 22:46 Matthew Wilcox [this message]
2020-11-11  0:39 ` Matthew Wilcox
2020-11-11  3:37 ` William Kucharski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201027224645.GY20115@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox