1 The vm currently performs scanning when allocating ram once the watermarks
2 are below the pages_low value and tries to restore them to the pages_high
3 watermark. The disadvantage of this is that we are scanning most aggresssively
4 at the same time we are allocating ram regardless of the stress the vm is
5 under. Add a pages_lots watermark and allow the watermark to be relaxed
6 according to the stress the vm is at the time (according to the priority
7 value). Thus we have more in reserve next time we are allocating ram and end
8 up scanning less aggresssively. Note the actual pages_lots isn't used directly
11 Signed-off-by: Con Kolivas <kernel@kolivas.org>
13 include/linux/mmzone.h | 2 +-
14 mm/page_alloc.c | 3 +++
15 mm/vmscan.c | 17 ++++++++++++++---
16 3 files changed, 18 insertions(+), 4 deletions(-)
18 Index: linux-2.6.22-ck1/include/linux/mmzone.h
19 ===================================================================
20 --- linux-2.6.22-ck1.orig/include/linux/mmzone.h 2007-07-09 18:44:34.000000000 +1000
21 +++ linux-2.6.22-ck1/include/linux/mmzone.h 2007-07-09 18:44:39.000000000 +1000
22 @@ -181,7 +181,7 @@ enum zone_type {
25 /* Fields commonly accessed by the page allocator */
26 - unsigned long pages_min, pages_low, pages_high;
27 + unsigned long pages_min, pages_low, pages_high, pages_lots;
29 * We don't know if the memory that we're going to allocate will be freeable
30 * or/and it will be released eventually, so to avoid totally wasting several
31 Index: linux-2.6.22-ck1/mm/page_alloc.c
32 ===================================================================
33 --- linux-2.6.22-ck1.orig/mm/page_alloc.c 2007-07-09 18:44:34.000000000 +1000
34 +++ linux-2.6.22-ck1/mm/page_alloc.c 2007-07-09 18:44:39.000000000 +1000
35 @@ -1570,6 +1570,7 @@ void show_free_areas(void)
41 " inactive_anon:%lukB"
43 @@ -1581,6 +1582,7 @@ void show_free_areas(void)
47 + K(zone->pages_lots),
48 K(zone_page_state(zone, NR_ACTIVE_ANON)),
49 K(zone_page_state(zone, NR_INACTIVE_ANON)),
50 K(zone_page_state(zone, NR_ACTIVE_FILE)),
51 @@ -3142,6 +3144,7 @@ void setup_per_zone_pages_min(void)
53 zone->pages_low = zone->pages_min + (tmp >> 2);
54 zone->pages_high = zone->pages_min + (tmp >> 1);
55 + zone->pages_lots = zone->pages_min + tmp;
56 setup_zone_migrate_reserve(zone);
57 spin_unlock_irqrestore(&zone->lock, flags);
59 Index: linux-2.6.22-ck1/mm/vmscan.c
60 ===================================================================
61 --- linux-2.6.22-ck1.orig/mm/vmscan.c 2007-07-09 18:44:39.000000000 +1000
62 +++ linux-2.6.22-ck1/mm/vmscan.c 2007-07-09 18:44:39.000000000 +1000
63 @@ -1171,6 +1171,7 @@ loop_again:
65 for (i = pgdat->nr_zones - 1; i >= 0; i--) {
66 struct zone *zone = pgdat->node_zones + i;
67 + unsigned long watermark;
69 if (!populated_zone(zone))
71 @@ -1178,8 +1179,14 @@ loop_again:
72 shrink_active_list(SWAP_CLUSTER_MAX, zone,
75 - if (!zone_watermark_ok(zone, order, zone->pages_high,
78 + * The watermark is relaxed depending on the
79 + * level of "priority" till it drops to
82 + watermark = zone->pages_high + (zone->pages_high *
83 + priority / DEF_PRIORITY);
84 + if (!zone_watermark_ok(zone, order, watermark, 0, 0)) {
88 @@ -1206,6 +1213,7 @@ loop_again:
89 for (i = 0; i <= end_zone; i++) {
90 struct zone *zone = pgdat->node_zones + i;
92 + unsigned long watermark;
94 if (!populated_zone(zone))
96 @@ -1213,7 +1221,10 @@ loop_again:
97 priority != DEF_PRIORITY)
100 - if (!zone_watermark_ok(zone, order, zone->pages_high,
101 + watermark = zone->pages_high + (zone->pages_high *
102 + priority / DEF_PRIORITY);
104 + if (!zone_watermark_ok(zone, order, watermark,
107 temp_priority[i] = priority;