vmscan: protect to read reclaim_stat by lru_lock
Subsystems (3)
PATCH 1/1 vmscan: protect to read reclaim_stat by lru_lock
Rik van Riel pointed out reading reclaim_stat should be protected lru_lock, otherwise vmscan might sweep 2x much pages.
This fault was introduced by followint commit.
commit 4f98a2fee8acdb4ac84545df98cccecfd130f8db
Author: Rik van Riel <[email protected]>
Date: Sat Oct 18 20:26:32 2008 -0700
vmscan: split LRU lists into anon & file sets
Split the LRU lists in two, one set for pages that are backed by real file systems ("file") and one for pages that are backed by memory and swap ("anon"). The latter includes tmpfs.
The advantage of doing this is that the VM will not have to scan over lots of anonymous pages (which we generally do not want to swap out), just to find the page cache pages that it should evict.
This patch has the infrastructure and a basic policy to balance how much we scan the anon lists and how much we scan the file lists. The big policy changes are in separate patches.
--- mm/vmscan.c | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-)
mm/vmscan.c +9 -11
@@ -1581,6 +1581,13 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, }/* +* With swappiness at 100, anonymous and file have the same priority. +* This scanning priority is essentially the inverse of IO cost. +*/ + anon_prio = sc->swappiness; + file_prio =200 - sc->swappiness; + +/* * OK, so we have swap space and a fair amount of page cache * pages. We use the recently rotated / recently scanned * ratios to determine how valuable each cache is.
@@ -1591,28 +1598,18 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,* * anon in [0], file in [1] */ +spin_lock_irq (&zone->lru_lock);if (unlikely (reclaim_stat->recent_scanned[0 ] > anon /4 )) { -spin_lock_irq (&zone->lru_lock); reclaim_stat->recent_scanned[0 ] /=2 ; reclaim_stat->recent_rotated[0 ] /=2 ; -spin_unlock_irq (&zone->lru_lock); }if (unlikely (reclaim_stat->recent_scanned[1 ] > file /4 )) { -spin_lock_irq (&zone->lru_lock); reclaim_stat->recent_scanned[1 ] /=2 ; reclaim_stat->recent_rotated[1 ] /=2 ; -spin_unlock_irq (&zone->lru_lock); }/* -* With swappiness at 100, anonymous and file have the same priority. -* This scanning priority is essentially the inverse of IO cost. -*/ - anon_prio = sc->swappiness; - file_prio =200 - sc->swappiness; - -/* * The amount of pressure on anon vs file pages is inversely * proportional to the fraction of recently scanned pages on * each list that were recently referenced and in active use.
@@ -1622,6 +1619,7 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, fp = (file_prio +1 ) * (reclaim_stat->recent_scanned[1 ] +1 ); fp /= reclaim_stat->recent_rotated[1 ] +1 ; +spin_unlock_irq (&zone->lru_lock); fraction[0 ] = ap; fraction[1 ] = fp;
Signature · 9 lines
1.6.5.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 19 lines · KOSAKI Motohiro
Rik van Riel pointed out reading
reclaim_statshould be protectedlru_lock, otherwise vmscan might sweep 2x much pages.This fault was introduced by followint commit.
commit
4f98a2fee8acdb4ac84545df98cccecfd130f8db
Author: Rik van Riel <[email protected]>
Date: Sat Oct 18 20:26:32 2008 -0700vmscan: split LRU lists into anon & file sets
Split the LRU lists in two, one set for pages that are backed by real file systems ("file") and one for pages that are backed by memory and swap ("anon"). The latter includes tmpfs.
The advantage of doing this is that the VM will not have to scan over lots of anonymous pages (which we generally do not want to swap out), just to find the page cache pages that it should evict.
Quoted 7 lines
This patch has the infrastructure and a basic policy to balance how much we scan the anon lists and how much we scan the file lists. The big policy changes are in separate patches.
Cc Rik van Riel <[email protected]>Cc Minchan Kim <[email protected]>Signed-off-by KOSAKI Motohiro <[email protected]>
Thanks, Kosaki. I have forgotten this issue.
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>