Skip to content

Commit b653db7

Browse files
author
Matthew Wilcox (Oracle)
committed
mm: Clear page->private when splitting or migrating a page
In our efforts to remove uses of PG_private, we have found folios with the private flag clear and folio->private not-NULL. That is the root cause behind 642d51f ("ceph: check folio PG_private bit instead of folio->private"). It can also affect a few other filesystems that haven't yet reported a problem. compaction_alloc() can return a page with uninitialised page->private, and rather than checking all the callers of migrate_pages(), just zero page->private after calling get_new_page(). Similarly, the tail pages from split_huge_page() may also have an uninitialised page->private. Reported-by: Xiubo Li <[email protected]> Tested-by: Xiubo Li <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
1 parent cb995f4 commit b653db7

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

mm/huge_memory.c

+1
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,7 @@ static void __split_huge_page_tail(struct page *head, int tail,
23772377
page_tail);
23782378
page_tail->mapping = head->mapping;
23792379
page_tail->index = head->index + tail;
2380+
page_tail->private = 0;
23802381

23812382
/* Page flags must be visible before we make the page non-compound. */
23822383
smp_wmb();

mm/migrate.c

+1
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,7 @@ static int unmap_and_move(new_page_t get_new_page,
11061106
if (!newpage)
11071107
return -ENOMEM;
11081108

1109+
newpage->private = 0;
11091110
rc = __unmap_and_move(page, newpage, force, mode);
11101111
if (rc == MIGRATEPAGE_SUCCESS)
11111112
set_page_owner_migrate_reason(newpage, reason);

0 commit comments

Comments
 (0)