mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Nick Piggin <piggin@cyberone.com.au>
Cc: cw@f00f.org, mfedyk@matchmail.com, torvalds@osdl.org,
	linux-kernel@vger.kernel.org
Subject: Re: Large slab cache in 2.6.1
Date: Sun, 22 Feb 2004 16:46:17 -0800	[thread overview]
Message-ID: <20040222164617.7fba4321.akpm@osdl.org> (raw)
In-Reply-To: <40394A9F.1050606@cyberone.com.au>

Nick Piggin <piggin@cyberone.com.au> wrote:
>
> >We should be performing lowmem page reclaim, but we're not.  With some
> >highmem/lowmem size combinations the `incremental min' logic in the page
> >allocator will prevent __GFP_HIGHMEM allocations from taking ZONE_NORMAL
> >below pages_high and kswapd then does not perform page reclaim in the
> >lowmem zone at all.  I'm seeing some workloads where we reclaim 700 highmem
> >pages for each lowmem page.  This hugely exacerbated the slab problem on
> >1.5G machines.  I have that fixed up now.
> >
> >
> 
> This is the incremental min logic doing its work though. Maybe
> that should be fixed up to be less aggressive instead of putting
> more complexity in the scanner to work around it.

The scanner got simpler.

> Anyway could you post the patch you're using to fix it?

Sure.

> >Regardless of that, we do, logically, want to reclaim slab in response to
> >highmem reclaim pressure because any highmem allocation can be satisfied by
> >lowmem too.
> >
> >
> 
> The logical extension of that is: "we want to reclaim *lowmem* in
> response to highmem reclaim pressure because any ..."

yep.

> If this isn't what the scanner is doing then it should be fixed in
> a more generic way.


 include/linux/mmzone.h |    5 ++++-
 mm/page_alloc.c        |   13 ++++++++++++-
 mm/vmscan.c            |   22 +++++++++-------------
 3 files changed, 25 insertions(+), 15 deletions(-)

diff -puN mm/page_alloc.c~zone-balancing-batching mm/page_alloc.c
--- 25/mm/page_alloc.c~zone-balancing-batching	2004-02-22 15:15:52.000000000 -0800
+++ 25-akpm/mm/page_alloc.c	2004-02-22 15:15:52.000000000 -0800
@@ -1019,6 +1019,7 @@ void show_free_areas(void)
 			" min:%lukB"
 			" low:%lukB"
 			" high:%lukB"
+			" batch:%lukB"
 			" active:%lukB"
 			" inactive:%lukB"
 			"\n",
@@ -1027,6 +1028,7 @@ void show_free_areas(void)
 			K(zone->pages_min),
 			K(zone->pages_low),
 			K(zone->pages_high),
+			K(zone->reclaim_batch),
 			K(zone->nr_active),
 			K(zone->nr_inactive)
 			);
@@ -1618,6 +1620,8 @@ static void setup_per_zone_pages_min(voi
 			lowmem_pages += zone->present_pages;
 
 	for_each_zone(zone) {
+		unsigned long long reclaim_batch;
+
 		spin_lock_irqsave(&zone->lru_lock, flags);
 		if (is_highmem(zone)) {
 			/*
@@ -1642,8 +1646,15 @@ static void setup_per_zone_pages_min(voi
 			                   lowmem_pages;
 		}
 
-		zone-> pages_low = zone->pages_min * 2;
+		zone->pages_low = zone->pages_min * 2;
 		zone->pages_high = zone->pages_min * 3;
+
+		reclaim_batch = zone->present_pages * SWAP_CLUSTER_MAX;
+		do_div(reclaim_batch, lowmem_pages);
+		zone->reclaim_batch = reclaim_batch;
+		if (zone->reclaim_batch < 4)
+			zone->reclaim_batch = 4;
+
 		spin_unlock_irqrestore(&zone->lru_lock, flags);
 	}
 }
diff -puN mm/vmscan.c~zone-balancing-batching mm/vmscan.c
--- 25/mm/vmscan.c~zone-balancing-batching	2004-02-22 15:15:52.000000000 -0800
+++ 25-akpm/mm/vmscan.c	2004-02-22 15:15:52.000000000 -0800
@@ -859,13 +859,12 @@ shrink_zone(struct zone *zone, unsigned 
  */
 static int
 shrink_caches(struct zone **zones, int priority, int *total_scanned,
-		int gfp_mask, int nr_pages, struct page_state *ps)
+		int gfp_mask, struct page_state *ps)
 {
 	int ret = 0;
 	int i;
 
 	for (i = 0; zones[i] != NULL; i++) {
-		int to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX);
 		struct zone *zone = zones[i];
 		int nr_scanned;
 
@@ -875,8 +874,8 @@ shrink_caches(struct zone **zones, int p
 		if (zone->all_unreclaimable && priority != DEF_PRIORITY)
 			continue;	/* Let kswapd poll it */
 
-		ret += shrink_zone(zone, gfp_mask,
-				to_reclaim, &nr_scanned, ps, priority);
+		ret += shrink_zone(zone, gfp_mask, zone->reclaim_batch,
+				&nr_scanned, ps, priority);
 		*total_scanned += nr_scanned;
 	}
 	return ret;
@@ -904,7 +903,6 @@ int try_to_free_pages(struct zone **zone
 {
 	int priority;
 	int ret = 0;
-	const int nr_pages = SWAP_CLUSTER_MAX;
 	int nr_reclaimed = 0;
 	struct reclaim_state *reclaim_state = current->reclaim_state;
 	int i;
@@ -920,7 +918,7 @@ int try_to_free_pages(struct zone **zone
 
 		get_page_state(&ps);
 		nr_reclaimed += shrink_caches(zones, priority, &total_scanned,
-						gfp_mask, nr_pages, &ps);
+						gfp_mask, &ps);
 
 		shrink_slab(total_scanned, gfp_mask);
 		if (reclaim_state) {
@@ -928,7 +926,7 @@ int try_to_free_pages(struct zone **zone
 			reclaim_state->reclaimed_slab = 0;
 		}
 
-		if (nr_reclaimed >= nr_pages) {
+		if (nr_reclaimed >= SWAP_CLUSTER_MAX) {
 			ret = 1;
 			if (gfp_mask & __GFP_FS)
 				wakeup_bdflush(total_scanned);
@@ -1008,13 +1006,11 @@ static int balance_pgdat(pg_data_t *pgda
 			if (zone->all_unreclaimable && priority != DEF_PRIORITY)
 				continue;
 
-			if (nr_pages) {		/* Software suspend */
+			if (nr_pages)		/* Software suspend */
 				to_reclaim = min(to_free, SWAP_CLUSTER_MAX*8);
-			} else {		/* Zone balancing */
-				to_reclaim = zone->pages_high-zone->free_pages;
-				if (to_reclaim <= 0)
-					continue;
-			}
+			else			/* Zone balancing */
+				to_reclaim = zone->reclaim_batch;
+
 			all_zones_ok = 0;
 			zone->temp_priority = priority;
 			reclaimed = shrink_zone(zone, GFP_KERNEL,
diff -puN include/linux/mmzone.h~zone-balancing-batching include/linux/mmzone.h
--- 25/include/linux/mmzone.h~zone-balancing-batching	2004-02-22 15:15:52.000000000 -0800
+++ 25-akpm/include/linux/mmzone.h	2004-02-22 15:15:52.000000000 -0800
@@ -69,7 +69,10 @@ struct zone {
 	 */
 	spinlock_t		lock;
 	unsigned long		free_pages;
-	unsigned long		pages_min, pages_low, pages_high;
+	unsigned long		pages_min;
+	unsigned long		pages_low;
+	unsigned long		pages_high;
+	unsigned long		reclaim_batch;
 
 	ZONE_PADDING(_pad1_)
 

_


  reply	other threads:[~2004-02-23  0:45 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-22  0:50 Mike Fedyk
2004-02-22  1:09 ` Mike Fedyk
2004-02-22  1:20   ` William Lee Irwin III
2004-02-22  2:03     ` Mike Fedyk
2004-02-22  2:17       ` William Lee Irwin III
2004-02-22  2:38         ` Nick Piggin
2004-02-22  2:46           ` William Lee Irwin III
2004-02-22  2:40         ` Mike Fedyk
2004-02-22  2:58           ` Nick Piggin
2004-02-22  2:33       ` Nick Piggin
2004-02-22  2:46         ` Nick Piggin
2004-02-22  2:54           ` Nick Piggin
2004-02-22  2:36 ` Chris Wedgwood
2004-02-22  3:03   ` Linus Torvalds
2004-02-22  3:11     ` Chris Wedgwood
2004-02-22  3:28       ` Linus Torvalds
2004-02-22  3:29         ` Chris Wedgwood
2004-02-22  3:31         ` Chris Wedgwood
2004-02-22  4:01           ` Nick Piggin
2004-02-22  4:10             ` Nick Piggin
2004-02-22  4:30               ` Nick Piggin
2004-02-22  4:41                 ` Mike Fedyk
2004-02-22  5:37                   ` Nick Piggin
2004-02-22  5:44                     ` Chris Wedgwood
2004-02-22  5:52                       ` Nick Piggin
2004-02-22  5:50                     ` Mike Fedyk
2004-02-22  6:01                       ` Nick Piggin
2004-02-22  6:17                         ` Andrew Morton
2004-02-22  6:35                           ` Nick Piggin
2004-02-22  6:57                             ` Andrew Morton
2004-02-22  7:20                               ` Nick Piggin
2004-02-22  8:36                             ` Chris Wedgwood
2004-02-22  9:13                               ` Andrew Morton
2004-02-23  0:16                                 ` Nick Piggin
2004-02-23  0:26                                   ` Andrew Morton
2004-02-23  0:34                                     ` Nick Piggin
2004-02-23  0:46                                       ` Andrew Morton [this message]
2004-02-23  0:54                                         ` Nick Piggin
2004-02-23  1:00                                           ` Andrew Morton
2004-02-23  1:06                                             ` Nick Piggin
2004-02-22  6:45                         ` Mike Fedyk
2004-02-22  6:58                           ` Nick Piggin
2004-02-22  7:20                             ` Mike Fedyk
2004-02-22  6:09                 ` Andrew Morton
2004-02-22 17:05                   ` Linus Torvalds
2004-02-23  0:29                     ` Nick Piggin
2004-02-22  6:15         ` Andrew Morton
2004-02-22 16:08           ` Martin J. Bligh
2004-02-22 17:55             ` Jamie Lokier
2004-02-23  3:45               ` Mike Fedyk
2004-02-22 21:13             ` Dipankar Sarma
2004-02-22 14:03         ` Ed Tomlinson
2004-02-23  2:28           ` Mike Fedyk
2004-02-23  3:33             ` Ed Tomlinson
2004-02-22  3:21     ` Mike Fedyk
2004-02-22 11:00 Manfred Spraul

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=20040222164617.7fba4321.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=cw@f00f.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfedyk@matchmail.com \
    --cc=piggin@cyberone.com.au \
    --cc=torvalds@osdl.org \
    /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

all inboxes | Powered by JetHome®