summaryrefslogtreecommitdiffstats
path: root/mm/ksm.c
diff options
context:
space:
mode:
authorStefan Roesch <shr@devkernel.io>2023-09-26 06:09:37 +0200
committerAndrew Morton <akpm@linux-foundation.org>2023-10-17 00:44:39 +0200
commite5a68991268906a6989f1bf273580c2218662ad6 (patch)
tree02b6ea1bc78a1dc5c5f7b584c006007350fecbf9 /mm/ksm.c
parentmm/ksm: add "smart" page scanning mode (diff)
downloadlinux-e5a68991268906a6989f1bf273580c2218662ad6.tar.xz
linux-e5a68991268906a6989f1bf273580c2218662ad6.zip
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@devkernel.io> Reviewed-by: David Hildenbrand <david@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Rik van Riel <riel@surriel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/ksm.c')
-rw-r--r--mm/ksm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/mm/ksm.c b/mm/ksm.c
index 8ad66b1c91b9..7efcc68ccc6e 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -294,6 +294,9 @@ static bool ksm_smart_scan = true;
/* The number of zero pages which is placed by KSM */
unsigned long ksm_zero_pages;
+/* 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;
@@ -2377,6 +2380,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;
@@ -3464,6 +3468,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 ksm_zero_pages_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
@@ -3561,6 +3572,7 @@ static struct attribute *ksm_attrs[] = {
&pages_sharing_attr.attr,
&pages_unshared_attr.attr,
&pages_volatile_attr.attr,
+ &pages_skipped_attr.attr,
&ksm_zero_pages_attr.attr,
&full_scans_attr.attr,
#ifdef CONFIG_NUMA