diff options
-rw-r--r-- | mm/ksm.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/rbtree.h> | 31 | #include <linux/rbtree.h> |
32 | #include <linux/mmu_notifier.h> | 32 | #include <linux/mmu_notifier.h> |
33 | #include <linux/swap.h> | ||
33 | #include <linux/ksm.h> | 34 | #include <linux/ksm.h> |
34 | 35 | ||
35 | #include <asm/tlbflush.h> | 36 | #include <asm/tlbflush.h> |
@@ -162,10 +163,10 @@ static unsigned long ksm_pages_unshared; | |||
162 | static unsigned long ksm_rmap_items; | 163 | static unsigned long ksm_rmap_items; |
163 | 164 | ||
164 | /* Limit on the number of unswappable pages used */ | 165 | /* Limit on the number of unswappable pages used */ |
165 | static unsigned long ksm_max_kernel_pages = 2000; | 166 | static unsigned long ksm_max_kernel_pages; |
166 | 167 | ||
167 | /* Number of pages ksmd should scan in one batch */ | 168 | /* Number of pages ksmd should scan in one batch */ |
168 | static unsigned int ksm_thread_pages_to_scan = 200; | 169 | static unsigned int ksm_thread_pages_to_scan = 100; |
169 | 170 | ||
170 | /* Milliseconds ksmd should sleep between batches */ | 171 | /* Milliseconds ksmd should sleep between batches */ |
171 | static unsigned int ksm_thread_sleep_millisecs = 20; | 172 | static unsigned int ksm_thread_sleep_millisecs = 20; |
@@ -173,7 +174,7 @@ static unsigned int ksm_thread_sleep_millisecs = 20; | |||
173 | #define KSM_RUN_STOP 0 | 174 | #define KSM_RUN_STOP 0 |
174 | #define KSM_RUN_MERGE 1 | 175 | #define KSM_RUN_MERGE 1 |
175 | #define KSM_RUN_UNMERGE 2 | 176 | #define KSM_RUN_UNMERGE 2 |
176 | static unsigned int ksm_run = KSM_RUN_MERGE; | 177 | static unsigned int ksm_run = KSM_RUN_STOP; |
177 | 178 | ||
178 | static DECLARE_WAIT_QUEUE_HEAD(ksm_thread_wait); | 179 | static DECLARE_WAIT_QUEUE_HEAD(ksm_thread_wait); |
179 | static DEFINE_MUTEX(ksm_thread_mutex); | 180 | static DEFINE_MUTEX(ksm_thread_mutex); |
@@ -183,6 +184,11 @@ static DEFINE_SPINLOCK(ksm_mmlist_lock); | |||
183 | sizeof(struct __struct), __alignof__(struct __struct),\ | 184 | sizeof(struct __struct), __alignof__(struct __struct),\ |
184 | (__flags), NULL) | 185 | (__flags), NULL) |
185 | 186 | ||
187 | static void __init ksm_init_max_kernel_pages(void) | ||
188 | { | ||
189 | ksm_max_kernel_pages = nr_free_buffer_pages() / 4; | ||
190 | } | ||
191 | |||
186 | static int __init ksm_slab_init(void) | 192 | static int __init ksm_slab_init(void) |
187 | { | 193 | { |
188 | rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0); | 194 | rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0); |
@@ -1667,6 +1673,8 @@ static int __init ksm_init(void) | |||
1667 | struct task_struct *ksm_thread; | 1673 | struct task_struct *ksm_thread; |
1668 | int err; | 1674 | int err; |
1669 | 1675 | ||
1676 | ksm_init_max_kernel_pages(); | ||
1677 | |||
1670 | err = ksm_slab_init(); | 1678 | err = ksm_slab_init(); |
1671 | if (err) | 1679 | if (err) |
1672 | goto out; | 1680 | goto out; |