Magellan Linux

Contents of /trunk/kernel26-magellan/patches-2.6.16-r12/0020-2.6.16-vm-mapped-1.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (show annotations) (download)
Mon Jun 5 09:25:38 2006 UTC (17 years, 10 months ago) by niro
File size: 4800 byte(s)
ver bump to 2.6.16-r12:
- updated to linux-2.6.16.19
- updated to ck11

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 include/linux/swap.h | 3 ++-
13 include/linux/sysctl.h | 3 ++-
14 kernel/sysctl.c | 16 ++++++++++++----
15 mm/vmscan.c | 17 +++++++++++------
16 4 files changed, 27 insertions(+), 12 deletions(-)
17
18 Index: linux-2.6.16-ck1/include/linux/swap.h
19 ===================================================================
20 --- linux-2.6.16-ck1.orig/include/linux/swap.h 2006-03-20 20:46:55.000000000 +1100
21 +++ linux-2.6.16-ck1/include/linux/swap.h 2006-03-20 20:46:56.000000000 +1100
22 @@ -175,7 +175,8 @@ extern void swap_setup(void);
23 /* linux/mm/vmscan.c */
24 extern int try_to_free_pages(struct zone **, gfp_t);
25 extern int shrink_all_memory(int);
26 -extern int vm_swappiness;
27 +extern int vm_mapped;
28 +extern int vm_hardmaplimit;
29
30 #ifdef CONFIG_NUMA
31 extern int zone_reclaim_mode;
32 Index: linux-2.6.16-ck1/include/linux/sysctl.h
33 ===================================================================
34 --- linux-2.6.16-ck1.orig/include/linux/sysctl.h 2006-03-20 20:46:55.000000000 +1100
35 +++ linux-2.6.16-ck1/include/linux/sysctl.h 2006-03-20 20:46:56.000000000 +1100
36 @@ -175,7 +175,7 @@ enum
37 VM_OVERCOMMIT_RATIO=16, /* percent of RAM to allow overcommit in */
38 VM_PAGEBUF=17, /* struct: Control pagebuf parameters */
39 VM_HUGETLB_PAGES=18, /* int: Number of available Huge Pages */
40 - VM_SWAPPINESS=19, /* Tendency to steal mapped memory */
41 + VM_MAPPED=19, /* percent mapped min while evicting cache */
42 VM_LOWMEM_RESERVE_RATIO=20,/* reservation ratio for lower memory zones */
43 VM_MIN_FREE_KBYTES=21, /* Minimum free kilobytes to maintain */
44 VM_MAX_MAP_COUNT=22, /* int: Maximum number of mmaps/address-space */
45 @@ -190,6 +190,7 @@ enum
46 VM_ZONE_RECLAIM_MODE=31, /* reclaim local zone memory before going off node */
47 VM_ZONE_RECLAIM_INTERVAL=32, /* time period to wait after reclaim failure */
48 VM_SWAP_PREFETCH=33, /* swap prefetch */
49 + VM_HARDMAPLIMIT=34, /* Make mapped a hard limit */
50 };
51
52
53 Index: linux-2.6.16-ck1/kernel/sysctl.c
54 ===================================================================
55 --- linux-2.6.16-ck1.orig/kernel/sysctl.c 2006-03-20 20:46:55.000000000 +1100
56 +++ linux-2.6.16-ck1/kernel/sysctl.c 2006-03-20 20:46:56.000000000 +1100
57 @@ -791,16 +791,24 @@ static ctl_table vm_table[] = {
58 .proc_handler = &proc_dointvec,
59 },
60 {
61 - .ctl_name = VM_SWAPPINESS,
62 - .procname = "swappiness",
63 - .data = &vm_swappiness,
64 - .maxlen = sizeof(vm_swappiness),
65 + .ctl_name = VM_MAPPED,
66 + .procname = "mapped",
67 + .data = &vm_mapped,
68 + .maxlen = sizeof(vm_mapped),
69 .mode = 0644,
70 .proc_handler = &proc_dointvec_minmax,
71 .strategy = &sysctl_intvec,
72 .extra1 = &zero,
73 .extra2 = &one_hundred,
74 },
75 + {
76 + .ctl_name = VM_HARDMAPLIMIT,
77 + .procname = "hardmaplimit",
78 + .data = &vm_hardmaplimit,
79 + .maxlen = sizeof(int),
80 + .mode = 0644,
81 + .proc_handler = &proc_dointvec,
82 + },
83 #ifdef CONFIG_HUGETLB_PAGE
84 {
85 .ctl_name = VM_HUGETLB_PAGES,
86 Index: linux-2.6.16-ck1/mm/vmscan.c
87 ===================================================================
88 --- linux-2.6.16-ck1.orig/mm/vmscan.c 2006-03-20 20:46:55.000000000 +1100
89 +++ linux-2.6.16-ck1/mm/vmscan.c 2006-03-20 20:46:56.000000000 +1100
90 @@ -124,10 +124,11 @@ struct shrinker {
91 #endif
92
93 /*
94 - * From 0 .. 100. Higher means more swappy.
95 + * From 0 .. 100. Lower means more swappy.
96 */
97 -int vm_swappiness = 60;
98 -static long total_memory;
99 +int vm_mapped __read_mostly = 66;
100 +int vm_hardmaplimit __read_mostly = 1;
101 +static long total_memory __read_mostly;
102
103 static LIST_HEAD(shrinker_list);
104 static DECLARE_RWSEM(shrinker_rwsem);
105 @@ -1232,10 +1233,14 @@ refill_inactive_zone(struct zone *zone,
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 + vm_swappiness;
117 + swap_tendency = mapped_ratio * 100 / (vm_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