Commit 2903fb16 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

[PATCH] vmscan: skip reclaim_mapped determination if we do not swap

This puts the variables and the way to get to reclaim_mapped in one block.
And allows zone_reclaim or other things to skip the determination (maybe
this whole block of code does not belong into refill_inactive_zone()?)
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 072eaa5d
...@@ -1195,48 +1195,55 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc) ...@@ -1195,48 +1195,55 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc)
struct page *page; struct page *page;
struct pagevec pvec; struct pagevec pvec;
int reclaim_mapped = 0; int reclaim_mapped = 0;
if (unlikely(sc->may_swap)) {
long mapped_ratio; long mapped_ratio;
long distress; long distress;
long swap_tendency; long swap_tendency;
lru_add_drain();
spin_lock_irq(&zone->lru_lock);
pgmoved = isolate_lru_pages(nr_pages, &zone->active_list,
&l_hold, &pgscanned);
zone->pages_scanned += pgscanned;
zone->nr_active -= pgmoved;
spin_unlock_irq(&zone->lru_lock);
/* /*
* `distress' is a measure of how much trouble we're having reclaiming * `distress' is a measure of how much trouble we're having
* pages. 0 -> no problems. 100 -> great trouble. * reclaiming pages. 0 -> no problems. 100 -> great trouble.
*/ */
distress = 100 >> zone->prev_priority; distress = 100 >> zone->prev_priority;
/* /*
* The point of this algorithm is to decide when to start reclaiming * The point of this algorithm is to decide when to start
* mapped memory instead of just pagecache. Work out how much memory * reclaiming mapped memory instead of just pagecache. Work out
* how much memory
* is mapped. * is mapped.
*/ */
mapped_ratio = (sc->nr_mapped * 100) / total_memory; mapped_ratio = (sc->nr_mapped * 100) / total_memory;
/* /*
* Now decide how much we really want to unmap some pages. The mapped * Now decide how much we really want to unmap some pages. The
* ratio is downgraded - just because there's a lot of mapped memory * mapped ratio is downgraded - just because there's a lot of
* doesn't necessarily mean that page reclaim isn't succeeding. * mapped memory doesn't necessarily mean that page reclaim
* isn't succeeding.
* *
* The distress ratio is important - we don't want to start going oom. * The distress ratio is important - we don't want to start
* going oom.
* *
* A 100% value of vm_swappiness overrides this algorithm altogether. * A 100% value of vm_swappiness overrides this algorithm
* altogether.
*/ */
swap_tendency = mapped_ratio / 2 + distress + vm_swappiness; swap_tendency = mapped_ratio / 2 + distress + vm_swappiness;
/* /*
* Now use this metric to decide whether to start moving mapped memory * Now use this metric to decide whether to start moving mapped
* onto the inactive list. * memory onto the inactive list.
*/ */
if (swap_tendency >= 100 && sc->may_swap) if (swap_tendency >= 100)
reclaim_mapped = 1; reclaim_mapped = 1;
}
lru_add_drain();
spin_lock_irq(&zone->lru_lock);
pgmoved = isolate_lru_pages(nr_pages, &zone->active_list,
&l_hold, &pgscanned);
zone->pages_scanned += pgscanned;
zone->nr_active -= pgmoved;
spin_unlock_irq(&zone->lru_lock);
while (!list_empty(&l_hold)) { while (!list_empty(&l_hold)) {
cond_resched(); cond_resched();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment