Skip to content

Commit e3ae195

Browse files
kiryltorvalds
authored andcommitted
thp: limit number of object to scan on deferred_split_scan()
If we have a lot of pages in queue to be split, deferred_split_scan() can spend unreasonable amount of time under spinlock with disabled interrupts. Let's cap number of pages to split on scan by sc->nr_to_scan. Signed-off-by: Kirill A. Shutemov <[email protected]> Reported-by: Andrea Arcangeli <[email protected]> Reviewed-by: Andrea Arcangeli <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Jerome Marchand <[email protected]> Cc: Sasha Levin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cb8d68e commit e3ae195

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mm/huge_memory.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,17 +3478,19 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
34783478
int split = 0;
34793479

34803480
spin_lock_irqsave(&pgdata->split_queue_lock, flags);
3481-
list_splice_init(&pgdata->split_queue, &list);
3482-
34833481
/* Take pin on all head pages to avoid freeing them under us */
34843482
list_for_each_safe(pos, next, &list) {
34853483
page = list_entry((void *)pos, struct page, mapping);
34863484
page = compound_head(page);
3487-
/* race with put_compound_page() */
3488-
if (!get_page_unless_zero(page)) {
3485+
if (get_page_unless_zero(page)) {
3486+
list_move(page_deferred_list(page), &list);
3487+
} else {
3488+
/* We lost race with put_compound_page() */
34893489
list_del_init(page_deferred_list(page));
34903490
pgdata->split_queue_len--;
34913491
}
3492+
if (!--sc->nr_to_scan)
3493+
break;
34923494
}
34933495
spin_unlock_irqrestore(&pgdata->split_queue_lock, flags);
34943496

0 commit comments

Comments
 (0)