From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>, Hugh Dickins <hughd@google.com>,
Minchan Kim <minchan@kernel.org>
Subject: [RFCv2 3/3] mm: Free reclaimed pages indepdent of next reclaim
Date: Fri, 20 Jun 2014 15:48:32 +0900 [thread overview]
Message-ID: <1403246912-18237-4-git-send-email-minchan@kernel.org> (raw)
In-Reply-To: <1403246912-18237-1-git-send-email-minchan@kernel.org>
Invalidate dirty/writeback page and file/swap I/O for reclaiming
are asynchronous so that when page writeback is completed,
it will be rotated back into LRU tail for freeing in next reclaim.
But it would make unnecessary CPU overhead and more aging
with higher priority of reclaim than necessary thing.
This patch makes such pages instant release when I/O complete
without LRU movement so that we could reduce reclaim events.
This patch wakes up one waiting PG_writeback and then clear
PG_reclaim bit because the page could be released during
rotating so it makes slighly race with Readahead logic but
the chance would be small and no huge side-effect even though
that happens, I belive.
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
mm/filemap.c | 17 +++++++++++------
mm/swap.c | 21 +++++++++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index c2f30ed8e95f..6e09de6cf510 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -752,23 +752,28 @@ EXPORT_SYMBOL(unlock_page);
*/
void end_page_writeback(struct page *page)
{
+ if (!test_clear_page_writeback(page))
+ BUG();
+
+ smp_mb__after_atomic();
+ wake_up_page(page, PG_writeback);
+
/*
* TestClearPageReclaim could be used here but it is an atomic
* operation and overkill in this particular case. Failing to
* shuffle a page marked for immediate reclaim is too mild to
* justify taking an atomic operation penalty at the end of
* ever page writeback.
+ *
+ * Clearing PG_reclaim after waking up waiter is slightly racy.
+ * Readahead might see PageReclaim as PageReadahead marker
+ * so readahead logic might be broken temporally but it isn't
+ * matter enough to care.
*/
if (PageReclaim(page)) {
ClearPageReclaim(page);
rotate_reclaimable_page(page);
}
-
- if (!test_clear_page_writeback(page))
- BUG();
-
- smp_mb__after_atomic();
- wake_up_page(page, PG_writeback);
}
EXPORT_SYMBOL(end_page_writeback);
diff --git a/mm/swap.c b/mm/swap.c
index 3074210f245d..d61b8783ccc3 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -443,6 +443,27 @@ static void pagevec_move_tail_fn(struct page *page, struct lruvec *lruvec,
if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
enum lru_list lru = page_lru_base_type(page);
+ struct address_space *mapping;
+
+ if (!trylock_page(page))
+ goto move_tail;
+
+ mapping = page_mapping(page);
+ if (!mapping)
+ goto unlock;
+
+ /*
+ * If it is successful, aotmic_remove_mapping
+ * makes page->count one so the page will be
+ * released when caller release his refcount.
+ */
+ if (atomic_remove_mapping(mapping, page)) {
+ unlock_page(page);
+ return;
+ }
+unlock:
+ unlock_page(page);
+move_tail:
list_move_tail(&page->lru, &lruvec->lists[lru]);
(*pgmoved)++;
}
--
2.0.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2014-06-20 6:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 6:48 [RFCv2 0/3] free reclaimed pages by paging out instantly Minchan Kim
2014-06-20 6:48 ` [RFCv2 1/3] mm: Don't hide spin_lock in swap_info_get internal Minchan Kim
2014-06-20 6:48 ` [RFCv2 2/3] mm: Introduce atomic_remove_mapping Minchan Kim
2014-06-20 6:48 ` Minchan Kim [this message]
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=1403246912-18237-4-git-send-email-minchan@kernel.org \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=riel@redhat.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;
as well as URLs for NNTP newsgroup(s).