[Devel] [PATCH RHEL9 COMMIT] ms/mm/ksm: add pages_skipped metric
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Aug 27 20:29:09 MSK 2024
The commit is pushed to "branch-rh9-5.14.0-427.31.1.vz9.70.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.31.1.vz9.68.1
------>
commit 7c5311ba09b5506a90b1dc5a91a7295d76032909
Author: Stefan Roesch <shr at devkernel.io>
Date: Wed Aug 21 14:45:42 2024 +0800
ms/mm/ksm: add pages_skipped metric
This change adds the "pages skipped" metric. To be able to evaluate how
successful smart page scanning is, the pages skipped metric can be
compared to the pages scanned metric.
The pages skipped metric is a cumulative counter. The counter is stored
under /sys/kernel/mm/ksm/pages_skipped.
Link: https://lkml.kernel.org/r/20230926040939.516161-3-shr@devkernel.io
Signed-off-by: Stefan Roesch <shr at devkernel.io>
Reviewed-by: David Hildenbrand <david at redhat.com>
Cc: Johannes Weiner <hannes at cmpxchg.org>
Cc: Rik van Riel <riel at surriel.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
https://virtuozzo.atlassian.net/browse/PSBM-157809
(cherry picked from commit e5a68991268906a6989f1bf273580c2218662ad6)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
======
Patchset description:
ksm: port smart scanning and advisor to improve performance
1) "Smart" scanning allows ksm to skip pages which didn't manage to be
deduplicated after several iterations, it skips those pages for maximum
8 iterations and then retries again. To enable:
echo 1 > /sys/kernel/mm/ksm/smart_scan
2) Ksm Advisor allows ksm to autoscale pages_to_scan based on previous
scans data to perform full memory scan in advisor_target_scan_time
(200s by default). It will increase scanning rate if new processes with
more pages to deduplicate start and will decrease performance impact
in more stable situations. To enable:
echo "scan-time" /sys/kernel/mm/ksm/advisor_mode
note: Don't forget to enable ksm, when using above, with:
echo 1 > /sys/kernel/mm/ksm/run
note: It shows greater performance on sysbench and webbench perf tests
in vconsolidate on csus > 40.
https://virtuozzo.atlassian.net/browse/PSBM-157809
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Stefan Roesch (4):
mm/ksm: add "smart" page scanning mode
mm/ksm: add pages_skipped metric
mm/ksm: add ksm advisor
mm/ksm: add sysfs knobs for advisor
Feature: ksm: smart scanning and advisor
---
mm/ksm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mm/ksm.c b/mm/ksm.c
index 1994db2b5014..767831a01306 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -284,6 +284,9 @@ static bool ksm_use_zero_pages __read_mostly;
/* Default to true at least temporarily, for testing */
static bool ksm_smart_scan = true;
+/* The number of pages that have been skipped due to "smart scanning" */
+static unsigned long ksm_pages_skipped;
+
#ifdef CONFIG_NUMA
/* Zeroed when merging across nodes is not allowed */
static unsigned int ksm_merge_across_nodes = 1;
@@ -2283,6 +2286,7 @@ static bool should_skip_rmap_item(struct page *page,
}
/* Skip this page */
+ ksm_pages_skipped++;
rmap_item->remaining_skips--;
remove_rmap_item_from_tree(rmap_item);
return true;
@@ -3177,6 +3181,13 @@ static ssize_t pages_volatile_show(struct kobject *kobj,
}
KSM_ATTR_RO(pages_volatile);
+static ssize_t pages_skipped_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ return sysfs_emit(buf, "%lu\n", ksm_pages_skipped);
+}
+KSM_ATTR_RO(pages_skipped);
+
static ssize_t stable_node_dups_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
@@ -3254,6 +3265,7 @@ static struct attribute *ksm_attrs[] = {
&pages_sharing_attr.attr,
&pages_unshared_attr.attr,
&pages_volatile_attr.attr,
+ &pages_skipped_attr.attr,
&full_scans_attr.attr,
#ifdef CONFIG_NUMA
&merge_across_nodes_attr.attr,
More information about the Devel
mailing list