Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2439
b: refs/heads/master
c: b15e090
h: refs/heads/master
i:
  2437: 39ac6b0
  2435: 19b4867
  2431: 5844e2d
v: v3
  • Loading branch information
akpm@osdl.org authored and Linus Torvalds committed Jun 22, 2005
1 parent 571ea50 commit 569a21c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 39c715b71740c4a78ba4769fb54826929bac03cb
refs/heads/master: b15e0905f2b9964fc7426fecab57445e96021b61
19 changes: 14 additions & 5 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -209,10 +212,14 @@ static int shrink_slab(unsigned long scanned, unsigned int gfp_mask,
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;

Expand All @@ -222,7 +229,7 @@ static int shrink_slab(unsigned long scanned, unsigned int gfp_mask,
shrinker->nr += total_scan;
}
up_read(&shrinker_rwsem);
return 0;
return ret;
}

/* Called without lock on whether page is mapped, so answer is unstable */
Expand Down Expand Up @@ -1079,6 +1086,7 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, int order)
*/
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
int nr_slab;

if (zone->present_pages == 0)
continue;
Expand All @@ -1100,14 +1108,15 @@ static int balance_pgdat(pg_data_t *pgdat, int nr_pages, int order)
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
Expand Down

0 comments on commit 569a21c

Please sign in to comment.