Another patchset from CK to lighten vm load
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / mm-lots_watermark.diff
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
9 in this code.
10
11 Signed-off-by: Con Kolivas <kernel@kolivas.org>
12
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(-)
17
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 {
23  
24  struct zone {
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;
28         /*
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)
36                         " min:%lukB"
37                         " low:%lukB"
38                         " high:%lukB"
39 +                       " lots:%lukB"
40                         " active_anon:%lukB"
41                         " inactive_anon:%lukB"
42                         " active_file:%lukB"
43 @@ -1581,6 +1582,7 @@ void show_free_areas(void)
44                         K(zone->pages_min),
45                         K(zone->pages_low),
46                         K(zone->pages_high),
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)
52  
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);
58         }
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:
64                  */
65                 for (i = pgdat->nr_zones - 1; i >= 0; i--) {
66                         struct zone *zone = pgdat->node_zones + i;
67 +                       unsigned long watermark;
68  
69                         if (!populated_zone(zone))
70                                 continue;
71 @@ -1178,8 +1179,14 @@ loop_again:
72                                 shrink_active_list(SWAP_CLUSTER_MAX, zone,
73                                                         &sc, priority, 0);
74  
75 -                       if (!zone_watermark_ok(zone, order, zone->pages_high,
76 -                                              0, 0)) {
77 +                       /*
78 +                        * The watermark is relaxed depending on the
79 +                        * level of "priority" till it drops to
80 +                        * pages_high.
81 +                        */
82 +                       watermark = zone->pages_high + (zone->pages_high *
83 +                                   priority / DEF_PRIORITY);
84 +                       if (!zone_watermark_ok(zone, order, watermark, 0, 0)) {
85                                 end_zone = i;
86                                 break;
87                         }
88 @@ -1206,6 +1213,7 @@ loop_again:
89                 for (i = 0; i <= end_zone; i++) {
90                         struct zone *zone = pgdat->node_zones + i;
91                         int nr_slab;
92 +                       unsigned long watermark;
93  
94                         if (!populated_zone(zone))
95                                 continue;
96 @@ -1213,7 +1221,10 @@ loop_again:
97                                         priority != DEF_PRIORITY)
98                                 continue;
99  
100 -                       if (!zone_watermark_ok(zone, order, zone->pages_high,
101 +                       watermark = zone->pages_high + (zone->pages_high *
102 +                                   priority / DEF_PRIORITY);
103 +
104 +                       if (!zone_watermark_ok(zone, order, watermark,
105                                                end_zone, 0))
106                                 all_zones_ok = 0;
107                         temp_priority[i] = priority;
108