All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>, Michal Hocko <mhocko@suse.cz>,
	Mel Gorman <mgorman@suse.de>, Hugh Dickins <hughd@google.com>,
	Satoru Moriya <satoru.moriya@hds.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 2/7] mm: vmscan: save work scanning (almost) empty LRU lists
Date: Wed, 19 Dec 2012 15:59:01 -0800	[thread overview]
Message-ID: <20121219155901.c488bac2.akpm@linux-foundation.org> (raw)
In-Reply-To: <1355767957-4913-3-git-send-email-hannes@cmpxchg.org>

On Mon, 17 Dec 2012 13:12:32 -0500
Johannes Weiner <hannes@cmpxchg.org> wrote:

> In certain cases (kswapd reclaim, memcg target reclaim), a fixed
> minimum amount of pages is scanned from the LRU lists on each
> iteration, to make progress.
> 
> Do not make this minimum bigger than the respective LRU list size,
> however, and save some busy work trying to isolate and reclaim pages
> that are not there.
> 
> Empty LRU lists are quite common with memory cgroups in NUMA
> environments because there exists a set of LRU lists for each zone for
> each memory cgroup, while the memory of a single cgroup is expected to
> stay on just one node.  The number of expected empty LRU lists is thus
> 
>   memcgs * (nodes - 1) * lru types
> 
> Each attempt to reclaim from an empty LRU list does expensive size
> comparisons between lists, acquires the zone's lru lock etc.  Avoid
> that.
> 
> ...
>
> -#define SWAP_CLUSTER_MAX 32
> +#define SWAP_CLUSTER_MAX 32UL

You made me review the effects of this change.  It looks OK.  A few
cleanups are possible, please review.

I wonder what happens in __setup_per_zone_wmarks() if we set
SWAP_CLUSTER_MAX greater than 128.



From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/page_alloc.c:__setup_per_zone_wmarks: make min_pages unsigned long

`int' is an inappropriate type for a number-of-pages counter.

While we're there, use the clamp() macro.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Simon Jeons <simon.jeons@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff -puN mm/page_alloc.c~a mm/page_alloc.c
--- a/mm/page_alloc.c~a
+++ a/mm/page_alloc.c
@@ -5258,13 +5258,10 @@ static void __setup_per_zone_wmarks(void
 			 * deltas controls asynch page reclaim, and so should
 			 * not be capped for highmem.
 			 */
-			int min_pages;
+			unsigned long min_pages;
 
 			min_pages = zone->present_pages / 1024;
-			if (min_pages < SWAP_CLUSTER_MAX)
-				min_pages = SWAP_CLUSTER_MAX;
-			if (min_pages > 128)
-				min_pages = 128;
+			min_pages = clamp(min_pages, SWAP_CLUSTER_MAX, 128UL);
 			zone->watermark[WMARK_MIN] = min_pages;
 		} else {
 			/*
_


From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/vmscan.c:shrink_lruvec(): switch to min()

"mm: vmscan: save work scanning (almost) empty LRU lists" made
SWAP_CLUSTER_MAX an unsigned long.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Simon Jeons <simon.jeons@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/vmscan.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -puN mm/vmscan.c~a mm/vmscan.c
--- a/mm/vmscan.c~a
+++ a/mm/vmscan.c
@@ -1873,8 +1873,7 @@ restart:
 					nr[LRU_INACTIVE_FILE]) {
 		for_each_evictable_lru(lru) {
 			if (nr[lru]) {
-				nr_to_scan = min_t(unsigned long,
-						   nr[lru], SWAP_CLUSTER_MAX);
+				nr_to_scan = min(nr[lru], SWAP_CLUSTER_MAX);
 				nr[lru] -= nr_to_scan;
 
 				nr_reclaimed += shrink_list(lru, nr_to_scan,
_


From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/vmscan.c:__zone_reclaim(): replace max_t() with max()

"mm: vmscan: save work scanning (almost) empty LRU lists" made
SWAP_CLUSTER_MAX an unsigned long.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Simon Jeons <simon.jeons@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/vmscan.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -puN mm/vmscan.c~mm-vmscanc-__zone_reclaim-replace-max_t-with-max mm/vmscan.c
--- a/mm/vmscan.c~mm-vmscanc-__zone_reclaim-replace-max_t-with-max
+++ a/mm/vmscan.c
@@ -3347,8 +3347,7 @@ static int __zone_reclaim(struct zone *z
 		.may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
 		.may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP),
 		.may_swap = 1,
-		.nr_to_reclaim = max_t(unsigned long, nr_pages,
-				       SWAP_CLUSTER_MAX),
+		.nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX),
 		.gfp_mask = gfp_mask,
 		.order = order,
 		.priority = ZONE_RECLAIM_PRIORITY,
_

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

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>, Michal Hocko <mhocko@suse.cz>,
	Mel Gorman <mgorman@suse.de>, Hugh Dickins <hughd@google.com>,
	Satoru Moriya <satoru.moriya@hds.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 2/7] mm: vmscan: save work scanning (almost) empty LRU lists
Date: Wed, 19 Dec 2012 15:59:01 -0800	[thread overview]
Message-ID: <20121219155901.c488bac2.akpm@linux-foundation.org> (raw)
In-Reply-To: <1355767957-4913-3-git-send-email-hannes@cmpxchg.org>

On Mon, 17 Dec 2012 13:12:32 -0500
Johannes Weiner <hannes@cmpxchg.org> wrote:

> In certain cases (kswapd reclaim, memcg target reclaim), a fixed
> minimum amount of pages is scanned from the LRU lists on each
> iteration, to make progress.
> 
> Do not make this minimum bigger than the respective LRU list size,
> however, and save some busy work trying to isolate and reclaim pages
> that are not there.
> 
> Empty LRU lists are quite common with memory cgroups in NUMA
> environments because there exists a set of LRU lists for each zone for
> each memory cgroup, while the memory of a single cgroup is expected to
> stay on just one node.  The number of expected empty LRU lists is thus
> 
>   memcgs * (nodes - 1) * lru types
> 
> Each attempt to reclaim from an empty LRU list does expensive size
> comparisons between lists, acquires the zone's lru lock etc.  Avoid
> that.
> 
> ...
>
> -#define SWAP_CLUSTER_MAX 32
> +#define SWAP_CLUSTER_MAX 32UL

You made me review the effects of this change.  It looks OK.  A few
cleanups are possible, please review.

I wonder what happens in __setup_per_zone_wmarks() if we set
SWAP_CLUSTER_MAX greater than 128.



From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/page_alloc.c:__setup_per_zone_wmarks: make min_pages unsigned long

`int' is an inappropriate type for a number-of-pages counter.

While we're there, use the clamp() macro.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Simon Jeons <simon.jeons@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff -puN mm/page_alloc.c~a mm/page_alloc.c
--- a/mm/page_alloc.c~a
+++ a/mm/page_alloc.c
@@ -5258,13 +5258,10 @@ static void __setup_per_zone_wmarks(void
 			 * deltas controls asynch page reclaim, and so should
 			 * not be capped for highmem.
 			 */
-			int min_pages;
+			unsigned long min_pages;
 
 			min_pages = zone->present_pages / 1024;
-			if (min_pages < SWAP_CLUSTER_MAX)
-				min_pages = SWAP_CLUSTER_MAX;
-			if (min_pages > 128)
-				min_pages = 128;
+			min_pages = clamp(min_pages, SWAP_CLUSTER_MAX, 128UL);
 			zone->watermark[WMARK_MIN] = min_pages;
 		} else {
 			/*
_


From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/vmscan.c:shrink_lruvec(): switch to min()

"mm: vmscan: save work scanning (almost) empty LRU lists" made
SWAP_CLUSTER_MAX an unsigned long.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Simon Jeons <simon.jeons@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/vmscan.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -puN mm/vmscan.c~a mm/vmscan.c
--- a/mm/vmscan.c~a
+++ a/mm/vmscan.c
@@ -1873,8 +1873,7 @@ restart:
 					nr[LRU_INACTIVE_FILE]) {
 		for_each_evictable_lru(lru) {
 			if (nr[lru]) {
-				nr_to_scan = min_t(unsigned long,
-						   nr[lru], SWAP_CLUSTER_MAX);
+				nr_to_scan = min(nr[lru], SWAP_CLUSTER_MAX);
 				nr[lru] -= nr_to_scan;
 
 				nr_reclaimed += shrink_list(lru, nr_to_scan,
_


From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm/vmscan.c:__zone_reclaim(): replace max_t() with max()

"mm: vmscan: save work scanning (almost) empty LRU lists" made
SWAP_CLUSTER_MAX an unsigned long.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Satoru Moriya <satoru.moriya@hds.com>
Cc: Simon Jeons <simon.jeons@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/vmscan.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -puN mm/vmscan.c~mm-vmscanc-__zone_reclaim-replace-max_t-with-max mm/vmscan.c
--- a/mm/vmscan.c~mm-vmscanc-__zone_reclaim-replace-max_t-with-max
+++ a/mm/vmscan.c
@@ -3347,8 +3347,7 @@ static int __zone_reclaim(struct zone *z
 		.may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
 		.may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP),
 		.may_swap = 1,
-		.nr_to_reclaim = max_t(unsigned long, nr_pages,
-				       SWAP_CLUSTER_MAX),
+		.nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX),
 		.gfp_mask = gfp_mask,
 		.order = order,
 		.priority = ZONE_RECLAIM_PRIORITY,
_


  reply	other threads:[~2012-12-19 23:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17 18:12 [patch 0/8] page reclaim bits v2 Johannes Weiner
2012-12-17 18:12 ` Johannes Weiner
2012-12-17 18:12 ` [patch 1/7] mm: memcg: only evict file pages when we have plenty Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-17 18:15   ` Rik van Riel
2012-12-17 18:15     ` Rik van Riel
2012-12-18  9:56   ` Mel Gorman
2012-12-18  9:56     ` Mel Gorman
2012-12-17 18:12 ` [patch 2/7] mm: vmscan: save work scanning (almost) empty LRU lists Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-19 23:59   ` Andrew Morton [this message]
2012-12-19 23:59     ` Andrew Morton
2012-12-20 13:55     ` Michal Hocko
2012-12-20 13:55       ` Michal Hocko
2012-12-21  3:02     ` Johannes Weiner
2012-12-21  3:02       ` Johannes Weiner
2012-12-17 18:12 ` [patch 3/7] mm: vmscan: clarify how swappiness, highest priority, memcg interact Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-17 18:16   ` Rik van Riel
2012-12-17 18:16     ` Rik van Riel
2012-12-17 19:37   ` Satoru Moriya
2012-12-17 19:37     ` Satoru Moriya
2012-12-17 20:05   ` Michal Hocko
2012-12-17 20:05     ` Michal Hocko
2012-12-18 10:04   ` Mel Gorman
2012-12-18 10:04     ` Mel Gorman
2012-12-18 15:16   ` Satoru Moriya
2012-12-18 15:16     ` Satoru Moriya
2012-12-17 18:12 ` [patch 4/7] mm: vmscan: improve comment on low-page cache handling Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-17 18:12 ` [patch 5/7] mm: vmscan: clean up get_scan_count() Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-20  0:08   ` Andrew Morton
2012-12-20  0:08     ` Andrew Morton
2012-12-21  2:49     ` Johannes Weiner
2012-12-21  2:49       ` Johannes Weiner
2012-12-17 18:12 ` [patch 6/7] mm: vmscan: compaction works against zones, not lruvecs Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-17 18:12 ` [patch 7/7] mm: reduce rmap overhead for ex-KSM page copies created on swap faults Johannes Weiner
2012-12-17 18:12   ` Johannes Weiner
2012-12-17 22:42   ` Hugh Dickins
2012-12-17 22:42     ` Hugh Dickins
2012-12-19  7:01   ` Simon Jeons
2012-12-19  7:01     ` Simon Jeons
2012-12-19 17:58     ` Johannes Weiner
2012-12-19 17:58       ` Johannes Weiner

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=20121219155901.c488bac2.akpm@linux-foundation.org \
    --to=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 \
    --cc=satoru.moriya@hds.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.