compaction.c (c95baf12f5077419db01313ab61c2aac007d40cd) | compaction.c (1da2f328fa643bd72197dfed0c655148af31e4eb) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/mm/compaction.c 4 * 5 * Memory compaction for the reduction of external fragmentation. Note that 6 * this heavily depends upon page migration to do all the real heavy 7 * lifting 8 * --- 880 unchanged lines hidden (view full) --- 889 */ 890 if (freepage_order > 0 && freepage_order < MAX_ORDER) 891 low_pfn += (1UL << freepage_order) - 1; 892 continue; 893 } 894 895 /* 896 * Regardless of being on LRU, compound pages such as THP and | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/mm/compaction.c 4 * 5 * Memory compaction for the reduction of external fragmentation. Note that 6 * this heavily depends upon page migration to do all the real heavy 7 * lifting 8 * --- 880 unchanged lines hidden (view full) --- 889 */ 890 if (freepage_order > 0 && freepage_order < MAX_ORDER) 891 low_pfn += (1UL << freepage_order) - 1; 892 continue; 893 } 894 895 /* 896 * Regardless of being on LRU, compound pages such as THP and |
897 * hugetlbfs are not to be compacted. We can potentially save 898 * a lot of iterations if we skip them at once. The check is 899 * racy, but we can consider only valid values and the only 900 * danger is skipping too much. | 897 * hugetlbfs are not to be compacted unless we are attempting 898 * an allocation much larger than the huge page size (eg CMA). 899 * We can potentially save a lot of iterations if we skip them 900 * at once. The check is racy, but we can consider only valid 901 * values and the only danger is skipping too much. |
901 */ | 902 */ |
902 if (PageCompound(page)) { | 903 if (PageCompound(page) && !cc->alloc_contig) { |
903 const unsigned int order = compound_order(page); 904 905 if (likely(order < MAX_ORDER)) 906 low_pfn += (1UL << order) - 1; 907 goto isolate_fail; 908 } 909 910 /* --- 53 unchanged lines hidden (view full) --- 964 if (!PageLRU(page)) 965 goto isolate_fail; 966 967 /* 968 * Page become compound since the non-locked check, 969 * and it's on LRU. It can only be a THP so the order 970 * is safe to read and it's 0 for tail pages. 971 */ | 904 const unsigned int order = compound_order(page); 905 906 if (likely(order < MAX_ORDER)) 907 low_pfn += (1UL << order) - 1; 908 goto isolate_fail; 909 } 910 911 /* --- 53 unchanged lines hidden (view full) --- 965 if (!PageLRU(page)) 966 goto isolate_fail; 967 968 /* 969 * Page become compound since the non-locked check, 970 * and it's on LRU. It can only be a THP so the order 971 * is safe to read and it's 0 for tail pages. 972 */ |
972 if (unlikely(PageCompound(page))) { | 973 if (unlikely(PageCompound(page) && !cc->alloc_contig)) { |
973 low_pfn += compound_nr(page) - 1; 974 goto isolate_fail; 975 } 976 } 977 978 lruvec = mem_cgroup_page_lruvec(page, pgdat); 979 980 /* Try isolate the page */ 981 if (__isolate_lru_page(page, isolate_mode) != 0) 982 goto isolate_fail; 983 | 974 low_pfn += compound_nr(page) - 1; 975 goto isolate_fail; 976 } 977 } 978 979 lruvec = mem_cgroup_page_lruvec(page, pgdat); 980 981 /* Try isolate the page */ 982 if (__isolate_lru_page(page, isolate_mode) != 0) 983 goto isolate_fail; 984 |
984 VM_BUG_ON_PAGE(PageCompound(page), page); | 985 /* The whole page is taken off the LRU; skip the tail pages. */ 986 if (PageCompound(page)) 987 low_pfn += compound_nr(page) - 1; |
985 986 /* Successfully isolated */ 987 del_page_from_lru_list(page, lruvec, page_lru(page)); | 988 989 /* Successfully isolated */ 990 del_page_from_lru_list(page, lruvec, page_lru(page)); |
988 inc_node_page_state(page, 989 NR_ISOLATED_ANON + page_is_file_cache(page)); | 991 mod_node_page_state(page_pgdat(page), 992 NR_ISOLATED_ANON + page_is_file_cache(page), 993 hpage_nr_pages(page)); |
990 991isolate_success: 992 list_add(&page->lru, &cc->migratepages); 993 cc->nr_migratepages++; 994 nr_isolated++; 995 996 /* 997 * Avoid isolating too much unless this block is being --- 1738 unchanged lines hidden --- | 994 995isolate_success: 996 list_add(&page->lru, &cc->migratepages); 997 cc->nr_migratepages++; 998 nr_isolated++; 999 1000 /* 1001 * Avoid isolating too much unless this block is being --- 1738 unchanged lines hidden --- |