Contents of /trunk/kernel26-alx/patches-2.6.20-r6/0016-2.6.20-mm-convert_swappiness_to_mapped.patch
Parent Directory | Revision Log
Revision 1175 -
(show annotations)
(download)
Thu Oct 14 12:15:46 2010 UTC (13 years, 11 months ago) by niro
File size: 7785 byte(s)
Thu Oct 14 12:15:46 2010 UTC (13 years, 11 months ago) by niro
File size: 7785 byte(s)
-2.6.20-alx-r6 new magellan 0.5.2 kernel
1 | Turn the "swappiness" knob into one with well defined semantics. Rename it |
2 | "mapped" to correspond directly with the percentage of mapped ram or |
3 | "applications" as users think of it. Currently the swappiness algorithm can |
4 | easily lead to swapping situations on simple file copies due to the distress |
5 | algorithm which too easily overrides the swappiness value. Add a |
6 | "hardmaplimit" tunable, on by default, which only allows the vm to override |
7 | the "mapped" tunable when distress is at its greatest to prevent false |
8 | out-of-memory situations. |
9 | |
10 | Signed-off-by: Con Kolivas <kernel@kolivas.org> |
11 | |
12 | Documentation/sysctl/vm.txt | 23 +++++++++++++++++++++++ |
13 | include/linux/swap.h | 3 ++- |
14 | include/linux/sysctl.h | 3 ++- |
15 | kernel/sysctl.c | 16 ++++++++++++---- |
16 | mm/vmscan.c | 27 ++++++++++++++++----------- |
17 | 5 files changed, 55 insertions(+), 17 deletions(-) |
18 | |
19 | Index: linux-2.6.20-ck1/include/linux/swap.h |
20 | =================================================================== |
21 | --- linux-2.6.20-ck1.orig/include/linux/swap.h 2007-02-16 19:01:33.000000000 +1100 |
22 | +++ linux-2.6.20-ck1/include/linux/swap.h 2007-02-16 19:01:33.000000000 +1100 |
23 | @@ -189,7 +189,8 @@ extern void swap_setup(void); |
24 | /* linux/mm/vmscan.c */ |
25 | extern unsigned long try_to_free_pages(struct zone **, gfp_t); |
26 | extern unsigned long shrink_all_memory(unsigned long nr_pages); |
27 | -extern int vm_swappiness; |
28 | +extern int vm_mapped; |
29 | +extern int vm_hardmaplimit; |
30 | extern int remove_mapping(struct address_space *mapping, struct page *page); |
31 | extern long vm_total_pages; |
32 | |
33 | Index: linux-2.6.20-ck1/include/linux/sysctl.h |
34 | =================================================================== |
35 | --- linux-2.6.20-ck1.orig/include/linux/sysctl.h 2007-02-16 19:01:33.000000000 +1100 |
36 | +++ linux-2.6.20-ck1/include/linux/sysctl.h 2007-02-16 19:01:33.000000000 +1100 |
37 | @@ -185,7 +185,7 @@ enum |
38 | VM_OVERCOMMIT_RATIO=16, /* percent of RAM to allow overcommit in */ |
39 | VM_PAGEBUF=17, /* struct: Control pagebuf parameters */ |
40 | VM_HUGETLB_PAGES=18, /* int: Number of available Huge Pages */ |
41 | - VM_SWAPPINESS=19, /* Tendency to steal mapped memory */ |
42 | + VM_MAPPED=19, /* percent mapped min while evicting cache */ |
43 | VM_LOWMEM_RESERVE_RATIO=20,/* reservation ratio for lower memory zones */ |
44 | VM_MIN_FREE_KBYTES=21, /* Minimum free kilobytes to maintain */ |
45 | VM_MAX_MAP_COUNT=22, /* int: Maximum number of mmaps/address-space */ |
46 | @@ -203,6 +203,7 @@ enum |
47 | VM_VDSO_ENABLED=34, /* map VDSO into new processes? */ |
48 | VM_MIN_SLAB=35, /* Percent pages ignored by zone reclaim */ |
49 | VM_SWAP_PREFETCH=36, /* swap prefetch */ |
50 | + VM_HARDMAPLIMIT=37, /* Make mapped a hard limit */ |
51 | }; |
52 | |
53 | |
54 | Index: linux-2.6.20-ck1/kernel/sysctl.c |
55 | =================================================================== |
56 | --- linux-2.6.20-ck1.orig/kernel/sysctl.c 2007-02-16 19:01:33.000000000 +1100 |
57 | +++ linux-2.6.20-ck1/kernel/sysctl.c 2007-02-16 19:01:33.000000000 +1100 |
58 | @@ -900,16 +900,24 @@ static ctl_table vm_table[] = { |
59 | .proc_handler = &proc_dointvec, |
60 | }, |
61 | { |
62 | - .ctl_name = VM_SWAPPINESS, |
63 | - .procname = "swappiness", |
64 | - .data = &vm_swappiness, |
65 | - .maxlen = sizeof(vm_swappiness), |
66 | + .ctl_name = VM_MAPPED, |
67 | + .procname = "mapped", |
68 | + .data = &vm_mapped, |
69 | + .maxlen = sizeof(vm_mapped), |
70 | .mode = 0644, |
71 | .proc_handler = &proc_dointvec_minmax, |
72 | .strategy = &sysctl_intvec, |
73 | .extra1 = &zero, |
74 | .extra2 = &one_hundred, |
75 | }, |
76 | + { |
77 | + .ctl_name = VM_HARDMAPLIMIT, |
78 | + .procname = "hardmaplimit", |
79 | + .data = &vm_hardmaplimit, |
80 | + .maxlen = sizeof(int), |
81 | + .mode = 0644, |
82 | + .proc_handler = &proc_dointvec, |
83 | + }, |
84 | #ifdef CONFIG_HUGETLB_PAGE |
85 | { |
86 | .ctl_name = VM_HUGETLB_PAGES, |
87 | Index: linux-2.6.20-ck1/mm/vmscan.c |
88 | =================================================================== |
89 | --- linux-2.6.20-ck1.orig/mm/vmscan.c 2007-02-16 19:01:33.000000000 +1100 |
90 | +++ linux-2.6.20-ck1/mm/vmscan.c 2007-02-16 19:01:33.000000000 +1100 |
91 | @@ -64,7 +64,7 @@ struct scan_control { |
92 | * whole list at once. */ |
93 | int swap_cluster_max; |
94 | |
95 | - int swappiness; |
96 | + int mapped; |
97 | |
98 | int all_unreclaimable; |
99 | }; |
100 | @@ -111,9 +111,10 @@ struct shrinker { |
101 | #endif |
102 | |
103 | /* |
104 | - * From 0 .. 100. Higher means more swappy. |
105 | + * From 0 .. 100. Lower means more swappy. |
106 | */ |
107 | -int vm_swappiness = 60; |
108 | +int vm_mapped __read_mostly = 66; |
109 | +int vm_hardmaplimit __read_mostly = 1; |
110 | long vm_total_pages; /* The total number of pages which the VM controls */ |
111 | |
112 | static LIST_HEAD(shrinker_list); |
113 | @@ -808,10 +809,14 @@ static void shrink_active_list(unsigned |
114 | * The distress ratio is important - we don't want to start |
115 | * going oom. |
116 | * |
117 | - * A 100% value of vm_swappiness overrides this algorithm |
118 | - * altogether. |
119 | + * This distress value is ignored if we apply a hardmaplimit except |
120 | + * in extreme distress. |
121 | + * |
122 | + * A 0% value of vm_mapped overrides this algorithm altogether. |
123 | */ |
124 | - swap_tendency = mapped_ratio / 2 + distress + sc->swappiness; |
125 | + swap_tendency = mapped_ratio * 100 / (sc->mapped + 1); |
126 | + if (!vm_hardmaplimit || distress == 100) |
127 | + swap_tendency += distress; |
128 | |
129 | /* |
130 | * Now use this metric to decide whether to start moving mapped |
131 | @@ -1028,7 +1033,7 @@ unsigned long try_to_free_pages(struct z |
132 | .may_writepage = !laptop_mode, |
133 | .swap_cluster_max = SWAP_CLUSTER_MAX, |
134 | .may_swap = 1, |
135 | - .swappiness = vm_swappiness, |
136 | + .mapped = vm_mapped, |
137 | }; |
138 | |
139 | delay_swap_prefetch(); |
140 | @@ -1134,7 +1139,7 @@ static unsigned long balance_pgdat(pg_da |
141 | .gfp_mask = GFP_KERNEL, |
142 | .may_swap = 1, |
143 | .swap_cluster_max = SWAP_CLUSTER_MAX, |
144 | - .swappiness = vm_swappiness, |
145 | + .mapped = vm_mapped, |
146 | }; |
147 | /* |
148 | * temp_priority is used to remember the scanning priority at which |
149 | @@ -1441,7 +1446,7 @@ unsigned long shrink_all_memory(unsigned |
150 | .may_swap = 0, |
151 | .swap_cluster_max = nr_pages, |
152 | .may_writepage = 1, |
153 | - .swappiness = vm_swappiness, |
154 | + .mapped = vm_mapped, |
155 | }; |
156 | |
157 | current->reclaim_state = &reclaim_state; |
158 | @@ -1476,7 +1481,7 @@ unsigned long shrink_all_memory(unsigned |
159 | /* Force reclaiming mapped pages in the passes #3 and #4 */ |
160 | if (pass > 2) { |
161 | sc.may_swap = 1; |
162 | - sc.swappiness = 100; |
163 | + sc.mapped = 0; |
164 | } |
165 | |
166 | for (prio = DEF_PRIORITY; prio >= 0; prio--) { |
167 | @@ -1624,7 +1629,7 @@ static int __zone_reclaim(struct zone *z |
168 | .swap_cluster_max = max_t(unsigned long, nr_pages, |
169 | SWAP_CLUSTER_MAX), |
170 | .gfp_mask = gfp_mask, |
171 | - .swappiness = vm_swappiness, |
172 | + .mapped = vm_mapped, |
173 | }; |
174 | unsigned long slab_reclaimable; |
175 | |
176 | Index: linux-2.6.20-ck1/Documentation/sysctl/vm.txt |
177 | =================================================================== |
178 | --- linux-2.6.20-ck1.orig/Documentation/sysctl/vm.txt 2007-02-16 19:01:33.000000000 +1100 |
179 | +++ linux-2.6.20-ck1/Documentation/sysctl/vm.txt 2007-02-16 19:01:33.000000000 +1100 |
180 | @@ -22,6 +22,8 @@ Currently, these files are in /proc/sys/ |
181 | - dirty_background_ratio |
182 | - dirty_expire_centisecs |
183 | - dirty_writeback_centisecs |
184 | +- hardmaplimit |
185 | +- mapped |
186 | - max_map_count |
187 | - min_free_kbytes |
188 | - laptop_mode |
189 | @@ -87,6 +89,27 @@ for swap because we only cluster swap da |
190 | |
191 | ============================================================== |
192 | |
193 | +hardmaplimit: |
194 | + |
195 | +This flag makes the vm adhere to the mapped value as closely as possible |
196 | +except in the most extreme vm stress where doing so would provoke an out |
197 | +of memory condition (see mapped below). |
198 | + |
199 | +Enabled by default. |
200 | + |
201 | +============================================================== |
202 | + |
203 | +mapped: |
204 | + |
205 | +This is the percentage ram that is filled with mapped pages (applications) |
206 | +before the vm will start reclaiming mapped pages by moving them to swap. |
207 | +It is altered by the relative stress of the vm at the time so is not |
208 | +strictly adhered to to prevent provoking out of memory kills. |
209 | + |
210 | +Set to 66 by default. |
211 | + |
212 | +============================================================== |
213 | + |
214 | max_map_count: |
215 | |
216 | This file contains the maximum number of memory map areas a process |