linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
	Oscar Salvador <osalvador@suse.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-dev@igalia.com
Subject: [PATCH RFC 2/9] mm/page_owner: add parameter option 'page_owner=on,swap'
Date: Fri,  5 Dec 2025 20:17:14 -0300	[thread overview]
Message-ID: <20251205231721.104505-3-mfo@igalia.com> (raw)
In-Reply-To: <20251205231721.104505-1-mfo@igalia.com>

CONFIG_SWAP_PAGE_OWNER will introduce a behavior change in page_owner on
systems with swap space. Thus, add the 'swap' option to the 'page_owner'
parameter to enable it ('page_owner=on,swap').

Currently, the allocation stack trace of a page is lost at swap-out (the
page is freed) and reset at swap-in (a new page is allocated).

With the new feature, if this option is enabled, the (initial) allocation
stack trace of a page is maintained over swap-out and swap-in, and the
refcounts for the initial and swap-in allocation stack traces are adjusted.

(Note: 'swap_page_owner_enabled' is parsed before 'page_owner_enabled', so
'page_owner=off,swap' could set the former but not the latter, but this is
a nop as then init_page_owner() returns early and doesn't enable anything.)

Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
---
 mm/page_owner.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index a70245684206..a27958872b07 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -57,6 +57,11 @@ struct stack_print_ctx {
 static bool page_owner_enabled __initdata;
 DEFINE_STATIC_KEY_FALSE(page_owner_inited);
 
+#ifdef CONFIG_SWAP_PAGE_OWNER
+static bool swap_page_owner_enabled __initdata;
+DEFINE_STATIC_KEY_FALSE(swap_page_owner_inited);
+#endif
+
 static depot_stack_handle_t dummy_handle;
 static depot_stack_handle_t failure_handle;
 static depot_stack_handle_t early_handle;
@@ -81,7 +86,18 @@ static inline void unset_current_in_page_owner(void)
 
 static int __init early_page_owner_param(char *buf)
 {
-	int ret = kstrtobool(buf, &page_owner_enabled);
+	int ret;
+
+#ifdef CONFIG_SWAP_PAGE_OWNER
+	char *swap = strchr(buf, ',');
+
+	if (swap) {
+		*swap++ = '\0';
+		if (!strcmp(swap, "swap"))
+			swap_page_owner_enabled = true;
+	}
+#endif
+	ret = kstrtobool(buf, &page_owner_enabled);
 
 	if (page_owner_enabled)
 		stack_depot_request_early_init();
@@ -138,6 +154,10 @@ static __init void init_page_owner(void)
 	dummy_stack.next = &failure_stack;
 	stack_list = &dummy_stack;
 	static_branch_enable(&page_owner_inited);
+#ifdef CONFIG_SWAP_PAGE_OWNER
+	if (swap_page_owner_enabled)
+		static_branch_enable(&swap_page_owner_inited);
+#endif
 }
 
 struct page_ext_operations page_owner_ops = {
-- 
2.51.0



  parent reply	other threads:[~2025-12-05 23:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05 23:17 [PATCH RFC 0/9] mm/page_owner: add support for pages in swap space Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 1/9] mm: add config option SWAP_PAGE_OWNER Mauricio Faria de Oliveira
2025-12-05 23:17 ` Mauricio Faria de Oliveira [this message]
2025-12-05 23:17 ` [PATCH RFC 3/9] mm/page_owner: add 'struct swap_page_owner' and helpers Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 4/9] mm/page_owner: add 'xarray swap_page_owners' " Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 5/9] mm/page_owner: add swap hooks Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 6/9] mm/page_owner: report '(swapped)' pages in debugfs file 'page_owner' Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 7/9] mm/page_owner: add debugfs file 'swap_page_owner' Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 8/9] mm: call arch-specific swap hooks from generic swap hooks Mauricio Faria de Oliveira
2025-12-05 23:17 ` [PATCH RFC 9/9] mm: call page_owner " Mauricio Faria de Oliveira

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=20251205231721.104505-3-mfo@igalia.com \
    --to=mfo@igalia.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=osalvador@suse.de \
    --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