page_isolation.c (c1144d29f405ce1f4e6ede6482beb3d0d09750c6) | page_isolation.c (d381c54760dcfad23743da40516e7e003d73952a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/mm/page_isolation.c 4 */ 5 6#include <linux/mm.h> 7#include <linux/page-isolation.h> 8#include <linux/pageblock-flags.h> 9#include <linux/memory.h> 10#include <linux/hugetlb.h> 11#include <linux/page_owner.h> 12#include <linux/migrate.h> 13#include "internal.h" 14 15#define CREATE_TRACE_POINTS 16#include <trace/events/page_isolation.h> 17 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/mm/page_isolation.c 4 */ 5 6#include <linux/mm.h> 7#include <linux/page-isolation.h> 8#include <linux/pageblock-flags.h> 9#include <linux/memory.h> 10#include <linux/hugetlb.h> 11#include <linux/page_owner.h> 12#include <linux/migrate.h> 13#include "internal.h" 14 15#define CREATE_TRACE_POINTS 16#include <trace/events/page_isolation.h> 17 |
18static int set_migratetype_isolate(struct page *page, int migratetype, 19 bool skip_hwpoisoned_pages) | 18static int set_migratetype_isolate(struct page *page, int migratetype, int isol_flags) |
20{ 21 struct zone *zone; 22 unsigned long flags, pfn; 23 struct memory_isolate_notify arg; 24 int notifier_ret; 25 int ret = -EBUSY; 26 27 zone = page_zone(page); --- 27 unchanged lines hidden (view full) --- 55 notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg); 56 notifier_ret = notifier_to_errno(notifier_ret); 57 if (notifier_ret) 58 goto out; 59 /* 60 * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. 61 * We just check MOVABLE pages. 62 */ | 19{ 20 struct zone *zone; 21 unsigned long flags, pfn; 22 struct memory_isolate_notify arg; 23 int notifier_ret; 24 int ret = -EBUSY; 25 26 zone = page_zone(page); --- 27 unchanged lines hidden (view full) --- 54 notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg); 55 notifier_ret = notifier_to_errno(notifier_ret); 56 if (notifier_ret) 57 goto out; 58 /* 59 * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. 60 * We just check MOVABLE pages. 61 */ |
63 if (!has_unmovable_pages(zone, page, arg.pages_found, migratetype, 64 skip_hwpoisoned_pages)) | 62 if (!has_unmovable_pages(zone, page, arg.pages_found, migratetype, flags)) |
65 ret = 0; 66 67 /* 68 * immobile means "not-on-lru" pages. If immobile is larger than 69 * removable-by-driver pages reported by notifier, we'll fail. 70 */ 71 72out: --- 107 unchanged lines hidden (view full) --- 180 * from trying to isolate overlapping ranges. If this happens, one thread 181 * will notice pageblocks in the overlapping range already set to isolate. 182 * This happens in set_migratetype_isolate, and set_migratetype_isolate 183 * returns an error. We then clean up by restoring the migration type on 184 * pageblocks we may have modified and return -EBUSY to caller. This 185 * prevents two threads from simultaneously working on overlapping ranges. 186 */ 187int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, | 63 ret = 0; 64 65 /* 66 * immobile means "not-on-lru" pages. If immobile is larger than 67 * removable-by-driver pages reported by notifier, we'll fail. 68 */ 69 70out: --- 107 unchanged lines hidden (view full) --- 178 * from trying to isolate overlapping ranges. If this happens, one thread 179 * will notice pageblocks in the overlapping range already set to isolate. 180 * This happens in set_migratetype_isolate, and set_migratetype_isolate 181 * returns an error. We then clean up by restoring the migration type on 182 * pageblocks we may have modified and return -EBUSY to caller. This 183 * prevents two threads from simultaneously working on overlapping ranges. 184 */ 185int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, |
188 unsigned migratetype, bool skip_hwpoisoned_pages) | 186 unsigned migratetype, int flags) |
189{ 190 unsigned long pfn; 191 unsigned long undo_pfn; 192 struct page *page; 193 194 BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages)); 195 BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages)); 196 197 for (pfn = start_pfn; 198 pfn < end_pfn; 199 pfn += pageblock_nr_pages) { 200 page = __first_valid_page(pfn, pageblock_nr_pages); 201 if (page && | 187{ 188 unsigned long pfn; 189 unsigned long undo_pfn; 190 struct page *page; 191 192 BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages)); 193 BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages)); 194 195 for (pfn = start_pfn; 196 pfn < end_pfn; 197 pfn += pageblock_nr_pages) { 198 page = __first_valid_page(pfn, pageblock_nr_pages); 199 if (page && |
202 set_migratetype_isolate(page, migratetype, skip_hwpoisoned_pages)) { | 200 set_migratetype_isolate(page, migratetype, flags)) { |
203 undo_pfn = pfn; 204 goto undo; 205 } 206 } 207 return 0; 208undo: 209 for (pfn = start_pfn; 210 pfn < undo_pfn; --- 105 unchanged lines hidden --- | 201 undo_pfn = pfn; 202 goto undo; 203 } 204 } 205 return 0; 206undo: 207 for (pfn = start_pfn; 208 pfn < undo_pfn; --- 105 unchanged lines hidden --- |