Magellan Linux

Contents of /trunk/kernel26-magellan/patches-2.6.20-r4/0019-2.6.20-mm-prio_dependant_scan-2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 132 - (show annotations) (download)
Fri Apr 27 15:24:56 2007 UTC (17 years ago) by niro
File size: 6150 byte(s)
files for 2.6.20-r4

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 | 32 +++++++++++++++++++-------------
11 4 files changed, 23 insertions(+), 16 deletions(-)
12
13 Index: linux-2.6.20-ck1/fs/buffer.c
14 ===================================================================
15 --- linux-2.6.20-ck1.orig/fs/buffer.c 2007-02-05 22:52:03.000000000 +1100
16 +++ linux-2.6.20-ck1/fs/buffer.c 2007-02-16 19:01:33.000000000 +1100
17 @@ -362,7 +362,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-2.6.20-ck1/include/linux/swap.h
27 ===================================================================
28 --- linux-2.6.20-ck1.orig/include/linux/swap.h 2007-02-16 19:01:33.000000000 +1100
29 +++ linux-2.6.20-ck1/include/linux/swap.h 2007-02-16 19:01:33.000000000 +1100
30 @@ -187,7 +187,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-2.6.20-ck1/mm/page_alloc.c
41 ===================================================================
42 --- linux-2.6.20-ck1.orig/mm/page_alloc.c 2007-02-16 19:01:33.000000000 +1100
43 +++ linux-2.6.20-ck1/mm/page_alloc.c 2007-02-16 19:01:33.000000000 +1100
44 @@ -1316,7 +1316,7 @@ nofail_alloc:
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-2.6.20-ck1/mm/vmscan.c
54 ===================================================================
55 --- linux-2.6.20-ck1.orig/mm/vmscan.c 2007-02-16 19:01:33.000000000 +1100
56 +++ linux-2.6.20-ck1/mm/vmscan.c 2007-02-16 19:01:33.000000000 +1100
57 @@ -1052,7 +1052,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 @@ -1060,7 +1061,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 @@ -1069,6 +1070,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 count_vm_event(ALLOCSTALL);
86 @@ -1082,7 +1086,7 @@ unsigned long try_to_free_pages(struct z
87 lru_pages += zone->nr_active + zone->nr_inactive;
88 }
89
90 - for (priority = DEF_PRIORITY; priority >= 0; priority--) {
91 + for (priority = scan_priority; priority >= 0; priority--) {
92 sc.nr_scanned = 0;
93 if (!priority)
94 disable_swap_token();
95 @@ -1112,7 +1116,7 @@ unsigned long try_to_free_pages(struct z
96 }
97
98 /* Take a nap, wait for some writeback to complete */
99 - if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
100 + if (sc.nr_scanned && priority < scan_priority - 2)
101 congestion_wait(WRITE, HZ/10);
102 }
103 /* top priority shrink_caches still had more to do? don't OOM, then */
104 @@ -1162,9 +1166,9 @@ out:
105 */
106 static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
107 {
108 - int all_zones_ok;
109 + int all_zones_ok = 0;
110 int priority;
111 - int i;
112 + int i, scan_priority;
113 unsigned long total_scanned;
114 unsigned long nr_reclaimed;
115 struct reclaim_state *reclaim_state = current->reclaim_state;
116 @@ -1180,6 +1184,8 @@ static unsigned long balance_pgdat(pg_da
117 */
118 int temp_priority[MAX_NR_ZONES];
119
120 + scan_priority = sc_priority(pgdat->kswapd);
121 +
122 loop_again:
123 total_scanned = 0;
124 nr_reclaimed = 0;
125 @@ -1187,9 +1193,9 @@ loop_again:
126 count_vm_event(PAGEOUTRUN);
127
128 for (i = 0; i < pgdat->nr_zones; i++)
129 - temp_priority[i] = DEF_PRIORITY;
130 + temp_priority[i] = scan_priority;
131
132 - for (priority = DEF_PRIORITY; priority >= 0; priority--) {
133 + for (priority = scan_priority; priority >= 0; priority--) {
134 int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */
135 unsigned long lru_pages = 0;
136
137 @@ -1210,7 +1216,7 @@ loop_again:
138 if (!populated_zone(zone))
139 continue;
140
141 - if (zone->all_unreclaimable && priority != DEF_PRIORITY)
142 + if (zone->all_unreclaimable && priority != scan_priority)
143 continue;
144
145 /*
146 @@ -1219,7 +1225,7 @@ loop_again:
147 * pages_high.
148 */
149 watermark = zone->pages_high + (zone->pages_high *
150 - priority / DEF_PRIORITY);
151 + priority / scan_priority);
152 if (!zone_watermark_ok(zone, order, watermark, 0, 0)) {
153 end_zone = i;
154 break;
155 @@ -1251,11 +1257,11 @@ loop_again:
156 if (!populated_zone(zone))
157 continue;
158
159 - if (zone->all_unreclaimable && priority != DEF_PRIORITY)
160 + if (zone->all_unreclaimable && priority != scan_priority)
161 continue;
162
163 watermark = zone->pages_high + (zone->pages_high *
164 - priority / DEF_PRIORITY);
165 + priority / scan_priority);
166
167 if (!zone_watermark_ok(zone, order, watermark,
168 end_zone, 0))
169 @@ -1289,7 +1295,7 @@ loop_again:
170 * OK, kswapd is getting into trouble. Take a nap, then take
171 * another pass across the zones.
172 */
173 - if (total_scanned && priority < DEF_PRIORITY - 2)
174 + if (total_scanned && priority < scan_priority - 2)
175 congestion_wait(WRITE, HZ/10);
176
177 /*