From: Nilay Vaish <nilayvaish@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@kernel.org>,
Greg Thelen <gthelen@google.com>,
Roman Gushchin <kfree@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Nilay Vaish <nilayvaish@google.com>
Subject: [PATCH 14/15] mm/page_owner, alloc_tag: use folio_page() for page_ext and codetag
Date: Tue, 29 Sep 2026 14:52:05 -0700 [thread overview]
Message-ID: <20260929215206.516490-15-nilayvaish@google.com> (raw)
In-Reply-To: <20260929215206.516490-1-nilayvaish@google.com>
As part of the memdescs effort, struct folio will be allocated
separately from struct page and will no longer overlay the head page.
Replace direct &folio->page, &old->page, &new->page, and &newfolio->page
uses with folio_page(..., 0) in __folio_set_owner_migrate_reason(),
__folio_copy_owner(), pgalloc_tag_split(), and pgalloc_tag_swap().
No functional change intended.
Assisted-by: LLM
Signed-off-by: Nilay Vaish <nilayvaish@google.com>
---
mm/alloc_tag.c | 10 +++++-----
mm/page_owner.c | 15 +++++++++------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
index 82e2c3448dcf..c93efb224ce1 100644
--- a/mm/alloc_tag.c
+++ b/mm/alloc_tag.c
@@ -534,7 +534,7 @@ void pgalloc_tag_split(struct folio *folio, int old_order, int new_order)
if (!mem_alloc_profiling_enabled())
return;
- tag = __pgalloc_tag_get(&folio->page);
+ tag = __pgalloc_tag_get(folio_page(folio, 0));
if (!tag)
return;
@@ -560,16 +560,16 @@ void pgalloc_tag_swap(struct folio *new, struct folio *old)
if (!mem_alloc_profiling_enabled())
return;
- tag_old = __pgalloc_tag_get(&old->page);
+ tag_old = __pgalloc_tag_get(folio_page(old, 0));
if (!tag_old)
return;
- tag_new = __pgalloc_tag_get(&new->page);
+ tag_new = __pgalloc_tag_get(folio_page(new, 0));
if (!tag_new)
return;
- if (!get_page_tag_ref(&old->page, &ref_old, &handle_old))
+ if (!get_page_tag_ref(folio_page(old, 0), &ref_old, &handle_old))
return;
- if (!get_page_tag_ref(&new->page, &ref_new, &handle_new)) {
+ if (!get_page_tag_ref(folio_page(new, 0), &ref_new, &handle_new)) {
put_page_tag_ref(handle_old);
return;
}
diff --git a/mm/page_owner.c b/mm/page_owner.c
index cfc31c92d765..39c381699a63 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -365,7 +365,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order,
void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason)
{
- struct page_ext *page_ext = page_ext_get(&folio->page);
+ struct page_ext *page_ext = page_ext_get(folio_page(folio, 0));
struct page_owner *page_owner;
if (unlikely(!page_ext))
@@ -398,14 +398,14 @@ void __folio_copy_owner(struct folio *newfolio, struct folio *old)
struct page_owner *new_page_owner;
depot_stack_handle_t migrate_handle;
- page_ext = page_ext_get(&old->page);
+ page_ext = page_ext_get(folio_page(old, 0));
if (unlikely(!page_ext))
return;
old_page_owner = get_page_owner(page_ext);
page_ext_put(page_ext);
- page_ext = page_ext_get(&newfolio->page);
+ page_ext = page_ext_get(folio_page(newfolio, 0));
if (unlikely(!page_ext))
return;
@@ -413,7 +413,8 @@ void __folio_copy_owner(struct folio *newfolio, struct folio *old)
page_ext_put(page_ext);
migrate_handle = new_page_owner->handle;
- __update_page_owner_handle(&newfolio->page, old_page_owner->handle,
+ __update_page_owner_handle(folio_page(newfolio, 0),
+ old_page_owner->handle,
old_page_owner->order, old_page_owner->gfp_mask,
old_page_owner->last_migrate_reason,
old_page_owner->ts_nsec, old_page_owner->pid,
@@ -423,7 +424,8 @@ void __folio_copy_owner(struct folio *newfolio, struct folio *old)
* will be freed after migration. Keep them until then as they may be
* useful.
*/
- __update_page_owner_free_handle(&newfolio->page, 0, old_page_owner->order,
+ __update_page_owner_free_handle(folio_page(newfolio, 0), 0,
+ old_page_owner->order,
old_page_owner->free_pid,
old_page_owner->free_tgid,
old_page_owner->free_ts_nsec);
@@ -433,7 +435,8 @@ void __folio_copy_owner(struct folio *newfolio, struct folio *old)
* when subtracting those pages from the stack.
*/
rcu_read_lock();
- for_each_page_ext(&old->page, 1 << new_page_owner->order, page_ext, iter) {
+ for_each_page_ext(folio_page(old, 0), 1 << new_page_owner->order,
+ page_ext, iter) {
old_page_owner = get_page_owner(page_ext);
old_page_owner->handle = migrate_handle;
}
--
2.56.0.rc1.315.gc6ed9934b7-goog
next prev parent reply other threads:[~2026-09-29 21:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 21:51 [PATCH 00/15] mm: eliminate &folio->page references in mm/ Nilay Vaish
2026-09-29 21:51 ` [PATCH 01/15] mm/khugepaged: drop redundant page parameter from set_huge_pmd() Nilay Vaish
2026-09-29 21:51 ` [PATCH 02/15] mm/huge_memory: use folio_page() in PMD/PUD rmap, zap, and migration Nilay Vaish
2026-09-29 21:51 ` [PATCH 03/15] mm/huge_memory: use folio_page() in THP split paths Nilay Vaish
2026-09-29 21:51 ` [PATCH 04/15] mm/hugetlb_vmemmap: use folio_page() for vmemmap address arithmetic Nilay Vaish
2026-09-29 21:51 ` [PATCH 05/15] mm/hugetlb_cma: use folio_page() in hugetlb_cma_free_frozen_folio() Nilay Vaish
2026-09-29 21:51 ` [PATCH 06/15] mm/hugetlb: replace &folio->page with folio_page() and VM_BUG_ON_FOLIO() Nilay Vaish
2026-09-29 21:51 ` [PATCH 07/15] mm/page_isolation: use folio_page() in page_is_unmovable() Nilay Vaish
2026-09-29 21:51 ` [PATCH 08/15] mm/compaction: stop casting free pages to struct folio Nilay Vaish
2026-09-29 21:52 ` [PATCH 09/15] mm/migrate, vmscan: use folio_page() for movable_ops helpers Nilay Vaish
2026-09-29 21:52 ` [PATCH 10/15] mm/memory: use folio_page() in fault and CoW paths Nilay Vaish
2026-09-29 21:52 ` [PATCH 11/15] mm/rmap, gup: use folio_page() for PageAnonExclusive and gup_must_unshare Nilay Vaish
2026-09-29 21:52 ` [PATCH 12/15] mm/ksm, userfaultfd: replace &folio->page with folio_page() Nilay Vaish
2026-09-29 21:52 ` [PATCH 13/15] mm/page_alloc, folio: use folio_page() when freeing folios Nilay Vaish
2026-09-29 21:52 ` Nilay Vaish [this message]
2026-09-29 21:52 ` [PATCH 15/15] mm: replace remaining &folio->page uses with folio_page() and helpers Nilay Vaish
2026-09-30 10:17 ` [PATCH 00/15] mm: eliminate &folio->page references in mm/ David Hildenbrand (Arm)
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=20260929215206.516490-15-nilayvaish@google.com \
--to=nilayvaish@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=gthelen@google.com \
--cc=kfree@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®