Re: [patch 07/19] (NEW) add some sanity checks to get_scan_ratio

Previous thread: [patch 09/19] (NEW) more aggressively use lumpy reclaim by Rik van Riel on Tuesday, January 8, 2008 - 4:59 pm. (3 messages)

Next thread: [patch 06/19] SEQ replacement for anonymous pages by Rik van Riel on Tuesday, January 8, 2008 - 4:59 pm. (1 message)
To: <linux-kernel@...>
Cc: <linux-mm@...>
Date: Tuesday, January 8, 2008 - 4:59 pm

The access ratio based scan rate determination in get_scan_ratio
works ok in most situations, but needs to be corrected in some
corner cases:
- if we run out of swap space, do not bother scanning the anon LRUs
- if we have already freed all of the page cache, we need to scan
the anon LRUs

Signed-off-by: Rik van Riel <riel@redhat.com>

Index: linux-2.6.24-rc6-mm1/mm/vmscan.c
===================================================================
--- linux-2.6.24-rc6-mm1.orig/mm/vmscan.c 2008-01-07 17:33:50.000000000 -0500
+++ linux-2.6.24-rc6-mm1/mm/vmscan.c 2008-01-07 17:57:49.000000000 -0500
@@ -1182,7 +1182,7 @@ static unsigned long shrink_list(enum lr
static void get_scan_ratio(struct zone *zone, struct scan_control * sc,
unsigned long *percent)
{
- unsigned long anon, file;
+ unsigned long anon, file, free;
unsigned long anon_prio, file_prio;
unsigned long rotate_sum;
unsigned long ap, fp;
@@ -1230,6 +1230,20 @@ static void get_scan_ratio(struct zone *
else if (fp > 100)
fp = 100;
percent[1] = fp;
+
+ free = zone_page_state(zone, NR_FREE_PAGES);
+
+ /*
+ * If we have no swap space, do not bother scanning anon pages
+ */
+ if (nr_swap_pages <= 0)
+ percent[0] = 0;
+ /*
+ * If we already freed most file pages, scan the anon pages
+ * regardless of the page access ratios or swappiness setting.
+ */
+ else if (file + free <= zone->pages_high)
+ percent[0] = 100;
}

--
All Rights Reversed

--

To: Rik van Riel <riel@...>
Cc: <linux-kernel@...>, <linux-mm@...>
Date: Wednesday, January 9, 2008 - 12:16 am

On Tue, 08 Jan 2008 15:59:46 -0500
Doesn't this mean that swap-cache in ACTIVE_ANON_LIST is not scanned ?
Or swap-cache is in File-Cache list ?

Thanks,
-Kame

--

To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Cc: <linux-kernel@...>, <linux-mm@...>
Date: Wednesday, January 9, 2008 - 8:53 am

On Wed, 9 Jan 2008 13:16:42 +0900

You are right, the swap cache will not be scanned once we run
completely out of swap space. To compensate for that, this
patch series has a patch that does scanning of swap cache and
freeing of swap space used by pages on the LRU list while there
is still space free.

Scanning all of the anon LRU lists could be a lot of work for
very little gain. A typical large server will have 32GB or
more of RAM, but only the default 2GB of swap.

All we accomplish by scanning the anonymous memory on a system
like that (once swap is full) is eating up CPU time and causing
lock contention.

--
All rights reversed.
--

Previous thread: [patch 09/19] (NEW) more aggressively use lumpy reclaim by Rik van Riel on Tuesday, January 8, 2008 - 4:59 pm. (3 messages)

Next thread: [patch 06/19] SEQ replacement for anonymous pages by Rik van Riel on Tuesday, January 8, 2008 - 4:59 pm. (1 message)