Skip to content

Commit a3477c9

Browse files
Hugh Dickinsakpm00
authored andcommitted
mm/thp: fix deferred split queue not partially_mapped: fix
Though even more elusive than before, list_del corruption has still been seen on THP's deferred split queue. The idea in commit e66f318 was right, but its implementation wrong. The context omitted an important comment just before the critical test: "split_folio() removes folio from list on success." In ignoring that comment, when a THP split succeeded, the code went on to release the preceding safe folio, preserving instead an irrelevant (formerly head) folio: which gives no safety because it's not on the list. Fix the logic. Link: https://lkml.kernel.org/r/[email protected] Fixes: e66f318 ("mm/thp: fix deferred split queue not partially_mapped") Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Usama Arif <[email protected]> Reviewed-by: Zi Yan <[email protected]> Cc: Baolin Wang <[email protected]> Cc: Barry Song <[email protected]> Cc: Chris Li <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Nhat Pham <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Wei Yang <[email protected]> Cc: Yang Shi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 94efde1 commit a3477c9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/huge_memory.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,9 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
37903790
* in the case it was underused, then consider it used and
37913791
* don't add it back to split_queue.
37923792
*/
3793-
if (!did_split && !folio_test_partially_mapped(folio)) {
3793+
if (did_split) {
3794+
; /* folio already removed from list */
3795+
} else if (!folio_test_partially_mapped(folio)) {
37943796
list_del_init(&folio->_deferred_list);
37953797
removed++;
37963798
} else {

0 commit comments

Comments
 (0)