Annotation of /trunk/kernel26-alx/patches-2.6.21-r14/0012-2.6.21-mm-convert_swappiness_to_mapped.patch
Parent Directory | Revision Log
Revision 447 -
(hide annotations)
(download)
Tue Jan 22 17:55:52 2008 UTC (16 years, 8 months ago) by niro
File size: 7538 byte(s)
Tue Jan 22 17:55:52 2008 UTC (16 years, 8 months ago) by niro
File size: 7538 byte(s)
-2.6.21-alx-r14 - fixed some natsemi errors on wys terminals
1 | niro | 447 | 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 | 2 +- | ||
15 | kernel/sysctl.c | 16 ++++++++++++---- | ||
16 | mm/vmscan.c | 27 ++++++++++++++++----------- | ||
17 | 5 files changed, 54 insertions(+), 17 deletions(-) | ||
18 | |||
19 | Index: linux-2.6.21-ck2/include/linux/swap.h | ||
20 | =================================================================== | ||
21 | --- linux-2.6.21-ck2.orig/include/linux/swap.h 2007-05-14 19:49:55.000000000 +1000 | ||
22 | +++ linux-2.6.21-ck2/include/linux/swap.h 2007-05-14 19:49:55.000000000 +1000 | ||
23 | @@ -191,7 +191,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.21-ck2/include/linux/sysctl.h | ||
34 | =================================================================== | ||
35 | --- linux-2.6.21-ck2.orig/include/linux/sysctl.h 2007-05-14 19:49:19.000000000 +1000 | ||
36 | +++ linux-2.6.21-ck2/include/linux/sysctl.h 2007-05-14 19:49:55.000000000 +1000 | ||
37 | @@ -190,7 +190,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 | Index: linux-2.6.21-ck2/kernel/sysctl.c | ||
47 | =================================================================== | ||
48 | --- linux-2.6.21-ck2.orig/kernel/sysctl.c 2007-05-14 19:49:55.000000000 +1000 | ||
49 | +++ linux-2.6.21-ck2/kernel/sysctl.c 2007-05-14 19:49:55.000000000 +1000 | ||
50 | @@ -741,16 +741,24 @@ static ctl_table vm_table[] = { | ||
51 | .proc_handler = &proc_dointvec, | ||
52 | }, | ||
53 | { | ||
54 | - .ctl_name = VM_SWAPPINESS, | ||
55 | - .procname = "swappiness", | ||
56 | - .data = &vm_swappiness, | ||
57 | - .maxlen = sizeof(vm_swappiness), | ||
58 | + .ctl_name = CTL_UNNUMBERED, | ||
59 | + .procname = "mapped", | ||
60 | + .data = &vm_mapped, | ||
61 | + .maxlen = sizeof(vm_mapped), | ||
62 | .mode = 0644, | ||
63 | .proc_handler = &proc_dointvec_minmax, | ||
64 | .strategy = &sysctl_intvec, | ||
65 | .extra1 = &zero, | ||
66 | .extra2 = &one_hundred, | ||
67 | }, | ||
68 | + { | ||
69 | + .ctl_name = CTL_UNNUMBERED, | ||
70 | + .procname = "hardmaplimit", | ||
71 | + .data = &vm_hardmaplimit, | ||
72 | + .maxlen = sizeof(int), | ||
73 | + .mode = 0644, | ||
74 | + .proc_handler = &proc_dointvec, | ||
75 | + }, | ||
76 | #ifdef CONFIG_HUGETLB_PAGE | ||
77 | { | ||
78 | .ctl_name = VM_HUGETLB_PAGES, | ||
79 | Index: linux-2.6.21-ck2/mm/vmscan.c | ||
80 | =================================================================== | ||
81 | --- linux-2.6.21-ck2.orig/mm/vmscan.c 2007-05-14 19:49:55.000000000 +1000 | ||
82 | +++ linux-2.6.21-ck2/mm/vmscan.c 2007-05-14 19:49:55.000000000 +1000 | ||
83 | @@ -64,7 +64,7 @@ struct scan_control { | ||
84 | * whole list at once. */ | ||
85 | int swap_cluster_max; | ||
86 | |||
87 | - int swappiness; | ||
88 | + int mapped; | ||
89 | |||
90 | int all_unreclaimable; | ||
91 | }; | ||
92 | @@ -111,9 +111,10 @@ struct shrinker { | ||
93 | #endif | ||
94 | |||
95 | /* | ||
96 | - * From 0 .. 100. Higher means more swappy. | ||
97 | + * From 0 .. 100. Lower means more swappy. | ||
98 | */ | ||
99 | -int vm_swappiness = 60; | ||
100 | +int vm_mapped __read_mostly = 66; | ||
101 | +int vm_hardmaplimit __read_mostly = 1; | ||
102 | long vm_total_pages; /* The total number of pages which the VM controls */ | ||
103 | |||
104 | static LIST_HEAD(shrinker_list); | ||
105 | @@ -809,10 +810,14 @@ static void shrink_active_list(unsigned | ||
106 | * The distress ratio is important - we don't want to start | ||
107 | * going oom. | ||
108 | * | ||
109 | - * A 100% value of vm_swappiness overrides this algorithm | ||
110 | - * altogether. | ||
111 | + * This distress value is ignored if we apply a hardmaplimit except | ||
112 | + * in extreme distress. | ||
113 | + * | ||
114 | + * A 0% value of vm_mapped overrides this algorithm altogether. | ||
115 | */ | ||
116 | - swap_tendency = mapped_ratio / 2 + distress + sc->swappiness; | ||
117 | + swap_tendency = mapped_ratio * 100 / (sc->mapped + 1); | ||
118 | + if (!vm_hardmaplimit || distress == 100) | ||
119 | + swap_tendency += distress; | ||
120 | |||
121 | /* | ||
122 | * Now use this metric to decide whether to start moving mapped | ||
123 | @@ -1031,7 +1036,7 @@ unsigned long try_to_free_pages(struct z | ||
124 | .may_writepage = !laptop_mode, | ||
125 | .swap_cluster_max = SWAP_CLUSTER_MAX, | ||
126 | .may_swap = 1, | ||
127 | - .swappiness = vm_swappiness, | ||
128 | + .mapped = vm_mapped, | ||
129 | }; | ||
130 | |||
131 | delay_swap_prefetch(); | ||
132 | @@ -1138,7 +1143,7 @@ static unsigned long balance_pgdat(pg_da | ||
133 | .gfp_mask = GFP_KERNEL, | ||
134 | .may_swap = 1, | ||
135 | .swap_cluster_max = SWAP_CLUSTER_MAX, | ||
136 | - .swappiness = vm_swappiness, | ||
137 | + .mapped = vm_mapped, | ||
138 | }; | ||
139 | /* | ||
140 | * temp_priority is used to remember the scanning priority at which | ||
141 | @@ -1446,7 +1451,7 @@ unsigned long shrink_all_memory(unsigned | ||
142 | .may_swap = 0, | ||
143 | .swap_cluster_max = nr_pages, | ||
144 | .may_writepage = 1, | ||
145 | - .swappiness = vm_swappiness, | ||
146 | + .mapped = vm_mapped, | ||
147 | }; | ||
148 | |||
149 | current->reclaim_state = &reclaim_state; | ||
150 | @@ -1481,7 +1486,7 @@ unsigned long shrink_all_memory(unsigned | ||
151 | /* Force reclaiming mapped pages in the passes #3 and #4 */ | ||
152 | if (pass > 2) { | ||
153 | sc.may_swap = 1; | ||
154 | - sc.swappiness = 100; | ||
155 | + sc.mapped = 0; | ||
156 | } | ||
157 | |||
158 | for (prio = DEF_PRIORITY; prio >= 0; prio--) { | ||
159 | @@ -1629,7 +1634,7 @@ static int __zone_reclaim(struct zone *z | ||
160 | .swap_cluster_max = max_t(unsigned long, nr_pages, | ||
161 | SWAP_CLUSTER_MAX), | ||
162 | .gfp_mask = gfp_mask, | ||
163 | - .swappiness = vm_swappiness, | ||
164 | + .mapped = vm_mapped, | ||
165 | }; | ||
166 | unsigned long slab_reclaimable; | ||
167 | |||
168 | Index: linux-2.6.21-ck2/Documentation/sysctl/vm.txt | ||
169 | =================================================================== | ||
170 | --- linux-2.6.21-ck2.orig/Documentation/sysctl/vm.txt 2007-05-14 19:49:55.000000000 +1000 | ||
171 | +++ linux-2.6.21-ck2/Documentation/sysctl/vm.txt 2007-05-14 19:49:55.000000000 +1000 | ||
172 | @@ -22,6 +22,8 @@ Currently, these files are in /proc/sys/ | ||
173 | - dirty_background_ratio | ||
174 | - dirty_expire_centisecs | ||
175 | - dirty_writeback_centisecs | ||
176 | +- hardmaplimit | ||
177 | +- mapped | ||
178 | - max_map_count | ||
179 | - min_free_kbytes | ||
180 | - laptop_mode | ||
181 | @@ -87,6 +89,27 @@ for swap because we only cluster swap da | ||
182 | |||
183 | ============================================================== | ||
184 | |||
185 | +hardmaplimit: | ||
186 | + | ||
187 | +This flag makes the vm adhere to the mapped value as closely as possible | ||
188 | +except in the most extreme vm stress where doing so would provoke an out | ||
189 | +of memory condition (see mapped below). | ||
190 | + | ||
191 | +Enabled by default. | ||
192 | + | ||
193 | +============================================================== | ||
194 | + | ||
195 | +mapped: | ||
196 | + | ||
197 | +This is the percentage ram that is filled with mapped pages (applications) | ||
198 | +before the vm will start reclaiming mapped pages by moving them to swap. | ||
199 | +It is altered by the relative stress of the vm at the time so is not | ||
200 | +strictly adhered to to prevent provoking out of memory kills. | ||
201 | + | ||
202 | +Set to 66 by default. | ||
203 | + | ||
204 | +============================================================== | ||
205 | + | ||
206 | max_map_count: | ||
207 | |||
208 | This file contains the maximum number of memory map areas a process |