Magellan Linux

Contents of /trunk/kernel26-alx/patches-2.6.17-r7/0022-2.6.17-mm-prio_dependant_scan-1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 199 - (show annotations) (download)
Fri May 18 11:04:36 2007 UTC (16 years, 11 months ago) by niro
File size: 6216 byte(s)
-import

1 Set the initial "priority" of memory reclaim scanning according to the cpu
2 scheduling priority thus determining how aggressively reclaim is to initally
3 progress according to nice level.
4
5 Signed-off-by: Con Kolivas <kernel@kolivas.org>
6
7 fs/buffer.c | 2 +-
8 include/linux/swap.h | 3 ++-
9 mm/page_alloc.c | 2 +-
10 mm/vmscan.c | 34 ++++++++++++++++++++--------------
11 4 files changed, 24 insertions(+), 17 deletions(-)
12
13 Index: linux-ck-dev/fs/buffer.c
14 ===================================================================
15 --- linux-ck-dev.orig/fs/buffer.c 2006-06-18 15:20:11.000000000 +1000
16 +++ linux-ck-dev/fs/buffer.c 2006-06-18 15:25:05.000000000 +1000
17 @@ -496,7 +496,7 @@ static void free_more_memory(void)
18 for_each_online_pgdat(pgdat) {
19 zones = pgdat->node_zonelists[gfp_zone(GFP_NOFS)].zones;
20 if (*zones)
21 - try_to_free_pages(zones, GFP_NOFS);
22 + try_to_free_pages(zones, GFP_NOFS, NULL);
23 }
24 }
25
26 Index: linux-ck-dev/include/linux/swap.h
27 ===================================================================
28 --- linux-ck-dev.orig/include/linux/swap.h 2006-06-18 15:24:58.000000000 +1000
29 +++ linux-ck-dev/include/linux/swap.h 2006-06-18 15:25:05.000000000 +1000
30 @@ -174,7 +174,8 @@ extern int rotate_reclaimable_page(struc
31 extern void swap_setup(void);
32
33 /* linux/mm/vmscan.c */
34 -extern unsigned long try_to_free_pages(struct zone **, gfp_t);
35 +extern unsigned long try_to_free_pages(struct zone **, gfp_t,
36 + struct task_struct *p);
37 extern unsigned long shrink_all_memory(unsigned long nr_pages);
38 extern int vm_mapped;
39 extern int vm_hardmaplimit;
40 Index: linux-ck-dev/mm/page_alloc.c
41 ===================================================================
42 --- linux-ck-dev.orig/mm/page_alloc.c 2006-06-18 15:25:02.000000000 +1000
43 +++ linux-ck-dev/mm/page_alloc.c 2006-06-18 15:25:05.000000000 +1000
44 @@ -1017,7 +1017,7 @@ rebalance:
45 reclaim_state.reclaimed_slab = 0;
46 p->reclaim_state = &reclaim_state;
47
48 - did_some_progress = try_to_free_pages(zonelist->zones, gfp_mask);
49 + did_some_progress = try_to_free_pages(zonelist->zones, gfp_mask, p);
50
51 p->reclaim_state = NULL;
52 p->flags &= ~PF_MEMALLOC;
53 Index: linux-ck-dev/mm/vmscan.c
54 ===================================================================
55 --- linux-ck-dev.orig/mm/vmscan.c 2006-06-18 15:25:02.000000000 +1000
56 +++ linux-ck-dev/mm/vmscan.c 2006-06-18 15:25:05.000000000 +1000
57 @@ -984,7 +984,8 @@ static unsigned long shrink_zones(int pr
58 * holds filesystem locks which prevent writeout this might not work, and the
59 * allocation attempt will fail.
60 */
61 -unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
62 +unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask,
63 + struct task_struct *p)
64 {
65 int priority;
66 int ret = 0;
67 @@ -992,7 +993,7 @@ unsigned long try_to_free_pages(struct z
68 unsigned long nr_reclaimed = 0;
69 struct reclaim_state *reclaim_state = current->reclaim_state;
70 unsigned long lru_pages = 0;
71 - int i;
72 + int i, scan_priority = DEF_PRIORITY;
73 struct scan_control sc = {
74 .gfp_mask = gfp_mask,
75 .may_writepage = !laptop_mode,
76 @@ -1001,6 +1002,9 @@ unsigned long try_to_free_pages(struct z
77 .mapped = vm_mapped,
78 };
79
80 + if (p)
81 + scan_priority = sc_priority(p);
82 +
83 delay_swap_prefetch();
84
85 inc_page_state(allocstall);
86 @@ -1011,11 +1015,11 @@ unsigned long try_to_free_pages(struct z
87 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
88 continue;
89
90 - zone->temp_priority = DEF_PRIORITY;
91 + zone->temp_priority = scan_priority;
92 lru_pages += zone->nr_active + zone->nr_inactive;
93 }
94
95 - for (priority = DEF_PRIORITY; priority >= 0; priority--) {
96 + for (priority = scan_priority; priority >= 0; priority--) {
97 sc.nr_mapped = read_page_state(nr_mapped);
98 sc.nr_scanned = 0;
99 if (!priority)
100 @@ -1046,7 +1050,7 @@ unsigned long try_to_free_pages(struct z
101 }
102
103 /* Take a nap, wait for some writeback to complete */
104 - if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
105 + if (sc.nr_scanned && priority < scan_priority - 2)
106 blk_congestion_wait(WRITE, HZ/10);
107 }
108 out:
109 @@ -1084,9 +1088,9 @@ out:
110 */
111 static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
112 {
113 - int all_zones_ok;
114 + int all_zones_ok = 0;
115 int priority;
116 - int i;
117 + int i, scan_priority;
118 unsigned long total_scanned;
119 unsigned long nr_reclaimed;
120 struct reclaim_state *reclaim_state = current->reclaim_state;
121 @@ -1097,6 +1101,8 @@ static unsigned long balance_pgdat(pg_da
122 .mapped = vm_mapped,
123 };
124
125 + scan_priority = sc_priority(pgdat->kswapd);
126 +
127 loop_again:
128 total_scanned = 0;
129 nr_reclaimed = 0;
130 @@ -1108,10 +1114,10 @@ loop_again:
131 for (i = 0; i < pgdat->nr_zones; i++) {
132 struct zone *zone = pgdat->node_zones + i;
133
134 - zone->temp_priority = DEF_PRIORITY;
135 + zone->temp_priority = scan_priority;
136 }
137
138 - for (priority = DEF_PRIORITY; priority >= 0; priority--) {
139 + for (priority = scan_priority; priority >= 0; priority--) {
140 int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */
141 unsigned long lru_pages = 0;
142
143 @@ -1132,7 +1138,7 @@ loop_again:
144 if (!populated_zone(zone))
145 continue;
146
147 - if (zone->all_unreclaimable && priority != DEF_PRIORITY)
148 + if (zone->all_unreclaimable && priority != scan_priority)
149 continue;
150
151 /*
152 @@ -1141,7 +1147,7 @@ loop_again:
153 * pages_high.
154 */
155 watermark = zone->pages_high + (zone->pages_high *
156 - priority / DEF_PRIORITY);
157 + priority / scan_priority);
158 if (!zone_watermark_ok(zone, order, watermark, 0, 0)) {
159 end_zone = i;
160 goto scan;
161 @@ -1173,11 +1179,11 @@ scan:
162 if (!populated_zone(zone))
163 continue;
164
165 - if (zone->all_unreclaimable && priority != DEF_PRIORITY)
166 + if (zone->all_unreclaimable && priority != scan_priority)
167 continue;
168
169 watermark = zone->pages_high + (zone->pages_high *
170 - priority / DEF_PRIORITY);
171 + priority / scan_priority);
172
173 if (!zone_watermark_ok(zone, order, watermark,
174 end_zone, 0))
175 @@ -1212,7 +1218,7 @@ scan:
176 * OK, kswapd is getting into trouble. Take a nap, then take
177 * another pass across the zones.
178 */
179 - if (total_scanned && priority < DEF_PRIORITY - 2)
180 + if (total_scanned && priority < scan_priority - 2)
181 blk_congestion_wait(WRITE, HZ/10);
182
183 /*