diff options
author | Hugh Dickins <hugh.dickins@tiscali.co.uk> | 2009-09-21 20:02:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:32 -0400 |
commit | 2ffd8679c8e4ec226718bff58b50b226dd477015 (patch) | |
tree | 5e58b19da86defa012613a850c6f57dd69ab51f3 /mm/ksm.c | |
parent | 1c2fb7a4c2ca7a958b02bc1e615d0254990bba8d (diff) |
ksm: sysfs and defaults
At present KSM is just a waste of space if you don't have CONFIG_SYSFS=y
to provide the /sys/kernel/mm/ksm files to tune and activate it.
Make KSM depend on SYSFS? Could do, but it might be better to provide
some defaults so that KSM works out-of-the-box, ready for testers to
madvise MADV_MERGEABLE, even without SYSFS.
Though anyone serious is likely to want to retune the numbers to their
taste once they have experience; and whether these settings ever reach
2.6.32 can be discussed along the way.
Save 1kB from tiny kernels by #ifdef'ing the SYSFS side of it.
Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Acked-by: Izik Eidus <ieidus@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/ksm.c')
-rw-r--r-- | mm/ksm.c | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -163,18 +163,18 @@ static unsigned long ksm_pages_unshared; | |||
163 | static unsigned long ksm_rmap_items; | 163 | static unsigned long ksm_rmap_items; |
164 | 164 | ||
165 | /* Limit on the number of unswappable pages used */ | 165 | /* Limit on the number of unswappable pages used */ |
166 | static unsigned long ksm_max_kernel_pages; | 166 | static unsigned long ksm_max_kernel_pages = 2000; |
167 | 167 | ||
168 | /* Number of pages ksmd should scan in one batch */ | 168 | /* Number of pages ksmd should scan in one batch */ |
169 | static unsigned int ksm_thread_pages_to_scan; | 169 | static unsigned int ksm_thread_pages_to_scan = 200; |
170 | 170 | ||
171 | /* Milliseconds ksmd should sleep between batches */ | 171 | /* Milliseconds ksmd should sleep between batches */ |
172 | static unsigned int ksm_thread_sleep_millisecs; | 172 | static unsigned int ksm_thread_sleep_millisecs = 20; |
173 | 173 | ||
174 | #define KSM_RUN_STOP 0 | 174 | #define KSM_RUN_STOP 0 |
175 | #define KSM_RUN_MERGE 1 | 175 | #define KSM_RUN_MERGE 1 |
176 | #define KSM_RUN_UNMERGE 2 | 176 | #define KSM_RUN_UNMERGE 2 |
177 | static unsigned int ksm_run; | 177 | static unsigned int ksm_run = KSM_RUN_MERGE; |
178 | 178 | ||
179 | static DECLARE_WAIT_QUEUE_HEAD(ksm_thread_wait); | 179 | static DECLARE_WAIT_QUEUE_HEAD(ksm_thread_wait); |
180 | static DEFINE_MUTEX(ksm_thread_mutex); | 180 | static DEFINE_MUTEX(ksm_thread_mutex); |
@@ -506,6 +506,10 @@ static int unmerge_ksm_pages(struct vm_area_struct *vma, | |||
506 | return err; | 506 | return err; |
507 | } | 507 | } |
508 | 508 | ||
509 | #ifdef CONFIG_SYSFS | ||
510 | /* | ||
511 | * Only called through the sysfs control interface: | ||
512 | */ | ||
509 | static int unmerge_and_remove_all_rmap_items(void) | 513 | static int unmerge_and_remove_all_rmap_items(void) |
510 | { | 514 | { |
511 | struct mm_slot *mm_slot; | 515 | struct mm_slot *mm_slot; |
@@ -563,6 +567,7 @@ error: | |||
563 | spin_unlock(&ksm_mmlist_lock); | 567 | spin_unlock(&ksm_mmlist_lock); |
564 | return err; | 568 | return err; |
565 | } | 569 | } |
570 | #endif /* CONFIG_SYSFS */ | ||
566 | 571 | ||
567 | static u32 calc_checksum(struct page *page) | 572 | static u32 calc_checksum(struct page *page) |
568 | { | 573 | { |
@@ -1454,6 +1459,11 @@ void __ksm_exit(struct mm_struct *mm) | |||
1454 | } | 1459 | } |
1455 | } | 1460 | } |
1456 | 1461 | ||
1462 | #ifdef CONFIG_SYSFS | ||
1463 | /* | ||
1464 | * This all compiles without CONFIG_SYSFS, but is a waste of space. | ||
1465 | */ | ||
1466 | |||
1457 | #define KSM_ATTR_RO(_name) \ | 1467 | #define KSM_ATTR_RO(_name) \ |
1458 | static struct kobj_attribute _name##_attr = __ATTR_RO(_name) | 1468 | static struct kobj_attribute _name##_attr = __ATTR_RO(_name) |
1459 | #define KSM_ATTR(_name) \ | 1469 | #define KSM_ATTR(_name) \ |
@@ -1636,6 +1646,7 @@ static struct attribute_group ksm_attr_group = { | |||
1636 | .attrs = ksm_attrs, | 1646 | .attrs = ksm_attrs, |
1637 | .name = "ksm", | 1647 | .name = "ksm", |
1638 | }; | 1648 | }; |
1649 | #endif /* CONFIG_SYSFS */ | ||
1639 | 1650 | ||
1640 | static int __init ksm_init(void) | 1651 | static int __init ksm_init(void) |
1641 | { | 1652 | { |
@@ -1657,16 +1668,17 @@ static int __init ksm_init(void) | |||
1657 | goto out_free2; | 1668 | goto out_free2; |
1658 | } | 1669 | } |
1659 | 1670 | ||
1671 | #ifdef CONFIG_SYSFS | ||
1660 | err = sysfs_create_group(mm_kobj, &ksm_attr_group); | 1672 | err = sysfs_create_group(mm_kobj, &ksm_attr_group); |
1661 | if (err) { | 1673 | if (err) { |
1662 | printk(KERN_ERR "ksm: register sysfs failed\n"); | 1674 | printk(KERN_ERR "ksm: register sysfs failed\n"); |
1663 | goto out_free3; | 1675 | kthread_stop(ksm_thread); |
1676 | goto out_free2; | ||
1664 | } | 1677 | } |
1678 | #endif /* CONFIG_SYSFS */ | ||
1665 | 1679 | ||
1666 | return 0; | 1680 | return 0; |
1667 | 1681 | ||
1668 | out_free3: | ||
1669 | kthread_stop(ksm_thread); | ||
1670 | out_free2: | 1682 | out_free2: |
1671 | mm_slots_hash_free(); | 1683 | mm_slots_hash_free(); |
1672 | out_free1: | 1684 | out_free1: |