From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Oscar Salvador <osalvador@suse.de>,
Suren Baghdasaryan <surenb@google.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-dev@igalia.com
Subject: [PATCH v2 1/5] mm/page_owner: introduce struct stack_print_ctx
Date: Wed, 1 Oct 2025 14:56:07 -0300 [thread overview]
Message-ID: <20251001175611.575861-2-mfo@igalia.com> (raw)
In-Reply-To: <20251001175611.575861-1-mfo@igalia.com>
Currently, struct seq_file.private is used as an iterator in stack_list
by stack_start|next(), for stack_print().
Create a context struct for this, in order to add another field next.
No behavior change intended.
P.S.: page_owner_stack_open() is expanded with separate statements for
variable definition and return just in preparation for the next patch.
Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
---
mm/page_owner.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/mm/page_owner.c b/mm/page_owner.c
index c3ca21132c2c..c1a7d7afe945 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -45,6 +45,10 @@ static struct stack failure_stack;
static struct stack *stack_list;
static DEFINE_SPINLOCK(stack_list_lock);
+struct stack_print_ctx {
+ struct stack *stack;
+};
+
static bool page_owner_enabled __initdata;
DEFINE_STATIC_KEY_FALSE(page_owner_inited);
@@ -856,6 +860,7 @@ static const struct file_operations proc_page_owner_operations = {
static void *stack_start(struct seq_file *m, loff_t *ppos)
{
struct stack *stack;
+ struct stack_print_ctx *ctx = m->private;
if (*ppos == -1UL)
return NULL;
@@ -867,9 +872,9 @@ static void *stack_start(struct seq_file *m, loff_t *ppos)
* value of stack_list.
*/
stack = smp_load_acquire(&stack_list);
- m->private = stack;
+ ctx->stack = stack;
} else {
- stack = m->private;
+ stack = ctx->stack;
}
return stack;
@@ -878,10 +883,11 @@ static void *stack_start(struct seq_file *m, loff_t *ppos)
static void *stack_next(struct seq_file *m, void *v, loff_t *ppos)
{
struct stack *stack = v;
+ struct stack_print_ctx *ctx = m->private;
stack = stack->next;
*ppos = stack ? *ppos + 1 : -1UL;
- m->private = stack;
+ ctx->stack = stack;
return stack;
}
@@ -926,7 +932,10 @@ static const struct seq_operations page_owner_stack_op = {
static int page_owner_stack_open(struct inode *inode, struct file *file)
{
- return seq_open_private(file, &page_owner_stack_op, 0);
+ int ret = seq_open_private(file, &page_owner_stack_op,
+ sizeof(struct stack_print_ctx));
+
+ return ret;
}
static const struct file_operations page_owner_stack_operations = {
--
2.48.1
next prev parent reply other threads:[~2025-10-01 17:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 17:56 [PATCH v2 0/5] mm/page_owner: add debugfs files 'show_handles' and 'show_stacks_handles' Mauricio Faria de Oliveira
2025-10-01 17:56 ` Mauricio Faria de Oliveira [this message]
2025-10-09 8:01 ` [PATCH v2 1/5] mm/page_owner: introduce struct stack_print_ctx Oscar Salvador
2025-10-01 17:56 ` [PATCH v2 2/5] mm/page_owner: add struct stack_print_ctx.flags Mauricio Faria de Oliveira
2025-10-09 8:07 ` Oscar Salvador
2025-10-01 17:56 ` [PATCH v2 3/5] mm/page_owner: add debugfs file 'show_handles' Mauricio Faria de Oliveira
2025-10-09 8:37 ` Oscar Salvador
2025-10-01 17:56 ` [PATCH v2 4/5] mm/page_owner: add debugfs file 'show_stacks_handles' Mauricio Faria de Oliveira
2025-10-01 17:56 ` [PATCH v2 5/5] mm/page_owner: update Documentation with 'show_handles' and 'show_stacks_handles' Mauricio Faria de Oliveira
2025-10-09 2:32 ` [PATCH v2 0/5] mm/page_owner: add debugfs files " Andrew Morton
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=20251001175611.575861-2-mfo@igalia.com \
--to=mfo@igalia.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=osalvador@suse.de \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/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