From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Linux Memory Management List <linux-mm@kvack.org>,
linux-fsdevel@vger.kernel.org,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Forcing vmscan to drop more (related) pages?
Date: Tue, 30 Jul 2024 15:35:31 +0930 [thread overview]
Message-ID: <7e68a0b2-0bee-4562-a29f-4dd7d8713cd9@gmx.com> (raw)
Hi,
With recent btrfs attempt to utilize larger folios (for its metadata), I
am hitting a case like this:
- Btrfs allocated an order 2 folio for metadata X
- Btrfs tries to add the order 2 folio at filepos X
Then filemap_add_folio() returns -EEXIST for filepos X.
- Btrfs tries to grab the existing metadata
Then filemap_lock_folio() returns -ENOENT for filepos X.
The above case can have two causes:
a) The folio at filepos X is released between add and lock
This is pretty rare, but still possible
b) Some folios exist at range [X+4K, X+16K)
In my observation, this is way more common than case a).
Case b) can be caused by the following situation:
- There is an extent buffer at filepos X
And it is consisted of 4 order 0 folios.
- vmscan wants to free folio at filepos X
It calls into the btrfs callback, btree_release_folio().
And btrfs did all the checks, release the metadata.
Now all the 4 folios at file pos [X, X+16K) have their private
flags cleared.
- vmscan freed folio at filepos X
However the remaining 3 folios X+4K, X+8K, X+12K are still attached
to the filemap, and in theory we should free all 4 folios in one go.
And later cause the conflicts with the larger folio we want to insert.
I'm wondering if there is anyway to make sure we can release all
involved folios in one go?
I guess it will need a new callback, and return a list of folios to be
released?
Thanks,
Qu
next reply other threads:[~2024-07-30 6:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 6:05 Qu Wenruo [this message]
2024-07-30 15:54 ` Matthew Wilcox
2024-07-30 21:18 ` Qu Wenruo
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=7e68a0b2-0bee-4562-a29f-4dd7d8713cd9@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=linux-btrfs@vger.kernel.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