All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Andi Kleen <andi@firstfloor.org>, Michal Hocko <mhocko@suse.cz>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	kernel-team@fb.com
Subject: [PATCH 09/10] mm: only count actual rotations as LRU reclaim cost
Date: Mon,  6 Jun 2016 15:48:35 -0400	[thread overview]
Message-ID: <20160606194836.3624-10-hannes@cmpxchg.org> (raw)
In-Reply-To: <20160606194836.3624-1-hannes@cmpxchg.org>

Noting a reference on an active file page but still deactivating it
represents a smaller cost of reclaim than noting a referenced
anonymous page and actually physically rotating it back to the head.
The file page *might* refault later on, but it's definite progress
toward freeing pages, whereas rotating the anonymous page costs us
real time without making progress toward the reclaim goal.

Don't treat both events as equal. The following patch will hook up LRU
balancing to cache and swap refaults, which are a much more concrete
cost signal for reclaiming one list over the other. Remove the
maybe-IO cost bias from page references, and only note the CPU cost
for actual rotations that prevent the pages from getting reclaimed.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/vmscan.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 06e381e1004c..acbd212eab6e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1821,7 +1821,6 @@ static void shrink_active_list(unsigned long nr_to_scan,
 
 		if (page_referenced(page, 0, sc->target_mem_cgroup,
 				    &vm_flags)) {
-			nr_rotated += hpage_nr_pages(page);
 			/*
 			 * Identify referenced, file-backed active pages and
 			 * give them one more trip around the active list. So
@@ -1832,6 +1831,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
 			 * so we ignore them here.
 			 */
 			if ((vm_flags & VM_EXEC) && page_is_file_cache(page)) {
+				nr_rotated += hpage_nr_pages(page);
 				list_add(&page->lru, &l_active);
 				continue;
 			}
@@ -1846,10 +1846,8 @@ static void shrink_active_list(unsigned long nr_to_scan,
 	 */
 	spin_lock_irq(&zone->lru_lock);
 	/*
-	 * Count referenced pages from currently used mappings as rotated,
-	 * even though only some of them are actually re-activated.  This
-	 * helps balance scan pressure between file and anonymous pages in
-	 * get_scan_count.
+	 * Rotating pages costs CPU without actually
+	 * progressing toward the reclaim goal.
 	 */
 	lru_note_cost(lruvec, file, nr_rotated);
 
-- 
2.8.3

WARNING: multiple messages have this Message-ID (diff)
From: Johannes Weiner <hannes@cmpxchg.org>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Andi Kleen <andi@firstfloor.org>, Michal Hocko <mhocko@suse.cz>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	kernel-team@fb.com
Subject: [PATCH 09/10] mm: only count actual rotations as LRU reclaim cost
Date: Mon,  6 Jun 2016 15:48:35 -0400	[thread overview]
Message-ID: <20160606194836.3624-10-hannes@cmpxchg.org> (raw)
In-Reply-To: <20160606194836.3624-1-hannes@cmpxchg.org>

Noting a reference on an active file page but still deactivating it
represents a smaller cost of reclaim than noting a referenced
anonymous page and actually physically rotating it back to the head.
The file page *might* refault later on, but it's definite progress
toward freeing pages, whereas rotating the anonymous page costs us
real time without making progress toward the reclaim goal.

Don't treat both events as equal. The following patch will hook up LRU
balancing to cache and swap refaults, which are a much more concrete
cost signal for reclaiming one list over the other. Remove the
maybe-IO cost bias from page references, and only note the CPU cost
for actual rotations that prevent the pages from getting reclaimed.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/vmscan.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 06e381e1004c..acbd212eab6e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1821,7 +1821,6 @@ static void shrink_active_list(unsigned long nr_to_scan,
 
 		if (page_referenced(page, 0, sc->target_mem_cgroup,
 				    &vm_flags)) {
-			nr_rotated += hpage_nr_pages(page);
 			/*
 			 * Identify referenced, file-backed active pages and
 			 * give them one more trip around the active list. So
@@ -1832,6 +1831,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
 			 * so we ignore them here.
 			 */
 			if ((vm_flags & VM_EXEC) && page_is_file_cache(page)) {
+				nr_rotated += hpage_nr_pages(page);
 				list_add(&page->lru, &l_active);
 				continue;
 			}
@@ -1846,10 +1846,8 @@ static void shrink_active_list(unsigned long nr_to_scan,
 	 */
 	spin_lock_irq(&zone->lru_lock);
 	/*
-	 * Count referenced pages from currently used mappings as rotated,
-	 * even though only some of them are actually re-activated.  This
-	 * helps balance scan pressure between file and anonymous pages in
-	 * get_scan_count.
+	 * Rotating pages costs CPU without actually
+	 * progressing toward the reclaim goal.
 	 */
 	lru_note_cost(lruvec, file, nr_rotated);
 
-- 
2.8.3

--
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:[~2016-06-06 19:51 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 19:48 [PATCH 00/10] mm: balance LRU lists based on relative thrashing Johannes Weiner
2016-06-06 19:48 ` Johannes Weiner
2016-06-06 19:48 ` [PATCH 01/10] mm: allow swappiness that prefers anon over file Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-07  0:25   ` Minchan Kim
2016-06-07  0:25     ` Minchan Kim
2016-06-07 14:18     ` Johannes Weiner
2016-06-07 14:18       ` Johannes Weiner
2016-06-08  0:06       ` Minchan Kim
2016-06-08  0:06         ` Minchan Kim
2016-06-08 15:58         ` Johannes Weiner
2016-06-08 15:58           ` Johannes Weiner
2016-06-09  1:01           ` Minchan Kim
2016-06-09  1:01             ` Minchan Kim
2016-06-09 13:32             ` Johannes Weiner
2016-06-09 13:32               ` Johannes Weiner
2016-06-06 19:48 ` [PATCH 02/10] mm: swap: unexport __pagevec_lru_add() Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-06 21:32   ` Rik van Riel
2016-06-07  9:07   ` Michal Hocko
2016-06-07  9:07     ` Michal Hocko
2016-06-08  7:14   ` Minchan Kim
2016-06-08  7:14     ` Minchan Kim
2016-06-06 19:48 ` [PATCH 03/10] mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-06 21:33   ` Rik van Riel
2016-06-07  9:12   ` Michal Hocko
2016-06-07  9:12     ` Michal Hocko
2016-06-08  7:24   ` Minchan Kim
2016-06-08  7:24     ` Minchan Kim
2016-06-06 19:48 ` [PATCH 04/10] mm: fix LRU balancing effect of new transparent huge pages Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-06 21:36   ` Rik van Riel
2016-06-07  9:19   ` Michal Hocko
2016-06-07  9:19     ` Michal Hocko
2016-06-08  7:28   ` Minchan Kim
2016-06-08  7:28     ` Minchan Kim
2016-06-06 19:48 ` [PATCH 05/10] mm: remove LRU balancing effect of temporary page isolation Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-06 21:56   ` Rik van Riel
2016-06-06 22:15     ` Johannes Weiner
2016-06-06 22:15       ` Johannes Weiner
2016-06-07  1:11       ` Rik van Riel
2016-06-07 13:57         ` Johannes Weiner
2016-06-07 13:57           ` Johannes Weiner
2016-06-07  9:26       ` Michal Hocko
2016-06-07  9:26         ` Michal Hocko
2016-06-07 14:06         ` Johannes Weiner
2016-06-07 14:06           ` Johannes Weiner
2016-06-07  9:49   ` Michal Hocko
2016-06-07  9:49     ` Michal Hocko
2016-06-08  7:39   ` Minchan Kim
2016-06-08  7:39     ` Minchan Kim
2016-06-08 16:02     ` Johannes Weiner
2016-06-08 16:02       ` Johannes Weiner
2016-06-06 19:48 ` [PATCH 06/10] mm: remove unnecessary use-once cache bias from LRU balancing Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-07  2:20   ` Rik van Riel
2016-06-07 14:11     ` Johannes Weiner
2016-06-07 14:11       ` Johannes Weiner
2016-06-08  8:03   ` Minchan Kim
2016-06-08  8:03     ` Minchan Kim
2016-06-08 12:31   ` Michal Hocko
2016-06-08 12:31     ` Michal Hocko
2016-06-06 19:48 ` [PATCH 07/10] mm: base LRU balancing on an explicit cost model Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-06 19:13   ` kbuild test robot
2016-06-07  2:34   ` Rik van Riel
2016-06-07 14:12     ` Johannes Weiner
2016-06-07 14:12       ` Johannes Weiner
2016-06-08  8:14   ` Minchan Kim
2016-06-08  8:14     ` Minchan Kim
2016-06-08 16:06     ` Johannes Weiner
2016-06-08 16:06       ` Johannes Weiner
2016-06-08 12:51   ` Michal Hocko
2016-06-08 12:51     ` Michal Hocko
2016-06-08 16:16     ` Johannes Weiner
2016-06-08 16:16       ` Johannes Weiner
2016-06-09 12:18       ` Michal Hocko
2016-06-09 12:18         ` Michal Hocko
2016-06-09 13:33         ` Johannes Weiner
2016-06-09 13:33           ` Johannes Weiner
2016-06-06 19:48 ` [PATCH 08/10] mm: deactivations shouldn't bias the LRU balance Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-08  8:15   ` Minchan Kim
2016-06-08  8:15     ` Minchan Kim
2016-06-08 12:57   ` Michal Hocko
2016-06-08 12:57     ` Michal Hocko
2016-06-06 19:48 ` Johannes Weiner [this message]
2016-06-06 19:48   ` [PATCH 09/10] mm: only count actual rotations as LRU reclaim cost Johannes Weiner
2016-06-08  8:19   ` Minchan Kim
2016-06-08  8:19     ` Minchan Kim
2016-06-08 13:18   ` Michal Hocko
2016-06-08 13:18     ` Michal Hocko
2016-06-06 19:48 ` [PATCH 10/10] mm: balance LRU lists based on relative thrashing Johannes Weiner
2016-06-06 19:48   ` Johannes Weiner
2016-06-06 19:22   ` kbuild test robot
2016-06-06 23:50   ` Tim Chen
2016-06-06 23:50     ` Tim Chen
2016-06-07 16:23     ` Johannes Weiner
2016-06-07 16:23       ` Johannes Weiner
2016-06-07 19:56       ` Tim Chen
2016-06-07 19:56         ` Tim Chen
2016-06-08 13:58   ` Michal Hocko
2016-06-08 13:58     ` Michal Hocko
2016-06-10  2:19   ` Minchan Kim
2016-06-10  2:19     ` Minchan Kim
2016-06-13 15:52     ` Johannes Weiner
2016-06-13 15:52       ` Johannes Weiner
2016-06-15  2:23       ` Minchan Kim
2016-06-15  2:23         ` Minchan Kim
2016-06-16 15:12         ` Johannes Weiner
2016-06-16 15:12           ` Johannes Weiner
2016-06-17  7:49           ` Minchan Kim
2016-06-17  7:49             ` Minchan Kim
2016-06-17 17:01             ` Johannes Weiner
2016-06-17 17:01               ` Johannes Weiner
2016-06-20  7:42               ` Minchan Kim
2016-06-20  7:42                 ` Minchan Kim
2016-06-22 21:56                 ` Johannes Weiner
2016-06-22 21:56                   ` Johannes Weiner
2016-06-24  6:22                   ` Minchan Kim
2016-06-24  6:22                     ` Minchan Kim
2016-06-07  9:51 ` [PATCH 00/10] " Michal Hocko
2016-06-07  9:51   ` Michal Hocko

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=20160606194836.3624-10-hannes@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.cz \
    --cc=riel@redhat.com \
    --cc=tim.c.chen@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.