linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
	Waiman Long <longman@redhat.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Marco Elver <elver@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Eric Dumazet <edumazet@google.com>,
	Alexander Potapenko <glider@google.com>,
	Oscar Salvador <osalvador@suse.de>
Subject: [PATCH v6 4/4] mm,page_owner: Filter out stacks by a threshold counter
Date: Mon, 20 Nov 2023 09:43:00 +0100	[thread overview]
Message-ID: <20231120084300.4368-5-osalvador@suse.de> (raw)
In-Reply-To: <20231120084300.4368-1-osalvador@suse.de>

We want to be able to filter out the output based on a certain
threshold, so we can leave out stacks with a low counter of
outstanding allocations.

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@suse.de>
---
 mm/page_owner.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index 509c11e506db..6ee345dafd01 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -41,6 +41,8 @@ static depot_stack_handle_t dummy_handle;
 static depot_stack_handle_t failure_handle;
 static depot_stack_handle_t early_handle;
 
+static unsigned long page_owner_stack_threshold;
+
 static void init_early_allocated_pages(void);
 
 static int __init early_page_owner_param(char *buf)
@@ -763,6 +765,9 @@ static int stack_print(struct seq_file *m, void *v)
 	int ret = 0;
 	struct stack_record *stack = (struct stack_record *)v;
 
+	if (refcount_read(&stack->count) < page_owner_stack_threshold)
+		return 0;
+
 	buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 
 	ret += stack_depot_get_stack_info(stack, buf);
@@ -804,6 +809,21 @@ const struct file_operations page_owner_stack_operations = {
 	.release        = seq_release,
 };
 
+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;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
+			&page_owner_threshold_set, "%llu");
+
 static int __init pageowner_init(void)
 {
 	if (!static_branch_unlikely(&page_owner_inited)) {
@@ -815,6 +835,8 @@ static int __init pageowner_init(void)
 			    &proc_page_owner_operations);
 	debugfs_create_file("page_owner_stacks", 0400, NULL, NULL,
 			    &page_owner_stack_operations);
+	debugfs_create_file("page_owner_threshold", 0600, NULL, NULL,
+			    &proc_page_owner_threshold);
 
 	return 0;
 }
-- 
2.42.0



  parent reply	other threads:[~2023-11-20  8:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  8:42 [PATCH v6 0/4] page_owner: print stacks and their counter Oscar Salvador
2023-11-20  8:42 ` [PATCH v6 1/4] lib/stackdepot: Add a refcount field in stack_record Oscar Salvador
2023-11-20  8:42 ` [PATCH v6 2/4] lib/stackdepot: Move stack_record struct definition into the header Oscar Salvador
2023-11-20  8:42 ` [PATCH v6 3/4] mm,page_owner: Add page_owner_stacks file to print out only stacks and their counter Oscar Salvador
2023-11-20  8:43 ` Oscar Salvador [this message]
2023-11-20 14:17   ` [PATCH v6 4/4] mm,page_owner: Filter out stacks by a threshold counter kernel test robot
2023-11-20 19:52   ` kernel test robot
2023-11-20  9:07 ` [PATCH v6 0/4] page_owner: print stacks and their counter Vlastimil Babka
2023-11-20 17:54   ` Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231120084300.4368-5-osalvador@suse.de \
    --to=osalvador@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=edumazet@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox