mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
mm/khugepaged: don't map folios that are not uptodate in MADV_COLLAPSE
madvise(MADV_COLLAPSE) can map PMD-sized pagecache folios that are not
uptodate. For example, shmem fallocate() can put such folios into the
page cache.
collapse_file() already refuses to proceed with folios that are not
uptodate. Let's just do the same in try_collapse_pte_mapped_thp() and skip
such folios, leaving handling to the page faults.
Note that collapse_file() effectively clears shmem folios through
shmem_get_folio(); let's keep this fix simple and simply let the page
fault path deal with that.
Fixes: 34488399fa ("mm/madvise: add file and shmem support to MADV_COLLAPSE")
Reported-by: Chris Mason <[email protected]>
Cc: [email protected]
Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Acked-by: Zi Yan <[email protected]>
Reviewed-by: Zach O'Keefe <[email protected]>
Reviewed-by: SJ Park <[email protected]>
Reviewed-by: Baolin Wang <[email protected]>
Reviewed-by: Lance Yang <[email protected]>
Reviewed-by: Kiryl Shutsemau (Meta) <[email protected]>
Link: https://patch.msgid.link/[email protected]
Reviewed-by: Pedro Falcato <[email protected]>
Signed-off-by: David Hildenbrand (Arm) <[email protected]>
This commit is contained in:
@@ -1888,6 +1888,12 @@ static enum scan_result try_collapse_pte_mapped_thp(struct mm_struct *mm, unsign
|
||||
goto drop_folio;
|
||||
}
|
||||
|
||||
/* Leave any uninitialized folios to the page fault path. */
|
||||
if (!folio_test_uptodate(folio)) {
|
||||
result = SCAN_FAIL;
|
||||
goto drop_folio;
|
||||
}
|
||||
|
||||
result = find_pmd_or_thp_or_none(mm, haddr, &pmd);
|
||||
switch (result) {
|
||||
case SCAN_SUCCEED:
|
||||
|
||||
Reference in New Issue
Block a user