]> git.pld-linux.org Git - packages/kernel.git/blame - 350-autoswap
- ported from linux-2.4.25-atmdd.patch
[packages/kernel.git] / 350-autoswap
CommitLineData
b2bde125 1diff -upN reference/kernel/sysctl.c current/kernel/sysctl.c
2--- reference/kernel/sysctl.c 2004-04-30 11:23:56.000000000 -0700
3+++ current/kernel/sysctl.c 2004-05-02 08:41:25.000000000 -0700
4@@ -721,11 +721,8 @@ static ctl_table vm_table[] = {
5 .procname = "swappiness",
6 .data = &vm_swappiness,
7 .maxlen = sizeof(vm_swappiness),
8- .mode = 0644,
9- .proc_handler = &proc_dointvec_minmax,
10- .strategy = &sysctl_intvec,
11- .extra1 = &zero,
12- .extra2 = &one_hundred,
13+ .mode = 0444 /* read-only*/,
14+ .proc_handler = &proc_dointvec,
15 },
16 #ifdef CONFIG_HUGETLB_PAGE
17 {
18diff -upN reference/mm/vmscan.c current/mm/vmscan.c
19--- reference/mm/vmscan.c 2004-04-30 11:23:57.000000000 -0700
20+++ current/mm/vmscan.c 2004-05-02 08:41:25.000000000 -0700
21@@ -42,7 +42,7 @@
22 /*
23 * From 0 .. 100. Higher means more swappy.
24 */
25-int vm_swappiness = 60;
26+int vm_swappiness = 0;
27 static long total_memory;
28
29 #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
30@@ -586,6 +586,7 @@ refill_inactive_zone(struct zone *zone,
31 LIST_HEAD(l_active); /* Pages to go onto the active_list */
32 struct page *page;
33 struct pagevec pvec;
34+ struct sysinfo i;
35 int reclaim_mapped = 0;
36 long mapped_ratio;
37 long distress;
38@@ -627,14 +628,39 @@ refill_inactive_zone(struct zone *zone,
39 */
40 mapped_ratio = (ps->nr_mapped * 100) / total_memory;
41
42+ si_swapinfo(&i);
43+ if (likely(i.totalswap)) {
44+ int app_centile, swap_centile;
45+
46+ /*
47+ * app_centile is the percentage of physical ram used
48+ * by application pages.
49+ */
50+ si_meminfo(&i);
51+ app_centile = 100 - ((i.freeram + get_page_cache_size() -
52+ total_swapcache_pages) / (i.totalram / 100));
53+
54+ /*
55+ * swap_centile is the percentage of the last (sizeof physical
56+ * ram) of swap free.
57+ */
58+ swap_centile = i.freeswap /
59+ (min(i.totalswap, i.totalram) / 100);
60+
61+ /*
62+ * Autoregulate vm_swappiness to be equal to the lowest of
63+ * app_centile and swap_centile. -ck
64+ */
65+ vm_swappiness = min(app_centile, swap_centile);
66+ } else
67+ vm_swappiness = 0;
68+
69 /*
70 * Now decide how much we really want to unmap some pages. The mapped
71 * ratio is downgraded - just because there's a lot of mapped memory
72 * doesn't necessarily mean that page reclaim isn't succeeding.
73 *
74 * The distress ratio is important - we don't want to start going oom.
75- *
76- * A 100% value of vm_swappiness overrides this algorithm altogether.
77 */
78 swap_tendency = mapped_ratio / 2 + distress + vm_swappiness;
79
This page took 0.063762 seconds and 4 git commands to generate.