page_alloc.c (2932c8b05056d4ba702f70f4deebe1c97600e62b) | page_alloc.c (d381c54760dcfad23743da40516e7e003d73952a) |
---|---|
1/* 2 * linux/mm/page_alloc.c 3 * 4 * Manages the free list, the system allocates free pages here. 5 * Note that kmalloc() lives in slab.c 6 * 7 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 8 * Swap reorganised 29.12.95, Stephen Tweedie --- 7753 unchanged lines hidden (view full) --- 7762 * If @count is not zero, it is okay to include less @count unmovable pages 7763 * 7764 * PageLRU check without isolation or lru_lock could race so that 7765 * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable 7766 * check without lock_page also may miss some movable non-lru pages at 7767 * race condition. So you can't expect this function should be exact. 7768 */ 7769bool has_unmovable_pages(struct zone *zone, struct page *page, int count, | 1/* 2 * linux/mm/page_alloc.c 3 * 4 * Manages the free list, the system allocates free pages here. 5 * Note that kmalloc() lives in slab.c 6 * 7 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 8 * Swap reorganised 29.12.95, Stephen Tweedie --- 7753 unchanged lines hidden (view full) --- 7762 * If @count is not zero, it is okay to include less @count unmovable pages 7763 * 7764 * PageLRU check without isolation or lru_lock could race so that 7765 * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable 7766 * check without lock_page also may miss some movable non-lru pages at 7767 * race condition. So you can't expect this function should be exact. 7768 */ 7769bool has_unmovable_pages(struct zone *zone, struct page *page, int count, |
7770 int migratetype, 7771 bool skip_hwpoisoned_pages) | 7770 int migratetype, int flags) |
7772{ 7773 unsigned long pfn, iter, found; 7774 7775 /* 7776 * TODO we could make this much more efficient by not checking every 7777 * page in the range if we know all of them are in MOVABLE_ZONE and 7778 * that the movable zone guarantees that pages are migratable but 7779 * the later is not the case right now unfortunatelly. E.g. movablecore --- 57 unchanged lines hidden (view full) --- 7837 iter += (1 << page_order(page)) - 1; 7838 continue; 7839 } 7840 7841 /* 7842 * The HWPoisoned page may be not in buddy system, and 7843 * page_count() is not 0. 7844 */ | 7771{ 7772 unsigned long pfn, iter, found; 7773 7774 /* 7775 * TODO we could make this much more efficient by not checking every 7776 * page in the range if we know all of them are in MOVABLE_ZONE and 7777 * that the movable zone guarantees that pages are migratable but 7778 * the later is not the case right now unfortunatelly. E.g. movablecore --- 57 unchanged lines hidden (view full) --- 7836 iter += (1 << page_order(page)) - 1; 7837 continue; 7838 } 7839 7840 /* 7841 * The HWPoisoned page may be not in buddy system, and 7842 * page_count() is not 0. 7843 */ |
7845 if (skip_hwpoisoned_pages && PageHWPoison(page)) | 7844 if ((flags & SKIP_HWPOISON) && PageHWPoison(page)) |
7846 continue; 7847 7848 if (__PageMovable(page)) 7849 continue; 7850 7851 if (!PageLRU(page)) 7852 found++; 7853 /* --- 10 unchanged lines hidden (view full) --- 7864 * page at boot. 7865 */ 7866 if (found > count) 7867 goto unmovable; 7868 } 7869 return false; 7870unmovable: 7871 WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE); | 7845 continue; 7846 7847 if (__PageMovable(page)) 7848 continue; 7849 7850 if (!PageLRU(page)) 7851 found++; 7852 /* --- 10 unchanged lines hidden (view full) --- 7863 * page at boot. 7864 */ 7865 if (found > count) 7866 goto unmovable; 7867 } 7868 return false; 7869unmovable: 7870 WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE); |
7872 dump_page(pfn_to_page(pfn+iter), "unmovable page"); | 7871 if (flags & REPORT_FAILURE) 7872 dump_page(pfn_to_page(pfn+iter), "unmovable page"); |
7873 return true; 7874} 7875 7876#if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA) 7877 7878static unsigned long pfn_max_align_down(unsigned long pfn) 7879{ 7880 return pfn & ~(max_t(unsigned long, MAX_ORDER_NR_PAGES, --- 110 unchanged lines hidden (view full) --- 7991 * 7992 * This lets us mark the pageblocks back as 7993 * MIGRATE_CMA/MIGRATE_MOVABLE so that free pages in the 7994 * aligned range but not in the unaligned, original range are 7995 * put back to page allocator so that buddy can use them. 7996 */ 7997 7998 ret = start_isolate_page_range(pfn_max_align_down(start), | 7873 return true; 7874} 7875 7876#if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA) 7877 7878static unsigned long pfn_max_align_down(unsigned long pfn) 7879{ 7880 return pfn & ~(max_t(unsigned long, MAX_ORDER_NR_PAGES, --- 110 unchanged lines hidden (view full) --- 7991 * 7992 * This lets us mark the pageblocks back as 7993 * MIGRATE_CMA/MIGRATE_MOVABLE so that free pages in the 7994 * aligned range but not in the unaligned, original range are 7995 * put back to page allocator so that buddy can use them. 7996 */ 7997 7998 ret = start_isolate_page_range(pfn_max_align_down(start), |
7999 pfn_max_align_up(end), migratetype, 8000 false); | 7999 pfn_max_align_up(end), migratetype, 0); |
8001 if (ret) 8002 return ret; 8003 8004 /* 8005 * In case of -EBUSY, we'd like to know which page causes problem. 8006 * So, just fall through. test_pages_isolated() has a tracepoint 8007 * which will report the busy page. 8008 * --- 234 unchanged lines hidden --- | 8000 if (ret) 8001 return ret; 8002 8003 /* 8004 * In case of -EBUSY, we'd like to know which page causes problem. 8005 * So, just fall through. test_pages_isolated() has a tracepoint 8006 * which will report the busy page. 8007 * --- 234 unchanged lines hidden --- |