From: Andrew Morton <akpm@osdl.org>
To: andrea@suse.de, noahm@csail.mit.edu, linux-kernel@vger.kernel.org
Subject: Re: OOM problems with 2.6.11-rc4
Date: Wed, 16 Mar 2005 04:15:53 -0800 [thread overview]
Message-ID: <20050316041553.4cdc205c.akpm@osdl.org> (raw)
In-Reply-To: <20050316040435.39533675.akpm@osdl.org>
Andrew Morton <akpm@osdl.org> wrote:
>
> Still, I think it would make more sense to return a success indication from
> shrink_slab() if we actually freed any slab objects. That will prevent us
> from incorrectly going all_unreclaimable if all we happen to be doing is
> increasing slab internal fragmentation.
>
> We could do that kludgily by re-polling the shrinker but it would be better
> to return a second value from all the shrinkers.
This is the kludgy version.
--- 25/mm/vmscan.c~vmscan-notice-slab-shrinking 2005-03-16 04:12:49.000000000 -0800
+++ 25-akpm/mm/vmscan.c 2005-03-16 04:14:02.000000000 -0800
@@ -180,17 +180,20 @@ EXPORT_SYMBOL(remove_shrinker);
* `lru_pages' represents the number of on-LRU pages in all the zones which
* are eligible for the caller's allocation attempt. It is used for balancing
* slab reclaim versus page reclaim.
+ *
+ * Returns the number of slab objects which we shrunk.
*/
static int shrink_slab(unsigned long scanned, unsigned int gfp_mask,
unsigned long lru_pages)
{
struct shrinker *shrinker;
+ int ret = 0;
if (scanned == 0)
scanned = SWAP_CLUSTER_MAX;
if (!down_read_trylock(&shrinker_rwsem))
- return 0;
+ return 1; /* Assume we'll be able to shrink next time */
list_for_each_entry(shrinker, &shrinker_list, list) {
unsigned long long delta;
@@ -209,10 +212,14 @@ static int shrink_slab(unsigned long sca
while (total_scan >= SHRINK_BATCH) {
long this_scan = SHRINK_BATCH;
int shrink_ret;
+ int nr_before;
+ nr_before = (*shrinker->shrinker)(0, gfp_mask);
shrink_ret = (*shrinker->shrinker)(this_scan, gfp_mask);
if (shrink_ret == -1)
break;
+ if (shrink_ret < nr_before)
+ ret += nr_before - shrink_ret;
mod_page_state(slabs_scanned, this_scan);
total_scan -= this_scan;
@@ -222,7 +229,7 @@ static int shrink_slab(unsigned long sca
shrinker->nr += total_scan;
}
up_read(&shrinker_rwsem);
- return 0;
+ return ret;
}
/* Called without lock on whether page is mapped, so answer is unstable */
@@ -1077,6 +1084,7 @@ scan:
*/
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
+ int nr_slab;
if (zone->present_pages == 0)
continue;
@@ -1098,14 +1106,15 @@ scan:
sc.swap_cluster_max = nr_pages? nr_pages : SWAP_CLUSTER_MAX;
shrink_zone(zone, &sc);
reclaim_state->reclaimed_slab = 0;
- shrink_slab(sc.nr_scanned, GFP_KERNEL, lru_pages);
+ nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL,
+ lru_pages);
sc.nr_reclaimed += reclaim_state->reclaimed_slab;
total_reclaimed += sc.nr_reclaimed;
total_scanned += sc.nr_scanned;
if (zone->all_unreclaimable)
continue;
- if (zone->pages_scanned >= (zone->nr_active +
- zone->nr_inactive) * 4)
+ if (nr_slab == 0 && zone->pages_scanned >=
+ (zone->nr_active + zone->nr_inactive) * 4)
zone->all_unreclaimable = 1;
/*
* If we've done a decent amount of scanning and
_
next prev parent reply other threads:[~2005-03-16 12:17 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-15 20:44 Noah Meyerhans
2005-03-15 21:56 ` Sean
2005-03-15 22:12 ` Lee Revell
2005-03-15 23:46 ` Andrew Morton
2005-03-18 16:12 ` Noah Meyerhans
2005-04-13 13:47 ` Andrea Arcangeli
2005-04-14 16:56 ` Noah Meyerhans
2005-03-16 0:31 ` Andrea Arcangeli
2005-03-16 11:12 ` Andrea Arcangeli
2005-03-16 12:04 ` Andrew Morton
2005-03-16 12:15 ` Andrew Morton [this message]
2005-03-16 18:37 ` Andrea Arcangeli
2005-03-16 22:21 ` Andrew Morton
2005-03-23 19:53 ` OOM problems on 2.6.12-rc1 with many fsx tests Mingming Cao
2005-03-23 22:49 ` Andrew Morton
2005-03-23 23:13 ` Martin J. Bligh
2005-03-23 23:20 ` Andrew Morton
2005-03-23 23:26 ` Andries Brouwer
2005-03-23 23:30 ` Martin J. Bligh
2005-03-23 23:42 ` Andrew Morton
2005-03-23 23:49 ` [Ext2-devel] " Badari Pulavarty
2005-03-24 1:49 ` Andrea Arcangeli
2005-03-24 2:00 ` Andrew Morton
2005-03-25 21:56 ` Andrew Morton
2005-03-25 22:11 ` [Ext2-devel] " Badari Pulavarty
2005-03-27 0:23 ` Mingming Cao
2005-03-27 19:22 ` Mingming Cao
2005-03-27 20:06 ` Badari Pulavarty
2005-03-27 20:17 ` Badari Pulavarty
2005-03-26 0:17 ` Dave Jones
2005-03-26 0:20 ` [Ext2-devel] " Badari Pulavarty
2005-04-04 1:35 ` Andrew Morton
2005-04-04 16:50 ` Mingming Cao
2005-04-04 20:04 ` Andrew Morton
2005-04-04 20:24 ` Martin J. Bligh
2005-04-04 20:33 ` Andrew Morton
2005-04-05 17:04 ` [Ext2-devel] " Mingming Cao
2005-04-06 1:23 ` Andrew Morton
2005-04-12 12:50 ` Stephen C. Tweedie
2005-04-05 16:44 ` Stephen C. Tweedie
2005-03-16 12:23 ` OOM problems with 2.6.11-rc4 Andrew Morton
2005-03-16 12:30 ` Andrew Morton
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=20050316041553.4cdc205c.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=andrea@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=noahm@csail.mit.edu \
/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
Powered by JetHome