page_alloc.c (566513775dca7f0d4ba15da4bc8394cdb2c98829) | page_alloc.c (b3d40a2b6d10c9d0424d2b398bf962fb6adad87e) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/mm/page_alloc.c 4 * 5 * Manages the free list, the system allocates free pages here. 6 * Note that kmalloc() lives in slab.c 7 * 8 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds --- 1058 unchanged lines hidden (view full) --- 1067 */ 1068 1069static inline void __free_one_page(struct page *page, 1070 unsigned long pfn, 1071 struct zone *zone, unsigned int order, 1072 int migratetype, fpi_t fpi_flags) 1073{ 1074 struct capture_control *capc = task_capc(zone); | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/mm/page_alloc.c 4 * 5 * Manages the free list, the system allocates free pages here. 6 * Note that kmalloc() lives in slab.c 7 * 8 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds --- 1058 unchanged lines hidden (view full) --- 1067 */ 1068 1069static inline void __free_one_page(struct page *page, 1070 unsigned long pfn, 1071 struct zone *zone, unsigned int order, 1072 int migratetype, fpi_t fpi_flags) 1073{ 1074 struct capture_control *capc = task_capc(zone); |
1075 unsigned int max_order = pageblock_order; |
|
1075 unsigned long buddy_pfn; 1076 unsigned long combined_pfn; | 1076 unsigned long buddy_pfn; 1077 unsigned long combined_pfn; |
1077 unsigned int max_order; | |
1078 struct page *buddy; 1079 bool to_tail; 1080 | 1078 struct page *buddy; 1079 bool to_tail; 1080 |
1081 max_order = min_t(unsigned int, MAX_ORDER - 1, pageblock_order); 1082 | |
1083 VM_BUG_ON(!zone_is_initialized(zone)); 1084 VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page); 1085 1086 VM_BUG_ON(migratetype == -1); 1087 if (likely(!is_migrate_isolate(migratetype))) 1088 __mod_zone_freepage_state(zone, 1 << order, migratetype); 1089 1090 VM_BUG_ON_PAGE(pfn & ((1 << order) - 1), page); --- 1163 unchanged lines hidden (view full) --- 2254 struct page *p = page; 2255 2256 do { 2257 __ClearPageReserved(p); 2258 set_page_count(p, 0); 2259 } while (++p, --i); 2260 2261 set_pageblock_migratetype(page, MIGRATE_CMA); | 1081 VM_BUG_ON(!zone_is_initialized(zone)); 1082 VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page); 1083 1084 VM_BUG_ON(migratetype == -1); 1085 if (likely(!is_migrate_isolate(migratetype))) 1086 __mod_zone_freepage_state(zone, 1 << order, migratetype); 1087 1088 VM_BUG_ON_PAGE(pfn & ((1 << order) - 1), page); --- 1163 unchanged lines hidden (view full) --- 2252 struct page *p = page; 2253 2254 do { 2255 __ClearPageReserved(p); 2256 set_page_count(p, 0); 2257 } while (++p, --i); 2258 2259 set_pageblock_migratetype(page, MIGRATE_CMA); |
2260 set_page_refcounted(page); 2261 __free_pages(page, pageblock_order); |
|
2262 | 2262 |
2263 if (pageblock_order >= MAX_ORDER) { 2264 i = pageblock_nr_pages; 2265 p = page; 2266 do { 2267 set_page_refcounted(p); 2268 __free_pages(p, MAX_ORDER - 1); 2269 p += MAX_ORDER_NR_PAGES; 2270 } while (i -= MAX_ORDER_NR_PAGES); 2271 } else { 2272 set_page_refcounted(page); 2273 __free_pages(page, pageblock_order); 2274 } 2275 | |
2276 adjust_managed_page_count(page, pageblock_nr_pages); 2277 page_zone(page)->cma_pages += pageblock_nr_pages; 2278} 2279#endif 2280 2281/* 2282 * The order of subdivision here is critical for the IO subsystem. 2283 * Please do not alter this order without good reasons and regression --- 5093 unchanged lines hidden (view full) --- 7377static inline void setup_usemap(struct zone *zone) {} 7378#endif /* CONFIG_SPARSEMEM */ 7379 7380#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE 7381 7382/* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ 7383void __init set_pageblock_order(void) 7384{ | 2263 adjust_managed_page_count(page, pageblock_nr_pages); 2264 page_zone(page)->cma_pages += pageblock_nr_pages; 2265} 2266#endif 2267 2268/* 2269 * The order of subdivision here is critical for the IO subsystem. 2270 * Please do not alter this order without good reasons and regression --- 5093 unchanged lines hidden (view full) --- 7364static inline void setup_usemap(struct zone *zone) {} 7365#endif /* CONFIG_SPARSEMEM */ 7366 7367#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE 7368 7369/* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ 7370void __init set_pageblock_order(void) 7371{ |
7385 unsigned int order; | 7372 unsigned int order = MAX_ORDER - 1; |
7386 7387 /* Check that pageblock_nr_pages has not already been setup */ 7388 if (pageblock_order) 7389 return; 7390 | 7373 7374 /* Check that pageblock_nr_pages has not already been setup */ 7375 if (pageblock_order) 7376 return; 7377 |
7391 if (HPAGE_SHIFT > PAGE_SHIFT) | 7378 /* Don't let pageblocks exceed the maximum allocation granularity. */ 7379 if (HPAGE_SHIFT > PAGE_SHIFT && HUGETLB_PAGE_ORDER < order) |
7392 order = HUGETLB_PAGE_ORDER; | 7380 order = HUGETLB_PAGE_ORDER; |
7393 else 7394 order = MAX_ORDER - 1; | |
7395 7396 /* 7397 * Assume the largest contiguous order of interest is a huge page. 7398 * This value may be variable depending on boot parameters on IA64 and 7399 * powerpc. 7400 */ 7401 pageblock_order = order; 7402} --- 1571 unchanged lines hidden (view full) --- 8974 return page; 8975 } 8976 return NULL; 8977} 8978 8979#ifdef CONFIG_CONTIG_ALLOC 8980static unsigned long pfn_max_align_down(unsigned long pfn) 8981{ | 7381 7382 /* 7383 * Assume the largest contiguous order of interest is a huge page. 7384 * This value may be variable depending on boot parameters on IA64 and 7385 * powerpc. 7386 */ 7387 pageblock_order = order; 7388} --- 1571 unchanged lines hidden (view full) --- 8960 return page; 8961 } 8962 return NULL; 8963} 8964 8965#ifdef CONFIG_CONTIG_ALLOC 8966static unsigned long pfn_max_align_down(unsigned long pfn) 8967{ |
8982 return pfn & ~(max_t(unsigned long, MAX_ORDER_NR_PAGES, 8983 pageblock_nr_pages) - 1); | 8968 return ALIGN_DOWN(pfn, MAX_ORDER_NR_PAGES); |
8984} 8985 8986static unsigned long pfn_max_align_up(unsigned long pfn) 8987{ | 8969} 8970 8971static unsigned long pfn_max_align_up(unsigned long pfn) 8972{ |
8988 return ALIGN(pfn, max_t(unsigned long, MAX_ORDER_NR_PAGES, 8989 pageblock_nr_pages)); | 8973 return ALIGN(pfn, MAX_ORDER_NR_PAGES); |
8990} 8991 8992#if defined(CONFIG_DYNAMIC_DEBUG) || \ 8993 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) 8994/* Usage: See admin-guide/dynamic-debug-howto.rst */ 8995static void alloc_contig_dump_pages(struct list_head *page_list) 8996{ 8997 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, "migrate failure"); --- 563 unchanged lines hidden --- | 8974} 8975 8976#if defined(CONFIG_DYNAMIC_DEBUG) || \ 8977 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) 8978/* Usage: See admin-guide/dynamic-debug-howto.rst */ 8979static void alloc_contig_dump_pages(struct list_head *page_list) 8980{ 8981 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, "migrate failure"); --- 563 unchanged lines hidden --- |