page_isolation.c (faa3d77749ad30d2e1c48e2e4363b9c4889aca27) | page_isolation.c (ee6f509c3274014d1f52e7a7a10aee9f85393c5e) |
---|---|
1/* 2 * linux/mm/page_isolation.c 3 */ 4 5#include <linux/mm.h> 6#include <linux/page-isolation.h> 7#include <linux/pageblock-flags.h> | 1/* 2 * linux/mm/page_isolation.c 3 */ 4 5#include <linux/mm.h> 6#include <linux/page-isolation.h> 7#include <linux/pageblock-flags.h> |
8#include <linux/memory.h> |
|
8#include "internal.h" 9 | 9#include "internal.h" 10 |
11int set_migratetype_isolate(struct page *page) 12{ 13 struct zone *zone; 14 unsigned long flags, pfn; 15 struct memory_isolate_notify arg; 16 int notifier_ret; 17 int ret = -EBUSY; 18 19 zone = page_zone(page); 20 21 spin_lock_irqsave(&zone->lock, flags); 22 23 pfn = page_to_pfn(page); 24 arg.start_pfn = pfn; 25 arg.nr_pages = pageblock_nr_pages; 26 arg.pages_found = 0; 27 28 /* 29 * It may be possible to isolate a pageblock even if the 30 * migratetype is not MIGRATE_MOVABLE. The memory isolation 31 * notifier chain is used by balloon drivers to return the 32 * number of pages in a range that are held by the balloon 33 * driver to shrink memory. If all the pages are accounted for 34 * by balloons, are free, or on the LRU, isolation can continue. 35 * Later, for example, when memory hotplug notifier runs, these 36 * pages reported as "can be isolated" should be isolated(freed) 37 * by the balloon driver through the memory notifier chain. 38 */ 39 notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg); 40 notifier_ret = notifier_to_errno(notifier_ret); 41 if (notifier_ret) 42 goto out; 43 /* 44 * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. 45 * We just check MOVABLE pages. 46 */ 47 if (!has_unmovable_pages(zone, page, arg.pages_found)) 48 ret = 0; 49 50 /* 51 * immobile means "not-on-lru" paes. If immobile is larger than 52 * removable-by-driver pages reported by notifier, we'll fail. 53 */ 54 55out: 56 if (!ret) { 57 set_pageblock_migratetype(page, MIGRATE_ISOLATE); 58 move_freepages_block(zone, page, MIGRATE_ISOLATE); 59 } 60 61 spin_unlock_irqrestore(&zone->lock, flags); 62 if (!ret) 63 drain_all_pages(); 64 return ret; 65} 66 67void unset_migratetype_isolate(struct page *page, unsigned migratetype) 68{ 69 struct zone *zone; 70 unsigned long flags; 71 zone = page_zone(page); 72 spin_lock_irqsave(&zone->lock, flags); 73 if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE) 74 goto out; 75 set_pageblock_migratetype(page, migratetype); 76 move_freepages_block(zone, page, migratetype); 77out: 78 spin_unlock_irqrestore(&zone->lock, flags); 79} 80 |
|
10static inline struct page * 11__first_valid_page(unsigned long pfn, unsigned long nr_pages) 12{ 13 int i; 14 for (i = 0; i < nr_pages; i++) 15 if (pfn_valid_within(pfn + i)) 16 break; 17 if (unlikely(i == nr_pages)) --- 125 unchanged lines hidden --- | 81static inline struct page * 82__first_valid_page(unsigned long pfn, unsigned long nr_pages) 83{ 84 int i; 85 for (i = 0; i < nr_pages; i++) 86 if (pfn_valid_within(pfn + i)) 87 break; 88 if (unlikely(i == nr_pages)) --- 125 unchanged lines hidden --- |