mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 11:16:11 +00:00
ksm: remove unswappable max_kernel_pages
Now that ksm pages are swappable, and the known holes plugged, remove mention of unswappable kernel pages from KSM documentation and comments. Remove the totalram_pages/4 initialization of max_kernel_pages. In fact, remove max_kernel_pages altogether - we can reinstate it if removal turns out to break someone's script; but if we later want to limit KSM's memory usage, limiting the stable nodes would not be an effective approach. Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Cc: Izik Eidus <ieidus@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Chris Wright <chrisw@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
62b61f611e
commit
d0f209f68f
3 changed files with 10 additions and 55 deletions
|
@ -16,9 +16,9 @@ by sharing the data common between them. But it can be useful to any
|
||||||
application which generates many instances of the same data.
|
application which generates many instances of the same data.
|
||||||
|
|
||||||
KSM only merges anonymous (private) pages, never pagecache (file) pages.
|
KSM only merges anonymous (private) pages, never pagecache (file) pages.
|
||||||
KSM's merged pages are at present locked into kernel memory for as long
|
KSM's merged pages were originally locked into kernel memory, but can now
|
||||||
as they are shared: so cannot be swapped out like the user pages they
|
be swapped out just like other user pages (but sharing is broken when they
|
||||||
replace (but swapping KSM pages should follow soon in a later release).
|
are swapped back in: ksmd must rediscover their identity and merge again).
|
||||||
|
|
||||||
KSM only operates on those areas of address space which an application
|
KSM only operates on those areas of address space which an application
|
||||||
has advised to be likely candidates for merging, by using the madvise(2)
|
has advised to be likely candidates for merging, by using the madvise(2)
|
||||||
|
@ -44,20 +44,12 @@ includes unmapped gaps (though working on the intervening mapped areas),
|
||||||
and might fail with EAGAIN if not enough memory for internal structures.
|
and might fail with EAGAIN if not enough memory for internal structures.
|
||||||
|
|
||||||
Applications should be considerate in their use of MADV_MERGEABLE,
|
Applications should be considerate in their use of MADV_MERGEABLE,
|
||||||
restricting its use to areas likely to benefit. KSM's scans may use
|
restricting its use to areas likely to benefit. KSM's scans may use a lot
|
||||||
a lot of processing power, and its kernel-resident pages are a limited
|
of processing power: some installations will disable KSM for that reason.
|
||||||
resource. Some installations will disable KSM for these reasons.
|
|
||||||
|
|
||||||
The KSM daemon is controlled by sysfs files in /sys/kernel/mm/ksm/,
|
The KSM daemon is controlled by sysfs files in /sys/kernel/mm/ksm/,
|
||||||
readable by all but writable only by root:
|
readable by all but writable only by root:
|
||||||
|
|
||||||
max_kernel_pages - set to maximum number of kernel pages that KSM may use
|
|
||||||
e.g. "echo 100000 > /sys/kernel/mm/ksm/max_kernel_pages"
|
|
||||||
Value 0 imposes no limit on the kernel pages KSM may use;
|
|
||||||
but note that any process using MADV_MERGEABLE can cause
|
|
||||||
KSM to allocate these pages, unswappable until it exits.
|
|
||||||
Default: quarter of memory (chosen to not pin too much)
|
|
||||||
|
|
||||||
pages_to_scan - how many present pages to scan before ksmd goes to sleep
|
pages_to_scan - how many present pages to scan before ksmd goes to sleep
|
||||||
e.g. "echo 100 > /sys/kernel/mm/ksm/pages_to_scan"
|
e.g. "echo 100 > /sys/kernel/mm/ksm/pages_to_scan"
|
||||||
Default: 100 (chosen for demonstration purposes)
|
Default: 100 (chosen for demonstration purposes)
|
||||||
|
@ -75,7 +67,7 @@ run - set 0 to stop ksmd from running but keep merged pages,
|
||||||
|
|
||||||
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
|
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
|
||||||
|
|
||||||
pages_shared - how many shared unswappable kernel pages KSM is using
|
pages_shared - how many shared pages are being used
|
||||||
pages_sharing - how many more sites are sharing them i.e. how much saved
|
pages_sharing - how many more sites are sharing them i.e. how much saved
|
||||||
pages_unshared - how many pages unique but repeatedly checked for merging
|
pages_unshared - how many pages unique but repeatedly checked for merging
|
||||||
pages_volatile - how many pages changing too fast to be placed in a tree
|
pages_volatile - how many pages changing too fast to be placed in a tree
|
||||||
|
@ -87,4 +79,4 @@ pages_volatile embraces several different kinds of activity, but a high
|
||||||
proportion there would also indicate poor use of madvise MADV_MERGEABLE.
|
proportion there would also indicate poor use of madvise MADV_MERGEABLE.
|
||||||
|
|
||||||
Izik Eidus,
|
Izik Eidus,
|
||||||
Hugh Dickins, 24 Sept 2009
|
Hugh Dickins, 17 Nov 2009
|
||||||
|
|
|
@ -212,7 +212,7 @@ config KSM
|
||||||
Enable Kernel Samepage Merging: KSM periodically scans those areas
|
Enable Kernel Samepage Merging: KSM periodically scans those areas
|
||||||
of an application's address space that an app has advised may be
|
of an application's address space that an app has advised may be
|
||||||
mergeable. When it finds pages of identical content, it replaces
|
mergeable. When it finds pages of identical content, it replaces
|
||||||
the many instances by a single resident page with that content, so
|
the many instances by a single page with that content, so
|
||||||
saving memory until one or another app needs to modify the content.
|
saving memory until one or another app needs to modify the content.
|
||||||
Recommended for use with KVM, or with other duplicative applications.
|
Recommended for use with KVM, or with other duplicative applications.
|
||||||
See Documentation/vm/ksm.txt for more information: KSM is inactive
|
See Documentation/vm/ksm.txt for more information: KSM is inactive
|
||||||
|
|
41
mm/ksm.c
41
mm/ksm.c
|
@ -179,9 +179,6 @@ static unsigned long ksm_pages_unshared;
|
||||||
/* The number of rmap_items in use: to calculate pages_volatile */
|
/* The number of rmap_items in use: to calculate pages_volatile */
|
||||||
static unsigned long ksm_rmap_items;
|
static unsigned long ksm_rmap_items;
|
||||||
|
|
||||||
/* Limit on the number of unswappable pages used */
|
|
||||||
static unsigned long ksm_max_kernel_pages;
|
|
||||||
|
|
||||||
/* Number of pages ksmd should scan in one batch */
|
/* Number of pages ksmd should scan in one batch */
|
||||||
static unsigned int ksm_thread_pages_to_scan = 100;
|
static unsigned int ksm_thread_pages_to_scan = 100;
|
||||||
|
|
||||||
|
@ -943,14 +940,6 @@ static struct page *try_to_merge_two_pages(struct rmap_item *rmap_item,
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/*
|
|
||||||
* The number of nodes in the stable tree
|
|
||||||
* is the number of kernel pages that we hold.
|
|
||||||
*/
|
|
||||||
if (ksm_max_kernel_pages &&
|
|
||||||
ksm_max_kernel_pages <= ksm_pages_shared)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
|
err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
err = try_to_merge_with_ksm_page(tree_rmap_item,
|
err = try_to_merge_with_ksm_page(tree_rmap_item,
|
||||||
|
@ -1850,8 +1839,8 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||||
/*
|
/*
|
||||||
* KSM_RUN_MERGE sets ksmd running, and 0 stops it running.
|
* KSM_RUN_MERGE sets ksmd running, and 0 stops it running.
|
||||||
* KSM_RUN_UNMERGE stops it running and unmerges all rmap_items,
|
* KSM_RUN_UNMERGE stops it running and unmerges all rmap_items,
|
||||||
* breaking COW to free the unswappable pages_shared (but leaves
|
* breaking COW to free the pages_shared (but leaves mm_slots
|
||||||
* mm_slots on the list for when ksmd may be set running again).
|
* on the list for when ksmd may be set running again).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mutex_lock(&ksm_thread_mutex);
|
mutex_lock(&ksm_thread_mutex);
|
||||||
|
@ -1876,29 +1865,6 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||||
}
|
}
|
||||||
KSM_ATTR(run);
|
KSM_ATTR(run);
|
||||||
|
|
||||||
static ssize_t max_kernel_pages_store(struct kobject *kobj,
|
|
||||||
struct kobj_attribute *attr,
|
|
||||||
const char *buf, size_t count)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
unsigned long nr_pages;
|
|
||||||
|
|
||||||
err = strict_strtoul(buf, 10, &nr_pages);
|
|
||||||
if (err)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ksm_max_kernel_pages = nr_pages;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t max_kernel_pages_show(struct kobject *kobj,
|
|
||||||
struct kobj_attribute *attr, char *buf)
|
|
||||||
{
|
|
||||||
return sprintf(buf, "%lu\n", ksm_max_kernel_pages);
|
|
||||||
}
|
|
||||||
KSM_ATTR(max_kernel_pages);
|
|
||||||
|
|
||||||
static ssize_t pages_shared_show(struct kobject *kobj,
|
static ssize_t pages_shared_show(struct kobject *kobj,
|
||||||
struct kobj_attribute *attr, char *buf)
|
struct kobj_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -1948,7 +1914,6 @@ static struct attribute *ksm_attrs[] = {
|
||||||
&sleep_millisecs_attr.attr,
|
&sleep_millisecs_attr.attr,
|
||||||
&pages_to_scan_attr.attr,
|
&pages_to_scan_attr.attr,
|
||||||
&run_attr.attr,
|
&run_attr.attr,
|
||||||
&max_kernel_pages_attr.attr,
|
|
||||||
&pages_shared_attr.attr,
|
&pages_shared_attr.attr,
|
||||||
&pages_sharing_attr.attr,
|
&pages_sharing_attr.attr,
|
||||||
&pages_unshared_attr.attr,
|
&pages_unshared_attr.attr,
|
||||||
|
@ -1968,8 +1933,6 @@ static int __init ksm_init(void)
|
||||||
struct task_struct *ksm_thread;
|
struct task_struct *ksm_thread;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
ksm_max_kernel_pages = totalram_pages / 4;
|
|
||||||
|
|
||||||
err = ksm_slab_init();
|
err = ksm_slab_init();
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in a new issue