lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221104093354.6218-4-osalvador@suse.de>
Date:   Fri,  4 Nov 2022 10:33:54 +0100
From:   Oscar Salvador <osalvador@...e.de>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Michal Hocko <mhocko@...e.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Eric Dumazet <edumazet@...gle.com>,
        Waiman Long <longman@...hat.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Marco Elver <elver@...gle.com>,
        Andrey Konovalov <andreyknvl@...il.com>,
        Alexander Potapenko <glider@...gle.com>,
        Oscar Salvador <osalvador@...e.de>
Subject: [PATCH v3 3/3] mm,page_owner: Filter out stacks by a threshold counter

We want to be able to filter out the output on a threshold basis,
in this way we can get rid of a lot of noise and focus only on those
stacks which have an allegedly high counter.

We can control the threshold value by a new file called
'page_owner_threshold', which is 0 by default.

Signed-off-by: Oscar Salvador <osalvador@...e.de>
---
 include/linux/stackdepot.h |  3 +++
 lib/stackdepot.c           | 17 ++++++++++++++++-
 mm/page_owner.c            |  5 +++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h
index ca048a79bf7c..c998b8024534 100644
--- a/include/linux/stackdepot.h
+++ b/include/linux/stackdepot.h
@@ -70,6 +70,9 @@ depot_stack_handle_t stack_depot_save_action(unsigned long *entries,
 void *stack_start(struct seq_file *m, loff_t *ppos);
 void *stack_next(struct seq_file *m, void *v, loff_t *ppos);
 int stack_print(struct seq_file *m, void *v);
+
+int page_owner_threshold_get(void *data, u64 *val);
+int page_owner_threshold_set(void *data, u64 val);
 #endif
 
 unsigned int stack_depot_fetch(depot_stack_handle_t handle,
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 97e5dce40f4b..b70d081d7c61 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -569,6 +569,9 @@ depot_stack_handle_t stack_depot_save_action(unsigned long *entries,
 EXPORT_SYMBOL_GPL(stack_depot_save_action);
 
 #ifdef CONFIG_PAGE_OWNER
+
+static unsigned long page_owner_stack_threshold = 0;
+
 void *stack_start(struct seq_file *m, loff_t *ppos)
 {
 	unsigned long *table = m->private;
@@ -624,7 +627,7 @@ int stack_print(struct seq_file *m, void *v)
 
 	if (!stack->size || stack->size < 0 ||
 	    stack->size > PAGE_SIZE || stack->handle.valid != 1 ||
-	    refcount_read(&stack->count) < 1)
+	    refcount_read(&stack->count) < page_owner_stack_threshold)
 		return 0;
 
 	buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
@@ -637,4 +640,16 @@ int stack_print(struct seq_file *m, void *v)
 
         return 0;
 }
+
+int page_owner_threshold_get(void *data, u64 *val)
+{
+        *val = page_owner_stack_threshold;
+        return 0;
+}
+
+int page_owner_threshold_set(void *data, u64 val)
+{
+        page_owner_stack_threshold = val;
+        return 0;
+}
 #endif
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 3808c0985060..3e05ebd25ba0 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -694,6 +694,9 @@ const struct file_operations page_owner_stack_operations = {
 	.release        = seq_release,
 };
 
+DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
+                        &page_owner_threshold_set, "%lu");
+
 static int __init pageowner_init(void)
 {
 	if (!static_branch_unlikely(&page_owner_inited)) {
@@ -706,6 +709,8 @@ static int __init pageowner_init(void)
 
 	debugfs_create_file("page_owner_stacks", S_IRUSR, NULL, NULL,
 			     &page_owner_stack_operations);
+	debugfs_create_file("page_owner_threshold", 0600, NULL, NULL,
+			    &proc_page_owner_threshold);
 
 	return 0;
 }
-- 
2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ