All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Martin Bligh <mbligh@google.com>
Cc: Andrew Morton <akpm@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux Memory Management <linux-mm@kvack.org>
Subject: Re: [PATCH] Fix bug in try_to_free_pages and balance_pgdat when they fail to reclaim pages
Date: Tue, 17 Oct 2006 16:18:12 +1000	[thread overview]
Message-ID: <453475A4.2000504@yahoo.com.au> (raw)
In-Reply-To: <453425A5.5040304@google.com>

Martin Bligh wrote:

> The same bug is contained in both try_to_free_pages and balance_pgdat.
> On reclaiming the requisite number of pages we correctly set
> prev_priority back to DEF_PRIORITY.


AFAIKS, we set prev_priority to the priority at which the zone was
deemed to require no more reclaiming, not DEF_PRIORITY.

> However, we ALSO do this even
> if we loop over all priorities and fail to reclaim.


If that happens, shouldn't prev_priority be set to 0?

I don't agree the patch is correct.

>
> Setting prev_priority artificially high causes reclaimers to set
> distress artificially low, and fail to reclaim mapped pages, when
> they are, in fact, under severe memory pressure (their priority
> may be as low as 0). This causes the OOM killer to fire incorrectly.
>
> This patch changes that to set prev_priority to 0 instead, if we
> fail to reclaim.


We saw problems with this before releasing SLES10 too. See
zone_is_near_oom and other changesets from around that era. I would
like to know what workload was prevented from going OOM with these
changes, but zone_is_near_oom didn't help -- it must have been very
marginal (or there may indeed be a bug somewhere).

Nick
--

>
> Signed-off-by: Martin J. Bligh <mbligh@google.com>

>
>
>------------------------------------------------------------------------
>
>diff -aurpN -X /home/mbligh/.diff.exclude linux-2.6.18/mm/vmscan.c 2.6.18-prev_reset/mm/vmscan.c
>--- linux-2.6.18/mm/vmscan.c	2006-09-20 12:24:42.000000000 -0700
>+++ 2.6.18-prev_reset/mm/vmscan.c	2006-10-16 17:23:48.000000000 -0700
>@@ -962,7 +962,6 @@ static unsigned long shrink_zones(int pr
> unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
> {
> 	int priority;
>-	int ret = 0;
> 	unsigned long total_scanned = 0;
> 	unsigned long nr_reclaimed = 0;
> 	struct reclaim_state *reclaim_state = current->reclaim_state;
>@@ -1000,8 +999,15 @@ unsigned long try_to_free_pages(struct z
> 		}
> 		total_scanned += sc.nr_scanned;
> 		if (nr_reclaimed >= sc.swap_cluster_max) {
>-			ret = 1;
>-			goto out;
>+			for (i = 0; zones[i] != 0; i++) {
>+				struct zone *zone = zones[i];
>+
>+				if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
>+					continue;
>+
>+				zone->prev_priority = zone->temp_priority;
>+			}
>+			return 1;
> 		}
> 
> 		/*
>@@ -1021,16 +1027,15 @@ unsigned long try_to_free_pages(struct z
> 		if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
> 			blk_congestion_wait(WRITE, HZ/10);
> 	}
>-out:
> 	for (i = 0; zones[i] != 0; i++) {
> 		struct zone *zone = zones[i];
> 
> 		if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
> 			continue;
> 
>-		zone->prev_priority = zone->temp_priority;
>+		zone->prev_priority = 0;
> 	}
>-	return ret;
>+	return 0;
> }
> 
> /*
>@@ -1186,7 +1191,10 @@ out:
> 	for (i = 0; i < pgdat->nr_zones; i++) {
> 		struct zone *zone = pgdat->node_zones + i;
> 
>-		zone->prev_priority = zone->temp_priority;
>+		if (priority < 0)		/* we failed to reclaim */
>+			zone->prev_priority = 0;
>+		else
>+			zone->prev_priority = zone->temp_priority;
> 	}
> 	if (!all_zones_ok) {
> 		cond_resched();
>

Send instant messages to your online friends http://au.messenger.yahoo.com 

WARNING: multiple messages have this Message-ID (diff)
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Martin Bligh <mbligh@google.com>
Cc: Andrew Morton <akpm@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux Memory Management <linux-mm@kvack.org>
Subject: Re: [PATCH] Fix bug in try_to_free_pages and balance_pgdat when they fail to reclaim pages
Date: Tue, 17 Oct 2006 16:18:12 +1000	[thread overview]
Message-ID: <453475A4.2000504@yahoo.com.au> (raw)
In-Reply-To: <453425A5.5040304@google.com>

Martin Bligh wrote:

> The same bug is contained in both try_to_free_pages and balance_pgdat.
> On reclaiming the requisite number of pages we correctly set
> prev_priority back to DEF_PRIORITY.


AFAIKS, we set prev_priority to the priority at which the zone was
deemed to require no more reclaiming, not DEF_PRIORITY.

> However, we ALSO do this even
> if we loop over all priorities and fail to reclaim.


If that happens, shouldn't prev_priority be set to 0?

I don't agree the patch is correct.

>
> Setting prev_priority artificially high causes reclaimers to set
> distress artificially low, and fail to reclaim mapped pages, when
> they are, in fact, under severe memory pressure (their priority
> may be as low as 0). This causes the OOM killer to fire incorrectly.
>
> This patch changes that to set prev_priority to 0 instead, if we
> fail to reclaim.


We saw problems with this before releasing SLES10 too. See
zone_is_near_oom and other changesets from around that era. I would
like to know what workload was prevented from going OOM with these
changes, but zone_is_near_oom didn't help -- it must have been very
marginal (or there may indeed be a bug somewhere).

Nick
--

>
> Signed-off-by: Martin J. Bligh <mbligh@google.com>

>
>
>------------------------------------------------------------------------
>
>diff -aurpN -X /home/mbligh/.diff.exclude linux-2.6.18/mm/vmscan.c 2.6.18-prev_reset/mm/vmscan.c
>--- linux-2.6.18/mm/vmscan.c	2006-09-20 12:24:42.000000000 -0700
>+++ 2.6.18-prev_reset/mm/vmscan.c	2006-10-16 17:23:48.000000000 -0700
>@@ -962,7 +962,6 @@ static unsigned long shrink_zones(int pr
> unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
> {
> 	int priority;
>-	int ret = 0;
> 	unsigned long total_scanned = 0;
> 	unsigned long nr_reclaimed = 0;
> 	struct reclaim_state *reclaim_state = current->reclaim_state;
>@@ -1000,8 +999,15 @@ unsigned long try_to_free_pages(struct z
> 		}
> 		total_scanned += sc.nr_scanned;
> 		if (nr_reclaimed >= sc.swap_cluster_max) {
>-			ret = 1;
>-			goto out;
>+			for (i = 0; zones[i] != 0; i++) {
>+				struct zone *zone = zones[i];
>+
>+				if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
>+					continue;
>+
>+				zone->prev_priority = zone->temp_priority;
>+			}
>+			return 1;
> 		}
> 
> 		/*
>@@ -1021,16 +1027,15 @@ unsigned long try_to_free_pages(struct z
> 		if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
> 			blk_congestion_wait(WRITE, HZ/10);
> 	}
>-out:
> 	for (i = 0; zones[i] != 0; i++) {
> 		struct zone *zone = zones[i];
> 
> 		if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
> 			continue;
> 
>-		zone->prev_priority = zone->temp_priority;
>+		zone->prev_priority = 0;
> 	}
>-	return ret;
>+	return 0;
> }
> 
> /*
>@@ -1186,7 +1191,10 @@ out:
> 	for (i = 0; i < pgdat->nr_zones; i++) {
> 		struct zone *zone = pgdat->node_zones + i;
> 
>-		zone->prev_priority = zone->temp_priority;
>+		if (priority < 0)		/* we failed to reclaim */
>+			zone->prev_priority = 0;
>+		else
>+			zone->prev_priority = zone->temp_priority;
> 	}
> 	if (!all_zones_ok) {
> 		cond_resched();
>

Send instant messages to your online friends http://au.messenger.yahoo.com 

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

  reply	other threads:[~2006-10-17  6:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17  0:36 [PATCH] Fix bug in try_to_free_pages and balance_pgdat when they fail to reclaim pages Martin Bligh
2006-10-17  6:18 ` Nick Piggin [this message]
2006-10-17  6:18   ` Nick Piggin
2006-10-17  6:36   ` Martin J. Bligh
2006-10-17  6:36     ` Martin J. Bligh
2006-10-17  6:48     ` Nick Piggin
2006-10-17  6:48       ` Nick Piggin
2006-10-17 14:07       ` Martin J. Bligh
2006-10-17 14:07         ` Martin J. Bligh
2006-10-17 17:03         ` Nick Piggin
2006-10-17 17:03           ` Nick Piggin

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=453475A4.2000504@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mbligh@google.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.