mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-01 16:31:34 -05:00
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]>
This commit is contained in:
parent
cb8d68ec16
commit
e3ae19535c
1 changed files with 6 additions and 4 deletions
|
|
@ -3478,17 +3478,19 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
|
|||
int split = 0;
|
||||
|
||||
spin_lock_irqsave(&pgdata->split_queue_lock, flags);
|
||||
list_splice_init(&pgdata->split_queue, &list);
|
||||
|
||||
/* Take pin on all head pages to avoid freeing them under us */
|
||||
list_for_each_safe(pos, next, &list) {
|
||||
page = list_entry((void *)pos, struct page, mapping);
|
||||
page = compound_head(page);
|
||||
/* race with put_compound_page() */
|
||||
if (!get_page_unless_zero(page)) {
|
||||
if (get_page_unless_zero(page)) {
|
||||
list_move(page_deferred_list(page), &list);
|
||||
} else {
|
||||
/* We lost race with put_compound_page() */
|
||||
list_del_init(page_deferred_list(page));
|
||||
pgdata->split_queue_len--;
|
||||
}
|
||||
if (!--sc->nr_to_scan)
|
||||
break;
|
||||
}
|
||||
spin_unlock_irqrestore(&pgdata->split_queue_lock, flags);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue