linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Michal Hocko <mhocko@suse.cz>, Hugh Dickins <hughd@google.com>,
	Minchan Kim <minchan@kernel.org>
Subject: [RFC 4/4] mm: free reclaimed pages instantly without depending next reclaim
Date: Mon, 13 May 2013 11:10:48 +0900	[thread overview]
Message-ID: <1368411048-3753-5-git-send-email-minchan@kernel.org> (raw)
In-Reply-To: <1368411048-3753-1-git-send-email-minchan@kernel.org>

Normally, file I/O for reclaiming is asynchronous so that
when page writeback is completed, reclaimed page will be
rotated into LRU tail for fast reclaiming in next turn.
But it makes unnecessary CPU overhead and more iteration with higher
priority of reclaim could reclaim too many pages than needed
pages.

This patch frees reclaimed pages by paging out instantly without
rotating back them into LRU's tail when the I/O is completed so
that we can get out of reclaim loop as soon as poosbile and avoid
unnecessary CPU overhead for moving them.

Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/filemap.c |  6 +++---
 mm/swap.c    | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 7905fe7..8e2017b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -618,12 +618,12 @@ EXPORT_SYMBOL(unlock_page);
  */
 void end_page_writeback(struct page *page)
 {
-	if (TestClearPageReclaim(page))
-		rotate_reclaimable_page(page);
-
 	if (!test_clear_page_writeback(page))
 		BUG();
 
+	if (TestClearPageReclaim(page))
+		rotate_reclaimable_page(page);
+
 	smp_mb__after_clear_bit();
 	wake_up_page(page, PG_writeback);
 }
diff --git a/mm/swap.c b/mm/swap.c
index dfd7d71..87f21632 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -324,7 +324,19 @@ static void pagevec_move_tail_fn(struct page *page, struct lruvec *lruvec,
 	int *pgmoved = arg;
 
 	if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
-		enum lru_list lru = page_lru_base_type(page);
+		enum lru_list lru;
+
+		if (!trylock_page(page))
+			goto move_tail;
+
+		if (!remove_mapping(page_mapping(page), page, true)) {
+			unlock_page(page);
+			goto move_tail;
+		}
+		unlock_page(page);
+		return;
+move_tail:
+		lru = page_lru_base_type(page);
 		list_move_tail(&page->lru, &lruvec->lists[lru]);
 		(*pgmoved)++;
 	}
-- 
1.8.2.1

--
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>

  parent reply	other threads:[~2013-05-13  2:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13  2:10 [RFC 0/4] free reclaimed pages by paging out instantly Minchan Kim
2013-05-13  2:10 ` [RFC 1/4] mm: Don't hide spin_lock in swap_info_get Minchan Kim
2013-05-13  2:10 ` [RFC 2/4] mm: introduce __swapcache_free Minchan Kim
2013-05-13  2:10 ` [RFC 3/4] mm: support remove_mapping in irqcontext Minchan Kim
2013-05-13 14:58   ` Michal Hocko
2013-05-14  7:17     ` Minchan Kim
2013-05-13  2:10 ` Minchan Kim [this message]
2013-05-14 17:32   ` [RFC 4/4] mm: free reclaimed pages instantly without depending next reclaim Rik van Riel
2013-05-15  7:12     ` Minchan Kim

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=1368411048-3753-5-git-send-email-minchan@kernel.org \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.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).