[PATCH] mm/page_owner: preserve original free_pid/free_tgid during folio migration

From: Hongfu Li

Date: Thu Sep 03 2026 - 05:28:11 EST


From: Hongfu Li <lihongfu@xxxxxxxxxx>

__update_page_owner_free_handle() accepts pid and tgid, but ignores
them, always storing current->pid and current->tgid.

__folio_copy_owner() forwards the original free pid/tgid during folio
migration, yet these values were overwritten by the migrating task.

Store the passed-in pid/tgid so the migrated folio keeps the original
free attribution.

Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>
---
mm/page_owner.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index 3fc37d9b908e..cfc31c92d765 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -307,8 +307,8 @@ static inline void __update_page_owner_free_handle(struct page *page,
page_owner->free_handle = handle;
}
page_owner->free_ts_nsec = free_ts_nsec;
- page_owner->free_pid = current->pid;
- page_owner->free_tgid = current->tgid;
+ page_owner->free_pid = pid;
+ page_owner->free_tgid = tgid;
}
rcu_read_unlock();
}
--
2.54.0