deferred_split_scan() gets called from reclaim path. Waiting for page lock may lead to deadlock there. Replace lock_page() with trylock_page() and skip the page if we failed to lock it. We will get to the page on the next scan.
Unified · Split
| @@ -2783,11 +2783,13 @@ static unsigned long deferred_split_scan(struct shrinker *shrink, · 2782 unmodified lines | |||
| 2783 | 2783 | ||
| 2784 | list_for_each_safe(pos, next, &list) { | 2784 | list_for_each_safe(pos, next, &list) { |
| 2785 | page = list_entry((void *)pos, struct page, mapping); | 2785 | page = list_entry((void *)pos, struct page, mapping); |
| 2786 | lock_page(page); | 2786 | if (!trylock_page(page)) |
| 2787 | goto next; | ||
| 2787 | /* split_huge_page() removes page from list on success */ | 2788 | /* split_huge_page() removes page from list on success */ |
| 2788 | if (!split_huge_page(page)) | 2789 | if (!split_huge_page(page)) |
| 2789 | split++; | 2790 | split++; |
| 2790 | unlock_page(page); | 2791 | unlock_page(page); |
| 2792 | next: | ||
| 2791 | put_page(page); | 2793 | put_page(page); |
| 2792 | } | 2794 | } |
| 2793 | 2795 | ||