Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45303
b: refs/heads/master
c: 76395d3
h: refs/heads/master
i:
  45301: 4eaf22f
  45299: cd2cd72
  45295: dacce5e
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Jan 6, 2007
1 parent ba73bf7 commit 55e7a8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 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: d63b70902befe189ba2672925f28ec3f4db41352
refs/heads/master: 76395d37611e8758dd8bd6c6f5bfcb31e1dc48f9
33 changes: 16 additions & 17 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,16 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
return ret;
}

static unsigned long count_lru_pages(void)
{
struct zone *zone;
unsigned long ret = 0;

for_each_zone(zone)
ret += zone->nr_active + zone->nr_inactive;
return ret;
}

/*
* Try to free `nr_pages' of memory, system-wide, and return the number of
* freed pages.
Expand All @@ -1420,7 +1430,6 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
unsigned long ret = 0;
int pass;
struct reclaim_state reclaim_state;
struct zone *zone;
struct scan_control sc = {
.gfp_mask = GFP_KERNEL,
.may_swap = 0,
Expand All @@ -1431,10 +1440,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)

current->reclaim_state = &reclaim_state;

lru_pages = 0;
for_each_zone(zone)
lru_pages += zone->nr_active + zone->nr_inactive;

lru_pages = count_lru_pages();
nr_slab = global_page_state(NR_SLAB_RECLAIMABLE);
/* If slab caches are huge, it's better to hit them first */
while (nr_slab >= lru_pages) {
Expand All @@ -1461,13 +1467,6 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
for (pass = 0; pass < 5; pass++) {
int prio;

/* Needed for shrinking slab caches later on */
if (!lru_pages)
for_each_zone(zone) {
lru_pages += zone->nr_active;
lru_pages += zone->nr_inactive;
}

/* Force reclaiming mapped pages in the passes #3 and #4 */
if (pass > 2) {
sc.may_swap = 1;
Expand All @@ -1483,28 +1482,28 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
goto out;

reclaim_state.reclaimed_slab = 0;
shrink_slab(sc.nr_scanned, sc.gfp_mask, lru_pages);
shrink_slab(sc.nr_scanned, sc.gfp_mask,
count_lru_pages());
ret += reclaim_state.reclaimed_slab;
if (ret >= nr_pages)
goto out;

if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
congestion_wait(WRITE, HZ / 10);
}

lru_pages = 0;
}

/*
* If ret = 0, we could not shrink LRUs, but there may be something
* in slab caches
*/
if (!ret)
if (!ret) {
do {
reclaim_state.reclaimed_slab = 0;
shrink_slab(nr_pages, sc.gfp_mask, lru_pages);
shrink_slab(nr_pages, sc.gfp_mask, count_lru_pages());
ret += reclaim_state.reclaimed_slab;
} while (ret < nr_pages && reclaim_state.reclaimed_slab > 0);
}

out:
current->reclaim_state = NULL;
Expand Down

0 comments on commit 55e7a8d

Please sign in to comment.