From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 3/9] mm: Return head pages from grab_cache_page_write_begin
Date: Mon, 26 Oct 2020 18:31:30 +0000 [thread overview]
Message-ID: <20201026183136.10404-4-willy@infradead.org> (raw)
In-Reply-To: <20201026183136.10404-1-willy@infradead.org>
This function is only called from filesystems on their own mapping,
so no caller will be surprised by getting back a head page when they
were expecting a tail page. This lets us remove a call to thp_head()
in wait_for_stable_page().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/filemap.c | 12 ++++++++++--
mm/page-writeback.c | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index 2214a2c48dd1..62bc6affeb70 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3327,15 +3327,23 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
}
EXPORT_SYMBOL(generic_file_direct_write);
-/*
+/**
+ * grab_cache_page_write_begin - Find or create a page for buffered writes.
+ * @mapping: The address space we're writing to.
+ * @index: The index we're writing to.
+ * @flags: %AOP_FLAG_NOFS to prevent memory reclaim calling the filesystem.
+ *
* Find or create a page at the given pagecache position. Return the locked
* page. This function is specifically for buffered writes.
+ *
+ * Return: The head page found in the cache, or NULL if no page could be
+ * created (due to lack of memory).
*/
struct page *grab_cache_page_write_begin(struct address_space *mapping,
pgoff_t index, unsigned flags)
{
struct page *page;
- int fgp_flags = FGP_LOCK|FGP_WRITE|FGP_CREAT;
+ int fgp_flags = FGP_LOCK|FGP_WRITE|FGP_CREAT|FGP_HEAD;
if (flags & AOP_FLAG_NOFS)
fgp_flags |= FGP_NOFS;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 7709f0e223f5..3671568d433f 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2849,7 +2849,7 @@ EXPORT_SYMBOL_GPL(wait_on_page_writeback);
*/
void wait_for_stable_page(struct page *page)
{
- page = thp_head(page);
+ VM_BUG_ON_PGFLAGS(PageTail(page), page);
if (page->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES)
wait_on_page_writeback(page);
}
--
2.28.0
next prev parent reply other threads:[~2020-10-26 18:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 18:31 [PATCH 0/9] More THP fixes Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 1/9] mm: Support THPs in zero_user_segments Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 2/9] mm/page-flags: Allow accessing PageError on tail pages Matthew Wilcox (Oracle)
2020-10-26 18:31 ` Matthew Wilcox (Oracle) [this message]
2020-10-26 18:31 ` [PATCH 4/9] mm: Replace prep_transhuge_page with thp_prep Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 5/9] mm/truncate: Make invalidate_inode_pages2_range work with THPs Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 6/9] mm/truncate: Fix invalidate_complete_page2 for THPs Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 7/9] mm/vmscan: Free non-shmem THPs without splitting them Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 8/9] mm: Fix THP size assumption in mem_cgroup_split_huge_fixup Matthew Wilcox (Oracle)
2020-10-26 18:31 ` [PATCH 9/9] mm: Fix READ_ONLY_THP warning Matthew Wilcox (Oracle)
2020-10-27 14:36 ` [PATCH 0/9] More THP fixes Zi Yan
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=20201026183136.10404-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).