Lines Matching refs:order

214 static void __free_pages_ok(struct page *page, unsigned int order,
288 static bool page_contains_unaccepted(struct page *page, unsigned int order);
289 static bool cond_accept_memory(struct zone *zone, unsigned int order);
314 _deferred_grow_zone(struct zone *zone, unsigned int order) in _deferred_grow_zone() argument
316 return deferred_grow_zone(zone, order); in _deferred_grow_zone()
324 static inline bool _deferred_grow_zone(struct zone *zone, unsigned int order) in _deferred_grow_zone() argument
509 static inline unsigned int order_to_pindex(int migratetype, int order) in order_to_pindex() argument
514 if (order > PAGE_ALLOC_COSTLY_ORDER) { in order_to_pindex()
515 VM_BUG_ON(order != HPAGE_PMD_ORDER); in order_to_pindex()
522 VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); in order_to_pindex()
525 return (MIGRATE_PCPTYPES * order) + migratetype; in order_to_pindex()
530 int order = pindex / MIGRATE_PCPTYPES; in pindex_to_order() local
534 order = HPAGE_PMD_ORDER; in pindex_to_order()
536 VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); in pindex_to_order()
539 return order; in pindex_to_order()
542 static inline bool pcp_allowed_order(unsigned int order) in pcp_allowed_order() argument
544 if (order <= PAGE_ALLOC_COSTLY_ORDER) in pcp_allowed_order()
547 if (order == HPAGE_PMD_ORDER) in pcp_allowed_order()
565 void prep_compound_page(struct page *page, unsigned int order) in prep_compound_page() argument
568 int nr_pages = 1 << order; in prep_compound_page()
574 prep_compound_head(page, order); in prep_compound_page()
577 static inline void set_buddy_order(struct page *page, unsigned int order) in set_buddy_order() argument
579 set_page_private(page, order); in set_buddy_order()
596 int order, int migratetype) in compaction_capture() argument
598 if (!capc || order != capc->cc->order) in compaction_capture()
613 if (order < pageblock_order && migratetype == MIGRATE_MOVABLE && in compaction_capture()
629 int order, int migratetype) in compaction_capture() argument
654 unsigned int order, int migratetype, in __add_to_free_list() argument
657 struct free_area *area = &zone->free_area[order]; in __add_to_free_list()
661 get_pageblock_migratetype(page), migratetype, 1 << order); in __add_to_free_list()
676 unsigned int order, int old_mt, int new_mt) in move_to_free_list() argument
678 struct free_area *area = &zone->free_area[order]; in move_to_free_list()
683 get_pageblock_migratetype(page), old_mt, 1 << order); in move_to_free_list()
687 account_freepages(zone, -(1 << order), old_mt); in move_to_free_list()
688 account_freepages(zone, 1 << order, new_mt); in move_to_free_list()
692 unsigned int order, int migratetype) in __del_page_from_free_list() argument
696 get_pageblock_migratetype(page), migratetype, 1 << order); in __del_page_from_free_list()
705 zone->free_area[order].nr_free--; in __del_page_from_free_list()
709 unsigned int order, int migratetype) in del_page_from_free_list() argument
711 __del_page_from_free_list(page, zone, order, migratetype); in del_page_from_free_list()
712 account_freepages(zone, -(1 << order), migratetype); in del_page_from_free_list()
732 struct page *page, unsigned int order) in buddy_merge_likely() argument
737 if (order >= MAX_PAGE_ORDER - 1) in buddy_merge_likely()
743 return find_buddy_page_pfn(higher_page, higher_page_pfn, order + 1, in buddy_merge_likely()
773 struct zone *zone, unsigned int order, in __free_one_page() argument
786 VM_BUG_ON_PAGE(pfn & ((1 << order) - 1), page); in __free_one_page()
789 account_freepages(zone, 1 << order, migratetype); in __free_one_page()
791 while (order < MAX_PAGE_ORDER) { in __free_one_page()
794 if (compaction_capture(capc, page, order, migratetype)) { in __free_one_page()
795 account_freepages(zone, -(1 << order), migratetype); in __free_one_page()
799 buddy = find_buddy_page_pfn(page, pfn, order, &buddy_pfn); in __free_one_page()
803 if (unlikely(order >= pageblock_order)) { in __free_one_page()
823 clear_page_guard(zone, buddy, order); in __free_one_page()
825 __del_page_from_free_list(buddy, zone, order, buddy_mt); in __free_one_page()
839 order++; in __free_one_page()
843 set_buddy_order(page, order); in __free_one_page()
847 else if (is_shuffle_order(order)) in __free_one_page()
850 to_tail = buddy_merge_likely(pfn, buddy_pfn, page, order); in __free_one_page()
852 __add_to_free_list(page, zone, order, migratetype, to_tail); in __free_one_page()
856 page_reporting_notify_free(order); in __free_one_page()
1045 unsigned int order) in free_pages_prepare() argument
1055 trace_mm_page_free(page, order); in free_pages_prepare()
1056 kmsan_free_page(page, order); in free_pages_prepare()
1059 __memcg_kmem_uncharge_page(page, order); in free_pages_prepare()
1075 if (unlikely(PageHWPoison(page)) && !order) { in free_pages_prepare()
1077 reset_page_owner(page, order); in free_pages_prepare()
1078 page_table_check_free(page, order); in free_pages_prepare()
1079 pgalloc_tag_sub(page, 1 << order); in free_pages_prepare()
1090 VM_BUG_ON_PAGE(compound && compound_order(page) != order, page); in free_pages_prepare()
1096 if (unlikely(order)) { in free_pages_prepare()
1101 for (i = 1; i < (1 << order); i++) { in free_pages_prepare()
1115 mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); in free_pages_prepare()
1127 reset_page_owner(page, order); in free_pages_prepare()
1128 page_table_check_free(page, order); in free_pages_prepare()
1129 pgalloc_tag_sub(page, 1 << order); in free_pages_prepare()
1133 PAGE_SIZE << order); in free_pages_prepare()
1135 PAGE_SIZE << order); in free_pages_prepare()
1138 kernel_poison_pages(page, 1 << order); in free_pages_prepare()
1149 kasan_poison_pages(page, order, init); in free_pages_prepare()
1156 kernel_init_pages(page, 1 << order); in free_pages_prepare()
1163 arch_free_page(page, order); in free_pages_prepare()
1165 debug_pagealloc_unmap_pages(page, 1 << order); in free_pages_prepare()
1180 unsigned int order; in free_pcppages_bulk() local
1205 order = pindex_to_order(pindex); in free_pcppages_bulk()
1206 nr_pages = 1 << order; in free_pcppages_bulk()
1220 __free_one_page(page, pfn, zone, order, mt, FPI_NONE); in free_pcppages_bulk()
1221 trace_mm_page_pcpu_drain(page, order, mt); in free_pcppages_bulk()
1230 unsigned long pfn, int order, fpi_t fpi) in split_large_buddy() argument
1232 unsigned long end = pfn + (1 << order); in split_large_buddy()
1234 VM_WARN_ON_ONCE(!IS_ALIGNED(pfn, 1 << order)); in split_large_buddy()
1238 if (order > pageblock_order) in split_large_buddy()
1239 order = pageblock_order; in split_large_buddy()
1244 __free_one_page(page, pfn, zone, order, mt, fpi); in split_large_buddy()
1245 pfn += 1 << order; in split_large_buddy()
1251 unsigned long pfn, unsigned int order, in free_one_page() argument
1257 split_large_buddy(zone, page, pfn, order, fpi_flags); in free_one_page()
1260 __count_vm_events(PGFREE, 1 << order); in free_one_page()
1263 static void __free_pages_ok(struct page *page, unsigned int order, in __free_pages_ok() argument
1269 if (free_pages_prepare(page, order)) in __free_pages_ok()
1270 free_one_page(zone, page, pfn, order, fpi_flags); in __free_pages_ok()
1273 void __meminit __free_pages_core(struct page *page, unsigned int order, in __free_pages_core() argument
1276 unsigned int nr_pages = 1 << order; in __free_pages_core()
1313 if (page_contains_unaccepted(page, order)) { in __free_pages_core()
1314 if (order == MAX_PAGE_ORDER && __free_unaccepted(page)) in __free_pages_core()
1317 accept_memory(page_to_phys(page), PAGE_SIZE << order); in __free_pages_core()
1324 __free_pages_ok(page, order, FPI_TO_TAIL); in __free_pages_core()
1458 static inline bool check_new_pages(struct page *page, unsigned int order) in check_new_pages() argument
1461 for (int i = 0; i < (1 << order); i++) { in check_new_pages()
1500 inline void post_alloc_hook(struct page *page, unsigned int order, in post_alloc_hook() argument
1511 arch_alloc_page(page, order); in post_alloc_hook()
1512 debug_pagealloc_map_pages(page, 1 << order); in post_alloc_hook()
1519 kernel_unpoison_pages(page, 1 << order); in post_alloc_hook()
1533 for (i = 0; i != 1 << order; ++i) in post_alloc_hook()
1540 kasan_unpoison_pages(page, order, init)) { in post_alloc_hook()
1549 for (i = 0; i != 1 << order; ++i) in post_alloc_hook()
1554 kernel_init_pages(page, 1 << order); in post_alloc_hook()
1556 set_page_owner(page, order, gfp_flags); in post_alloc_hook()
1557 page_table_check_alloc(page, order); in post_alloc_hook()
1558 pgalloc_tag_add(page, current, 1 << order); in post_alloc_hook()
1561 static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags, in prep_new_page() argument
1564 post_alloc_hook(page, order, gfp_flags); in prep_new_page()
1566 if (order && (gfp_flags & __GFP_COMP)) in prep_new_page()
1567 prep_compound_page(page, order); in prep_new_page()
1586 struct page *__rmqueue_smallest(struct zone *zone, unsigned int order, in __rmqueue_smallest() argument
1594 for (current_order = order; current_order < NR_PAGE_ORDERS; ++current_order) { in __rmqueue_smallest()
1600 page_del_and_expand(zone, page, order, current_order, in __rmqueue_smallest()
1602 trace_mm_page_alloc_zone_locked(page, order, migratetype, in __rmqueue_smallest()
1603 pcp_allowed_order(order) && in __rmqueue_smallest()
1626 unsigned int order) in __rmqueue_cma_fallback() argument
1628 return __rmqueue_smallest(zone, order, MIGRATE_CMA); in __rmqueue_cma_fallback()
1632 unsigned int order) { return NULL; } in __rmqueue_cma_fallback() argument
1644 unsigned int order; in __move_freepages_block() local
1661 order = buddy_order(page); in __move_freepages_block()
1663 move_to_free_list(page, zone, order, old_mt, new_mt); in __move_freepages_block()
1665 pfn += 1 << order; in __move_freepages_block()
1666 pages_moved += 1 << order; in __move_freepages_block()
1739 int order = 0; in find_large_buddy() local
1745 if (++order > MAX_PAGE_ORDER) in find_large_buddy()
1747 pfn &= ~0UL << order; in find_large_buddy()
1795 int order = buddy_order(buddy); in move_freepages_block_isolate() local
1797 del_page_from_free_list(buddy, zone, order, in move_freepages_block_isolate()
1800 split_large_buddy(zone, buddy, pfn, order, FPI_NONE); in move_freepages_block_isolate()
1806 int order = buddy_order(page); in move_freepages_block_isolate() local
1808 del_page_from_free_list(page, zone, order, in move_freepages_block_isolate()
1811 split_large_buddy(zone, page, pfn, order, FPI_NONE); in move_freepages_block_isolate()
1845 static bool can_steal_fallback(unsigned int order, int start_mt) in can_steal_fallback() argument
1854 if (order >= pageblock_order) in can_steal_fallback()
1857 if (order >= pageblock_order / 2 || in can_steal_fallback()
1913 int current_order, int order, int start_type, in steal_suitable_fallback() argument
1935 nr_added = expand(zone, page, order, current_order, start_type); in steal_suitable_fallback()
1985 return __rmqueue_smallest(zone, order, start_type); in steal_suitable_fallback()
1989 page_del_and_expand(zone, page, order, current_order, block_type); in steal_suitable_fallback()
1999 int find_suitable_fallback(struct free_area *area, unsigned int order, in find_suitable_fallback() argument
2014 if (can_steal_fallback(order, migratetype)) in find_suitable_fallback()
2032 static void reserve_highatomic_pageblock(struct page *page, int order, in reserve_highatomic_pageblock() argument
2062 if (order < pageblock_order) { in reserve_highatomic_pageblock()
2067 change_pageblock_range(page, order, MIGRATE_HIGHATOMIC); in reserve_highatomic_pageblock()
2068 zone->nr_reserved_highatomic += 1 << order; in reserve_highatomic_pageblock()
2092 int order; in unreserve_highatomic_pageblock() local
2106 for (order = 0; order < NR_PAGE_ORDERS; order++) { in unreserve_highatomic_pageblock()
2107 struct free_area *area = &(zone->free_area[order]); in unreserve_highatomic_pageblock()
2131 size = max(pageblock_nr_pages, 1UL << order); in unreserve_highatomic_pageblock()
2145 if (order < pageblock_order) in unreserve_highatomic_pageblock()
2149 move_to_free_list(page, zone, order, mt, in unreserve_highatomic_pageblock()
2151 change_pageblock_range(page, order, in unreserve_highatomic_pageblock()
2182 __rmqueue_fallback(struct zone *zone, int order, int start_migratetype, in __rmqueue_fallback() argument
2187 int min_order = order; in __rmqueue_fallback()
2197 if (order < pageblock_order && alloc_flags & ALLOC_NOFRAGMENT) in __rmqueue_fallback()
2222 && current_order > order) in __rmqueue_fallback()
2231 for (current_order = order; current_order < NR_PAGE_ORDERS; current_order++) { in __rmqueue_fallback()
2249 page = steal_suitable_fallback(zone, page, current_order, order, in __rmqueue_fallback()
2252 trace_mm_page_alloc_extfrag(page, order, current_order, in __rmqueue_fallback()
2263 __rmqueue(struct zone *zone, unsigned int order, int migratetype, in __rmqueue() argument
2277 page = __rmqueue_cma_fallback(zone, order); in __rmqueue()
2283 page = __rmqueue_smallest(zone, order, migratetype); in __rmqueue()
2286 page = __rmqueue_cma_fallback(zone, order); in __rmqueue()
2289 page = __rmqueue_fallback(zone, order, migratetype, in __rmqueue()
2300 static int rmqueue_bulk(struct zone *zone, unsigned int order, in rmqueue_bulk() argument
2309 struct page *page = __rmqueue(zone, order, migratetype, in rmqueue_bulk()
2595 unsigned int order) in free_unref_page_commit() argument
2607 __count_vm_events(PGFREE, 1 << order); in free_unref_page_commit()
2608 pindex = order_to_pindex(migratetype, order); in free_unref_page_commit()
2610 pcp->count += 1 << order; in free_unref_page_commit()
2619 if (order && order <= PAGE_ALLOC_COSTLY_ORDER) { in free_unref_page_commit()
2629 pcp->free_count += (1 << order); in free_unref_page_commit()
2644 void free_unref_page(struct page *page, unsigned int order) in free_unref_page() argument
2652 if (!pcp_allowed_order(order)) { in free_unref_page()
2653 __free_pages_ok(page, order, FPI_NONE); in free_unref_page()
2657 if (!free_pages_prepare(page, order)) in free_unref_page()
2670 free_one_page(page_zone(page), page, pfn, order, FPI_NONE); in free_unref_page()
2680 free_unref_page_commit(zone, pcp, page, migratetype, order); in free_unref_page()
2683 free_one_page(zone, page, pfn, order, FPI_NONE); in free_unref_page()
2702 unsigned int order = folio_order(folio); in free_unref_folios() local
2704 if (!free_pages_prepare(&folio->page, order)) in free_unref_folios()
2710 if (!pcp_allowed_order(order)) { in free_unref_folios()
2712 pfn, order, FPI_NONE); in free_unref_folios()
2715 folio->private = (void *)(unsigned long)order; in free_unref_folios()
2726 unsigned int order = (unsigned long)folio->private; in free_unref_folios() local
2748 order, FPI_NONE); in free_unref_folios()
2761 order, FPI_NONE); in free_unref_folios()
2776 order); in free_unref_folios()
2794 void split_page(struct page *page, unsigned int order) in split_page() argument
2801 for (i = 1; i < (1 << order); i++) in split_page()
2803 split_page_owner(page, order, 0); in split_page()
2804 pgalloc_tag_split(page_folio(page), order, 0); in split_page()
2805 split_page_memcg(page, order, 0); in split_page()
2809 int __isolate_free_page(struct page *page, unsigned int order) in __isolate_free_page() argument
2822 watermark = zone->_watermark[WMARK_MIN] + (1UL << order); in __isolate_free_page()
2827 del_page_from_free_list(page, zone, order, mt); in __isolate_free_page()
2833 if (order >= pageblock_order - 1) { in __isolate_free_page()
2834 struct page *endpage = page + (1 << order) - 1; in __isolate_free_page()
2847 return 1UL << order; in __isolate_free_page()
2859 void __putback_isolated_page(struct page *page, unsigned int order, int mt) in __putback_isolated_page() argument
2867 __free_one_page(page, page_to_pfn(page), zone, order, mt, in __putback_isolated_page()
2899 unsigned int order, unsigned int alloc_flags, in rmqueue_buddy() argument
2909 page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); in rmqueue_buddy()
2911 page = __rmqueue(zone, order, migratetype, alloc_flags); in rmqueue_buddy()
2920 page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); in rmqueue_buddy()
2928 } while (check_new_pages(page, order)); in rmqueue_buddy()
2930 __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); in rmqueue_buddy()
2936 static int nr_pcp_alloc(struct per_cpu_pages *pcp, struct zone *zone, int order) in nr_pcp_alloc() argument
2950 if (order) in nr_pcp_alloc()
2962 if (!order) { in nr_pcp_alloc()
2981 batch = max(batch >> order, 2); in nr_pcp_alloc()
2988 struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order, in __rmqueue_pcplist() argument
2998 int batch = nr_pcp_alloc(pcp, zone, order); in __rmqueue_pcplist()
3001 alloced = rmqueue_bulk(zone, order, in __rmqueue_pcplist()
3005 pcp->count += alloced << order; in __rmqueue_pcplist()
3012 pcp->count -= 1 << order; in __rmqueue_pcplist()
3013 } while (check_new_pages(page, order)); in __rmqueue_pcplist()
3020 struct zone *zone, unsigned int order, in rmqueue_pcplist() argument
3042 list = &pcp->lists[order_to_pindex(migratetype, order)]; in rmqueue_pcplist()
3043 page = __rmqueue_pcplist(zone, order, migratetype, alloc_flags, pcp, list); in rmqueue_pcplist()
3047 __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); in rmqueue_pcplist()
3067 struct zone *zone, unsigned int order, in rmqueue() argument
3073 if (likely(pcp_allowed_order(order))) { in rmqueue()
3074 page = rmqueue_pcplist(preferred_zone, zone, order, in rmqueue()
3080 page = rmqueue_buddy(preferred_zone, zone, order, alloc_flags, in rmqueue()
3096 unsigned int order, unsigned int alloc_flags) in __zone_watermark_unusable_free() argument
3098 long unusable_free = (1 << order) - 1; in __zone_watermark_unusable_free()
3122 bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, in __zone_watermark_ok() argument
3130 free_pages -= __zone_watermark_unusable_free(z, order, alloc_flags); in __zone_watermark_ok()
3170 if (!order) in __zone_watermark_ok()
3174 for (o = order; o < NR_PAGE_ORDERS; o++) { in __zone_watermark_ok()
3200 bool zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, in zone_watermark_ok() argument
3203 return __zone_watermark_ok(z, order, mark, highest_zoneidx, alloc_flags, in zone_watermark_ok()
3207 static inline bool zone_watermark_fast(struct zone *z, unsigned int order, in zone_watermark_fast() argument
3219 if (!order) { in zone_watermark_fast()
3232 if (__zone_watermark_ok(z, order, mark, highest_zoneidx, alloc_flags, in zone_watermark_fast()
3242 if (unlikely(!order && (alloc_flags & ALLOC_MIN_RESERVE) && z->watermark_boost in zone_watermark_fast()
3245 return __zone_watermark_ok(z, order, mark, highest_zoneidx, in zone_watermark_fast()
3252 bool zone_watermark_ok_safe(struct zone *z, unsigned int order, in zone_watermark_ok_safe() argument
3260 return __zone_watermark_ok(z, order, mark, highest_zoneidx, 0, in zone_watermark_ok_safe()
3335 get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, in get_page_from_freelist() argument
3405 cond_accept_memory(zone, order); in get_page_from_freelist()
3418 if (zone_watermark_fast(zone, order, mark, in get_page_from_freelist()
3427 if (!zone_watermark_fast(zone, order, mark, in get_page_from_freelist()
3432 if (cond_accept_memory(zone, order)) in get_page_from_freelist()
3440 if (_deferred_grow_zone(zone, order)) in get_page_from_freelist()
3452 ret = node_reclaim(zone->zone_pgdat, gfp_mask, order); in get_page_from_freelist()
3462 if (zone_watermark_ok(zone, order, mark, in get_page_from_freelist()
3471 page = rmqueue(zonelist_zone(ac->preferred_zoneref), zone, order, in get_page_from_freelist()
3474 prep_new_page(page, order, gfp_mask, alloc_flags); in get_page_from_freelist()
3481 reserve_highatomic_pageblock(page, order, zone); in get_page_from_freelist()
3485 if (cond_accept_memory(zone, order)) in get_page_from_freelist()
3490 if (_deferred_grow_zone(zone, order)) in get_page_from_freelist()
3553 __alloc_pages_cpuset_fallback(gfp_t gfp_mask, unsigned int order, in __alloc_pages_cpuset_fallback() argument
3559 page = get_page_from_freelist(gfp_mask, order, in __alloc_pages_cpuset_fallback()
3566 page = get_page_from_freelist(gfp_mask, order, in __alloc_pages_cpuset_fallback()
3573 __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, in __alloc_pages_may_oom() argument
3581 .order = order, in __alloc_pages_may_oom()
3605 ~__GFP_DIRECT_RECLAIM, order, in __alloc_pages_may_oom()
3614 if (order > PAGE_ALLOC_COSTLY_ORDER) in __alloc_pages_may_oom()
3651 page = __alloc_pages_cpuset_fallback(gfp_mask, order, in __alloc_pages_may_oom()
3668 __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, in __alloc_pages_direct_compact() argument
3676 if (!order) in __alloc_pages_direct_compact()
3683 *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, in __alloc_pages_direct_compact()
3700 prep_new_page(page, order, gfp_mask, alloc_flags); in __alloc_pages_direct_compact()
3704 page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); in __alloc_pages_direct_compact()
3710 compaction_defer_reset(zone, order, true); in __alloc_pages_direct_compact()
3727 should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, in should_compact_retry() argument
3738 if (!order) in should_compact_retry()
3749 ret = compaction_zonelist_suitable(ac, order, alloc_flags); in should_compact_retry()
3767 if (order > PAGE_ALLOC_COSTLY_ORDER) in should_compact_retry()
3779 min_priority = (order > PAGE_ALLOC_COSTLY_ORDER) ? in should_compact_retry()
3788 trace_compact_retry(order, priority, compact_result, retries, max_retries, ret); in should_compact_retry()
3793 __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, in __alloc_pages_direct_compact() argument
3802 should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags, in should_compact_retry() argument
3810 if (!order || order > PAGE_ALLOC_COSTLY_ORDER) in should_compact_retry()
3914 __perform_reclaim(gfp_t gfp_mask, unsigned int order, in __perform_reclaim() argument
3927 progress = try_to_free_pages(ac->zonelist, order, gfp_mask, in __perform_reclaim()
3940 __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order, in __alloc_pages_direct_reclaim() argument
3949 *did_some_progress = __perform_reclaim(gfp_mask, order, ac); in __alloc_pages_direct_reclaim()
3954 page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); in __alloc_pages_direct_reclaim()
3973 static void wake_all_kswapds(unsigned int order, gfp_t gfp_mask, in wake_all_kswapds() argument
3986 wakeup_kswapd(zone, gfp_mask, order, highest_zoneidx); in wake_all_kswapds()
3993 gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order) in gfp_to_alloc_flags() argument
4022 if (order > 0) in gfp_to_alloc_flags()
4094 should_reclaim_retry(gfp_t gfp_mask, unsigned order, in should_reclaim_retry() argument
4107 if (did_some_progress && order <= PAGE_ALLOC_COSTLY_ORDER) in should_reclaim_retry()
4141 wmark = __zone_watermark_ok(zone, order, min_wmark, in should_reclaim_retry()
4143 trace_reclaim_retry_zone(z, order, reclaimable, in should_reclaim_retry()
4204 __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, in __alloc_pages_slowpath() argument
4210 const bool costly_order = order > PAGE_ALLOC_COSTLY_ORDER; in __alloc_pages_slowpath()
4227 WARN_ON_ONCE(order > 1); in __alloc_pages_slowpath()
4253 alloc_flags = gfp_to_alloc_flags(gfp_mask, order); in __alloc_pages_slowpath()
4280 wake_all_kswapds(order, gfp_mask, ac); in __alloc_pages_slowpath()
4286 page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); in __alloc_pages_slowpath()
4301 (order > 0 && ac->migratetype != MIGRATE_MOVABLE)) in __alloc_pages_slowpath()
4303 page = __alloc_pages_direct_compact(gfp_mask, order, in __alloc_pages_slowpath()
4348 wake_all_kswapds(order, gfp_mask, ac); in __alloc_pages_slowpath()
4367 page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); in __alloc_pages_slowpath()
4380 page = __alloc_pages_direct_reclaim(gfp_mask, order, alloc_flags, ac, in __alloc_pages_slowpath()
4386 page = __alloc_pages_direct_compact(gfp_mask, order, alloc_flags, ac, in __alloc_pages_slowpath()
4403 if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags, in __alloc_pages_slowpath()
4414 should_compact_retry(ac, order, alloc_flags, in __alloc_pages_slowpath()
4429 page = __alloc_pages_may_oom(gfp_mask, order, ac, &did_some_progress); in __alloc_pages_slowpath()
4474 page = __alloc_pages_cpuset_fallback(gfp_mask, order, ALLOC_MIN_RESERVE, ac); in __alloc_pages_slowpath()
4483 "page allocation failure: order:%u", order); in __alloc_pages_slowpath()
4488 static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, in prepare_alloc_pages() argument
4512 if (should_fail_alloc_page(gfp_mask, order)) in prepare_alloc_pages()
4715 struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order, in __alloc_pages_noprof() argument
4727 if (WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp)) in __alloc_pages_noprof()
4740 if (!prepare_alloc_pages(gfp, order, preferred_nid, nodemask, &ac, in __alloc_pages_noprof()
4751 page = get_page_from_freelist(alloc_gfp, order, alloc_flags, &ac); in __alloc_pages_noprof()
4764 page = __alloc_pages_slowpath(alloc_gfp, order, &ac); in __alloc_pages_noprof()
4768 unlikely(__memcg_kmem_charge_page(page, gfp, order) != 0)) { in __alloc_pages_noprof()
4769 __free_pages(page, order); in __alloc_pages_noprof()
4773 trace_mm_page_alloc(page, order, alloc_gfp, ac.migratetype); in __alloc_pages_noprof()
4774 kmsan_alloc_page(page, order, alloc_gfp); in __alloc_pages_noprof()
4780 struct folio *__folio_alloc_noprof(gfp_t gfp, unsigned int order, int preferred_nid, in __folio_alloc_noprof() argument
4783 struct page *page = __alloc_pages_noprof(gfp | __GFP_COMP, order, in __folio_alloc_noprof()
4794 unsigned long get_free_pages_noprof(gfp_t gfp_mask, unsigned int order) in get_free_pages_noprof() argument
4798 page = alloc_pages_noprof(gfp_mask & ~__GFP_HIGHMEM, order); in get_free_pages_noprof()
4831 void __free_pages(struct page *page, unsigned int order) in __free_pages() argument
4838 free_unref_page(page, order); in __free_pages()
4840 pgalloc_tag_sub_pages(tag, (1 << order) - 1); in __free_pages()
4841 while (order-- > 0) in __free_pages()
4842 free_unref_page(page + (1 << order), order); in __free_pages()
4847 void free_pages(unsigned long addr, unsigned int order) in free_pages() argument
4851 __free_pages(virt_to_page((void *)addr), order); in free_pages()
4993 static void *make_alloc_exact(unsigned long addr, unsigned int order, in make_alloc_exact() argument
5001 split_page_owner(page, order, 0); in make_alloc_exact()
5002 pgalloc_tag_split(page_folio(page), order, 0); in make_alloc_exact()
5003 split_page_memcg(page, order, 0); in make_alloc_exact()
5007 last = page + (1UL << order); in make_alloc_exact()
5031 unsigned int order = get_order(size); in alloc_pages_exact_noprof() local
5037 addr = get_free_pages_noprof(gfp_mask, order); in alloc_pages_exact_noprof()
5038 return make_alloc_exact(addr, order, size); in alloc_pages_exact_noprof()
5056 unsigned int order = get_order(size); in alloc_pages_exact_nid_noprof() local
5062 p = alloc_pages_node_noprof(nid, gfp_mask, order); in alloc_pages_exact_nid_noprof()
5065 return make_alloc_exact((unsigned long)page_address(p), order, size); in alloc_pages_exact_nid_noprof()
6487 int order; in split_free_pages() local
6489 for (order = 0; order < NR_PAGE_ORDERS; order++) { in split_free_pages()
6491 int nr_pages = 1 << order; in split_free_pages()
6493 list_for_each_entry_safe(page, next, &list[order], lru) { in split_free_pages()
6496 post_alloc_hook(page, order, __GFP_MOVABLE); in split_free_pages()
6497 if (!order) in split_free_pages()
6500 split_page(page, order); in split_free_pages()
6539 .order = -1, in alloc_contig_range_noprof()
6632 int order = ilog2(end - start); in alloc_contig_range_noprof() local
6634 check_new_pages(head, order); in alloc_contig_range_noprof()
6635 prep_new_page(head, order, gfp_mask, 0); in alloc_contig_range_noprof()
6829 unsigned int order; in __offline_isolated_pages() local
6859 order = buddy_order(page); in __offline_isolated_pages()
6860 del_page_from_free_list(page, zone, order, MIGRATE_ISOLATE); in __offline_isolated_pages()
6861 pfn += (1 << order); in __offline_isolated_pages()
6875 unsigned int order; in is_free_buddy_page() local
6877 for (order = 0; order < NR_PAGE_ORDERS; order++) { in is_free_buddy_page()
6878 const struct page *head = page - (pfn & ((1 << order) - 1)); in is_free_buddy_page()
6881 buddy_order_unsafe(head) >= order) in is_free_buddy_page()
6885 return order <= MAX_PAGE_ORDER; in is_free_buddy_page()
6891 unsigned int order, int migratetype, in add_to_free_list() argument
6894 __add_to_free_list(page, zone, order, migratetype, tail); in add_to_free_list()
6895 account_freepages(zone, 1 << order, migratetype); in add_to_free_list()
6936 unsigned int order; in take_page_off_buddy() local
6940 for (order = 0; order < NR_PAGE_ORDERS; order++) { in take_page_off_buddy()
6941 struct page *page_head = page - (pfn & ((1 << order) - 1)); in take_page_off_buddy()
6944 if (PageBuddy(page_head) && page_order >= order) { in take_page_off_buddy()
7026 static bool page_contains_unaccepted(struct page *page, unsigned int order) in page_contains_unaccepted() argument
7030 return range_contains_unaccepted_memory(start, PAGE_SIZE << order); in page_contains_unaccepted()
7093 static bool cond_accept_memory(struct zone *zone, unsigned int order) in cond_accept_memory() argument
7107 __zone_watermark_unusable_free(zone, order, 0) - in cond_accept_memory()
7145 static bool page_contains_unaccepted(struct page *page, unsigned int order) in page_contains_unaccepted() argument
7150 static bool cond_accept_memory(struct zone *zone, unsigned int order) in cond_accept_memory() argument