diff options
| -rw-r--r-- | Documentation/vm/ksm.txt | 13 | ||||
| -rw-r--r-- | mm/Kconfig | 4 | ||||
| -rw-r--r-- | mm/ksm.c | 10 |
3 files changed, 14 insertions, 13 deletions
diff --git a/Documentation/vm/ksm.txt b/Documentation/vm/ksm.txt index 72a22f65960e..262d8e6793a3 100644 --- a/Documentation/vm/ksm.txt +++ b/Documentation/vm/ksm.txt | |||
| @@ -52,15 +52,15 @@ The KSM daemon is controlled by sysfs files in /sys/kernel/mm/ksm/, | |||
| 52 | readable by all but writable only by root: | 52 | readable by all but writable only by root: |
| 53 | 53 | ||
| 54 | max_kernel_pages - set to maximum number of kernel pages that KSM may use | 54 | max_kernel_pages - set to maximum number of kernel pages that KSM may use |
| 55 | e.g. "echo 2000 > /sys/kernel/mm/ksm/max_kernel_pages" | 55 | e.g. "echo 100000 > /sys/kernel/mm/ksm/max_kernel_pages" |
| 56 | Value 0 imposes no limit on the kernel pages KSM may use; | 56 | Value 0 imposes no limit on the kernel pages KSM may use; |
| 57 | but note that any process using MADV_MERGEABLE can cause | 57 | but note that any process using MADV_MERGEABLE can cause |
| 58 | KSM to allocate these pages, unswappable until it exits. | 58 | KSM to allocate these pages, unswappable until it exits. |
| 59 | Default: 2000 (chosen for demonstration purposes) | 59 | Default: quarter of memory (chosen to not pin too much) |
| 60 | 60 | ||
| 61 | pages_to_scan - how many present pages to scan before ksmd goes to sleep | 61 | pages_to_scan - how many present pages to scan before ksmd goes to sleep |
| 62 | e.g. "echo 200 > /sys/kernel/mm/ksm/pages_to_scan" | 62 | e.g. "echo 100 > /sys/kernel/mm/ksm/pages_to_scan" |
| 63 | Default: 200 (chosen for demonstration purposes) | 63 | Default: 100 (chosen for demonstration purposes) |
| 64 | 64 | ||
| 65 | sleep_millisecs - how many milliseconds ksmd should sleep before next scan | 65 | sleep_millisecs - how many milliseconds ksmd should sleep before next scan |
| 66 | e.g. "echo 20 > /sys/kernel/mm/ksm/sleep_millisecs" | 66 | e.g. "echo 20 > /sys/kernel/mm/ksm/sleep_millisecs" |
| @@ -70,7 +70,8 @@ run - set 0 to stop ksmd from running but keep merged pages, | |||
| 70 | set 1 to run ksmd e.g. "echo 1 > /sys/kernel/mm/ksm/run", | 70 | set 1 to run ksmd e.g. "echo 1 > /sys/kernel/mm/ksm/run", |
| 71 | set 2 to stop ksmd and unmerge all pages currently merged, | 71 | set 2 to stop ksmd and unmerge all pages currently merged, |
| 72 | but leave mergeable areas registered for next run | 72 | but leave mergeable areas registered for next run |
| 73 | Default: 1 (for immediate use by apps which register) | 73 | Default: 0 (must be changed to 1 to activate KSM, |
| 74 | except if CONFIG_SYSFS is disabled) | ||
| 74 | 75 | ||
| 75 | The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/: | 76 | The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/: |
| 76 | 77 | ||
| @@ -86,4 +87,4 @@ pages_volatile embraces several different kinds of activity, but a high | |||
| 86 | proportion there would also indicate poor use of madvise MADV_MERGEABLE. | 87 | proportion there would also indicate poor use of madvise MADV_MERGEABLE. |
| 87 | 88 | ||
| 88 | Izik Eidus, | 89 | Izik Eidus, |
| 89 | Hugh Dickins, 30 July 2009 | 90 | Hugh Dickins, 24 Sept 2009 |
diff --git a/mm/Kconfig b/mm/Kconfig index edd300aca173..57963c6063d1 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
| @@ -224,7 +224,9 @@ config KSM | |||
| 224 | the many instances by a single resident page with that content, so | 224 | the many instances by a single resident page with that content, so |
| 225 | saving memory until one or another app needs to modify the content. | 225 | saving memory until one or another app needs to modify the content. |
| 226 | Recommended for use with KVM, or with other duplicative applications. | 226 | Recommended for use with KVM, or with other duplicative applications. |
| 227 | See Documentation/vm/ksm.txt for more information. | 227 | See Documentation/vm/ksm.txt for more information: KSM is inactive |
| 228 | until a program has madvised that an area is MADV_MERGEABLE, and | ||
| 229 | root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set). | ||
| 228 | 230 | ||
| 229 | config DEFAULT_MMAP_MIN_ADDR | 231 | config DEFAULT_MMAP_MIN_ADDR |
| 230 | int "Low address space to protect from user allocation" | 232 | int "Low address space to protect from user allocation" |
| @@ -184,11 +184,6 @@ static DEFINE_SPINLOCK(ksm_mmlist_lock); | |||
| 184 | sizeof(struct __struct), __alignof__(struct __struct),\ | 184 | sizeof(struct __struct), __alignof__(struct __struct),\ |
| 185 | (__flags), NULL) | 185 | (__flags), NULL) |
| 186 | 186 | ||
| 187 | static void __init ksm_init_max_kernel_pages(void) | ||
| 188 | { | ||
| 189 | ksm_max_kernel_pages = nr_free_buffer_pages() / 4; | ||
| 190 | } | ||
| 191 | |||
| 192 | static int __init ksm_slab_init(void) | 187 | static int __init ksm_slab_init(void) |
| 193 | { | 188 | { |
| 194 | rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0); | 189 | rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0); |
| @@ -1673,7 +1668,7 @@ static int __init ksm_init(void) | |||
| 1673 | struct task_struct *ksm_thread; | 1668 | struct task_struct *ksm_thread; |
| 1674 | int err; | 1669 | int err; |
| 1675 | 1670 | ||
| 1676 | ksm_init_max_kernel_pages(); | 1671 | ksm_max_kernel_pages = totalram_pages / 4; |
| 1677 | 1672 | ||
| 1678 | err = ksm_slab_init(); | 1673 | err = ksm_slab_init(); |
| 1679 | if (err) | 1674 | if (err) |
| @@ -1697,6 +1692,9 @@ static int __init ksm_init(void) | |||
| 1697 | kthread_stop(ksm_thread); | 1692 | kthread_stop(ksm_thread); |
| 1698 | goto out_free2; | 1693 | goto out_free2; |
| 1699 | } | 1694 | } |
| 1695 | #else | ||
| 1696 | ksm_run = KSM_RUN_MERGE; /* no way for user to start it */ | ||
| 1697 | |||
| 1700 | #endif /* CONFIG_SYSFS */ | 1698 | #endif /* CONFIG_SYSFS */ |
| 1701 | 1699 | ||
| 1702 | return 0; | 1700 | return 0; |
