From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 18/19] allow GFP_NOFS allocators to perform swapcache writeout
Date: Sun, 16 Jun 2002 23:53:51 -0700 [thread overview]
Message-ID: <3D0D877F.8996BD6B@zip.com.au> (raw)
(Requires the direct-to-BIO-for-swap patch)
One weakness which was introduced when the buffer LRU went away was
that GFP_NOFS allocations became equivalent to GFP_NOIO. Because all
writeback goes via writepage/writepages, which requires entry into the
filesystem.
However now that swapout no longer calls bmap(), we can honour
GFP_NOFS's intent for swapcache pages. So if the allocation request
specifies __GFP_IO and !__GFP_FS, we can wait on swapcache pages and we
can perform swapcache writeout.
This should strengthen the VM somewhat.
--- 2.5.22/mm/vmscan.c~GFP_IO-swap Sun Jun 16 23:12:53 2002
+++ 2.5.22-akpm/mm/vmscan.c Sun Jun 16 23:12:53 2002
@@ -391,7 +391,8 @@ shrink_cache(int nr_pages, zone_t *class
spin_lock(&pagemap_lru_lock);
while (--max_scan >= 0 &&
(entry = inactive_list.prev) != &inactive_list) {
- struct page * page;
+ struct page *page;
+ int may_enter_fs;
if (need_resched()) {
spin_unlock(&pagemap_lru_lock);
@@ -426,10 +427,17 @@ shrink_cache(int nr_pages, zone_t *class
goto page_mapped;
/*
+ * swap activity never enters the filesystem and is safe
+ * for GFP_NOFS allocations.
+ */
+ may_enter_fs = (gfp_mask & __GFP_FS) ||
+ (PageSwapCache(page) && (gfp_mask & __GFP_IO));
+
+ /*
* IO in progress? Leave it at the back of the list.
*/
if (unlikely(PageWriteback(page))) {
- if (gfp_mask & __GFP_FS) {
+ if (may_enter_fs) {
page_cache_get(page);
spin_unlock(&pagemap_lru_lock);
wait_on_page_writeback(page);
@@ -450,7 +458,7 @@ shrink_cache(int nr_pages, zone_t *class
mapping = page->mapping;
if (PageDirty(page) && is_page_cache_freeable(page) &&
- page->mapping && (gfp_mask & __GFP_FS)) {
+ page->mapping && may_enter_fs) {
/*
* It is not critical here to write it only if
* the page is unmapped beause any direct writer
@@ -479,6 +487,15 @@ shrink_cache(int nr_pages, zone_t *class
* If the page has buffers, try to free the buffer mappings
* associated with this page. If we succeed we try to free
* the page as well.
+ *
+ * We do this even if the page is PageDirty().
+ * try_to_release_page() does not perform I/O, but it is
+ * possible for a page to have PageDirty set, but it is actually
+ * clean (all its buffers are clean). This happens if the
+ * buffers were written out directly, with submit_bh(). ext3
+ * will do this, as well as the blockdev mapping.
+ * try_to_release_page() will discover that cleanness and will
+ * drop the buffers and mark the page clean - it can be freed.
*/
if (PagePrivate(page)) {
spin_unlock(&pagemap_lru_lock);
-
reply other threads:[~2002-06-17 6:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=3D0D877F.8996BD6B@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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