diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /mm/page_alloc.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 527 |
1 files changed, 350 insertions, 177 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2bc2ac63f41e..d03c946d5566 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -48,7 +48,9 @@ | |||
48 | #include <linux/page_cgroup.h> | 48 | #include <linux/page_cgroup.h> |
49 | #include <linux/debugobjects.h> | 49 | #include <linux/debugobjects.h> |
50 | #include <linux/kmemleak.h> | 50 | #include <linux/kmemleak.h> |
51 | #include <linux/memory.h> | ||
51 | #include <trace/events/kmem.h> | 52 | #include <trace/events/kmem.h> |
53 | #include <linux/ftrace_event.h> | ||
52 | 54 | ||
53 | #include <asm/tlbflush.h> | 55 | #include <asm/tlbflush.h> |
54 | #include <asm/div64.h> | 56 | #include <asm/div64.h> |
@@ -75,6 +77,31 @@ unsigned long totalreserve_pages __read_mostly; | |||
75 | int percpu_pagelist_fraction; | 77 | int percpu_pagelist_fraction; |
76 | gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; | 78 | gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; |
77 | 79 | ||
80 | #ifdef CONFIG_PM_SLEEP | ||
81 | /* | ||
82 | * The following functions are used by the suspend/hibernate code to temporarily | ||
83 | * change gfp_allowed_mask in order to avoid using I/O during memory allocations | ||
84 | * while devices are suspended. To avoid races with the suspend/hibernate code, | ||
85 | * they should always be called with pm_mutex held (gfp_allowed_mask also should | ||
86 | * only be modified with pm_mutex held, unless the suspend/hibernate code is | ||
87 | * guaranteed not to run in parallel with that modification). | ||
88 | */ | ||
89 | void set_gfp_allowed_mask(gfp_t mask) | ||
90 | { | ||
91 | WARN_ON(!mutex_is_locked(&pm_mutex)); | ||
92 | gfp_allowed_mask = mask; | ||
93 | } | ||
94 | |||
95 | gfp_t clear_gfp_allowed_mask(gfp_t mask) | ||
96 | { | ||
97 | gfp_t ret = gfp_allowed_mask; | ||
98 | |||
99 | WARN_ON(!mutex_is_locked(&pm_mutex)); | ||
100 | gfp_allowed_mask &= ~mask; | ||
101 | return ret; | ||
102 | } | ||
103 | #endif /* CONFIG_PM_SLEEP */ | ||
104 | |||
78 | #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE | 105 | #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE |
79 | int pageblock_order __read_mostly; | 106 | int pageblock_order __read_mostly; |
80 | #endif | 107 | #endif |
@@ -262,10 +289,7 @@ static void bad_page(struct page *page) | |||
262 | 289 | ||
263 | printk(KERN_ALERT "BUG: Bad page state in process %s pfn:%05lx\n", | 290 | printk(KERN_ALERT "BUG: Bad page state in process %s pfn:%05lx\n", |
264 | current->comm, page_to_pfn(page)); | 291 | current->comm, page_to_pfn(page)); |
265 | printk(KERN_ALERT | 292 | dump_page(page); |
266 | "page:%p flags:%p count:%d mapcount:%d mapping:%p index:%lx\n", | ||
267 | page, (void *)page->flags, page_count(page), | ||
268 | page_mapcount(page), page->mapping, page->index); | ||
269 | 293 | ||
270 | dump_stack(); | 294 | dump_stack(); |
271 | out: | 295 | out: |
@@ -486,7 +510,6 @@ static inline void __free_one_page(struct page *page, | |||
486 | zone->free_area[order].nr_free++; | 510 | zone->free_area[order].nr_free++; |
487 | } | 511 | } |
488 | 512 | ||
489 | #ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT | ||
490 | /* | 513 | /* |
491 | * free_page_mlock() -- clean up attempts to free and mlocked() page. | 514 | * free_page_mlock() -- clean up attempts to free and mlocked() page. |
492 | * Page should not be on lru, so no need to fix that up. | 515 | * Page should not be on lru, so no need to fix that up. |
@@ -497,9 +520,6 @@ static inline void free_page_mlock(struct page *page) | |||
497 | __dec_zone_page_state(page, NR_MLOCK); | 520 | __dec_zone_page_state(page, NR_MLOCK); |
498 | __count_vm_event(UNEVICTABLE_MLOCKFREED); | 521 | __count_vm_event(UNEVICTABLE_MLOCKFREED); |
499 | } | 522 | } |
500 | #else | ||
501 | static void free_page_mlock(struct page *page) { } | ||
502 | #endif | ||
503 | 523 | ||
504 | static inline int free_pages_check(struct page *page) | 524 | static inline int free_pages_check(struct page *page) |
505 | { | 525 | { |
@@ -533,7 +553,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, | |||
533 | int batch_free = 0; | 553 | int batch_free = 0; |
534 | 554 | ||
535 | spin_lock(&zone->lock); | 555 | spin_lock(&zone->lock); |
536 | zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE); | 556 | zone->all_unreclaimable = 0; |
537 | zone->pages_scanned = 0; | 557 | zone->pages_scanned = 0; |
538 | 558 | ||
539 | __mod_zone_page_state(zone, NR_FREE_PAGES, count); | 559 | __mod_zone_page_state(zone, NR_FREE_PAGES, count); |
@@ -559,8 +579,9 @@ static void free_pcppages_bulk(struct zone *zone, int count, | |||
559 | page = list_entry(list->prev, struct page, lru); | 579 | page = list_entry(list->prev, struct page, lru); |
560 | /* must delete as __free_one_page list manipulates */ | 580 | /* must delete as __free_one_page list manipulates */ |
561 | list_del(&page->lru); | 581 | list_del(&page->lru); |
562 | __free_one_page(page, zone, 0, migratetype); | 582 | /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ |
563 | trace_mm_page_pcpu_drain(page, 0, migratetype); | 583 | __free_one_page(page, zone, 0, page_private(page)); |
584 | trace_mm_page_pcpu_drain(page, 0, page_private(page)); | ||
564 | } while (--count && --batch_free && !list_empty(list)); | 585 | } while (--count && --batch_free && !list_empty(list)); |
565 | } | 586 | } |
566 | spin_unlock(&zone->lock); | 587 | spin_unlock(&zone->lock); |
@@ -570,7 +591,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order, | |||
570 | int migratetype) | 591 | int migratetype) |
571 | { | 592 | { |
572 | spin_lock(&zone->lock); | 593 | spin_lock(&zone->lock); |
573 | zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE); | 594 | zone->all_unreclaimable = 0; |
574 | zone->pages_scanned = 0; | 595 | zone->pages_scanned = 0; |
575 | 596 | ||
576 | __mod_zone_page_state(zone, NR_FREE_PAGES, 1 << order); | 597 | __mod_zone_page_state(zone, NR_FREE_PAGES, 1 << order); |
@@ -585,6 +606,7 @@ static void __free_pages_ok(struct page *page, unsigned int order) | |||
585 | int bad = 0; | 606 | int bad = 0; |
586 | int wasMlocked = __TestClearPageMlocked(page); | 607 | int wasMlocked = __TestClearPageMlocked(page); |
587 | 608 | ||
609 | trace_mm_page_free_direct(page, order); | ||
588 | kmemcheck_free_shadow(page, order); | 610 | kmemcheck_free_shadow(page, order); |
589 | 611 | ||
590 | for (i = 0 ; i < (1 << order) ; ++i) | 612 | for (i = 0 ; i < (1 << order) ; ++i) |
@@ -1011,10 +1033,10 @@ static void drain_pages(unsigned int cpu) | |||
1011 | struct per_cpu_pageset *pset; | 1033 | struct per_cpu_pageset *pset; |
1012 | struct per_cpu_pages *pcp; | 1034 | struct per_cpu_pages *pcp; |
1013 | 1035 | ||
1014 | pset = zone_pcp(zone, cpu); | 1036 | local_irq_save(flags); |
1037 | pset = per_cpu_ptr(zone->pageset, cpu); | ||
1015 | 1038 | ||
1016 | pcp = &pset->pcp; | 1039 | pcp = &pset->pcp; |
1017 | local_irq_save(flags); | ||
1018 | free_pcppages_bulk(zone, pcp->count, pcp); | 1040 | free_pcppages_bulk(zone, pcp->count, pcp); |
1019 | pcp->count = 0; | 1041 | pcp->count = 0; |
1020 | local_irq_restore(flags); | 1042 | local_irq_restore(flags); |
@@ -1075,8 +1097,9 @@ void mark_free_pages(struct zone *zone) | |||
1075 | 1097 | ||
1076 | /* | 1098 | /* |
1077 | * Free a 0-order page | 1099 | * Free a 0-order page |
1100 | * cold == 1 ? free a cold page : free a hot page | ||
1078 | */ | 1101 | */ |
1079 | static void free_hot_cold_page(struct page *page, int cold) | 1102 | void free_hot_cold_page(struct page *page, int cold) |
1080 | { | 1103 | { |
1081 | struct zone *zone = page_zone(page); | 1104 | struct zone *zone = page_zone(page); |
1082 | struct per_cpu_pages *pcp; | 1105 | struct per_cpu_pages *pcp; |
@@ -1084,6 +1107,7 @@ static void free_hot_cold_page(struct page *page, int cold) | |||
1084 | int migratetype; | 1107 | int migratetype; |
1085 | int wasMlocked = __TestClearPageMlocked(page); | 1108 | int wasMlocked = __TestClearPageMlocked(page); |
1086 | 1109 | ||
1110 | trace_mm_page_free_direct(page, 0); | ||
1087 | kmemcheck_free_shadow(page, 0); | 1111 | kmemcheck_free_shadow(page, 0); |
1088 | 1112 | ||
1089 | if (PageAnon(page)) | 1113 | if (PageAnon(page)) |
@@ -1098,7 +1122,6 @@ static void free_hot_cold_page(struct page *page, int cold) | |||
1098 | arch_free_page(page, 0); | 1122 | arch_free_page(page, 0); |
1099 | kernel_map_pages(page, 1, 0); | 1123 | kernel_map_pages(page, 1, 0); |
1100 | 1124 | ||
1101 | pcp = &zone_pcp(zone, get_cpu())->pcp; | ||
1102 | migratetype = get_pageblock_migratetype(page); | 1125 | migratetype = get_pageblock_migratetype(page); |
1103 | set_page_private(page, migratetype); | 1126 | set_page_private(page, migratetype); |
1104 | local_irq_save(flags); | 1127 | local_irq_save(flags); |
@@ -1121,6 +1144,7 @@ static void free_hot_cold_page(struct page *page, int cold) | |||
1121 | migratetype = MIGRATE_MOVABLE; | 1144 | migratetype = MIGRATE_MOVABLE; |
1122 | } | 1145 | } |
1123 | 1146 | ||
1147 | pcp = &this_cpu_ptr(zone->pageset)->pcp; | ||
1124 | if (cold) | 1148 | if (cold) |
1125 | list_add_tail(&page->lru, &pcp->lists[migratetype]); | 1149 | list_add_tail(&page->lru, &pcp->lists[migratetype]); |
1126 | else | 1150 | else |
@@ -1133,15 +1157,8 @@ static void free_hot_cold_page(struct page *page, int cold) | |||
1133 | 1157 | ||
1134 | out: | 1158 | out: |
1135 | local_irq_restore(flags); | 1159 | local_irq_restore(flags); |
1136 | put_cpu(); | ||
1137 | } | 1160 | } |
1138 | 1161 | ||
1139 | void free_hot_page(struct page *page) | ||
1140 | { | ||
1141 | trace_mm_page_free_direct(page, 0); | ||
1142 | free_hot_cold_page(page, 0); | ||
1143 | } | ||
1144 | |||
1145 | /* | 1162 | /* |
1146 | * split_page takes a non-compound higher-order page, and splits it into | 1163 | * split_page takes a non-compound higher-order page, and splits it into |
1147 | * n (1<<order) sub-pages: page[0..n] | 1164 | * n (1<<order) sub-pages: page[0..n] |
@@ -1183,17 +1200,15 @@ struct page *buffered_rmqueue(struct zone *preferred_zone, | |||
1183 | unsigned long flags; | 1200 | unsigned long flags; |
1184 | struct page *page; | 1201 | struct page *page; |
1185 | int cold = !!(gfp_flags & __GFP_COLD); | 1202 | int cold = !!(gfp_flags & __GFP_COLD); |
1186 | int cpu; | ||
1187 | 1203 | ||
1188 | again: | 1204 | again: |
1189 | cpu = get_cpu(); | ||
1190 | if (likely(order == 0)) { | 1205 | if (likely(order == 0)) { |
1191 | struct per_cpu_pages *pcp; | 1206 | struct per_cpu_pages *pcp; |
1192 | struct list_head *list; | 1207 | struct list_head *list; |
1193 | 1208 | ||
1194 | pcp = &zone_pcp(zone, cpu)->pcp; | ||
1195 | list = &pcp->lists[migratetype]; | ||
1196 | local_irq_save(flags); | 1209 | local_irq_save(flags); |
1210 | pcp = &this_cpu_ptr(zone->pageset)->pcp; | ||
1211 | list = &pcp->lists[migratetype]; | ||
1197 | if (list_empty(list)) { | 1212 | if (list_empty(list)) { |
1198 | pcp->count += rmqueue_bulk(zone, 0, | 1213 | pcp->count += rmqueue_bulk(zone, 0, |
1199 | pcp->batch, list, | 1214 | pcp->batch, list, |
@@ -1225,16 +1240,15 @@ again: | |||
1225 | } | 1240 | } |
1226 | spin_lock_irqsave(&zone->lock, flags); | 1241 | spin_lock_irqsave(&zone->lock, flags); |
1227 | page = __rmqueue(zone, order, migratetype); | 1242 | page = __rmqueue(zone, order, migratetype); |
1228 | __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); | ||
1229 | spin_unlock(&zone->lock); | 1243 | spin_unlock(&zone->lock); |
1230 | if (!page) | 1244 | if (!page) |
1231 | goto failed; | 1245 | goto failed; |
1246 | __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); | ||
1232 | } | 1247 | } |
1233 | 1248 | ||
1234 | __count_zone_vm_events(PGALLOC, zone, 1 << order); | 1249 | __count_zone_vm_events(PGALLOC, zone, 1 << order); |
1235 | zone_statistics(preferred_zone, zone); | 1250 | zone_statistics(preferred_zone, zone); |
1236 | local_irq_restore(flags); | 1251 | local_irq_restore(flags); |
1237 | put_cpu(); | ||
1238 | 1252 | ||
1239 | VM_BUG_ON(bad_range(zone, page)); | 1253 | VM_BUG_ON(bad_range(zone, page)); |
1240 | if (prep_new_page(page, order, gfp_flags)) | 1254 | if (prep_new_page(page, order, gfp_flags)) |
@@ -1243,7 +1257,6 @@ again: | |||
1243 | 1257 | ||
1244 | failed: | 1258 | failed: |
1245 | local_irq_restore(flags); | 1259 | local_irq_restore(flags); |
1246 | put_cpu(); | ||
1247 | return NULL; | 1260 | return NULL; |
1248 | } | 1261 | } |
1249 | 1262 | ||
@@ -1658,12 +1671,22 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, | |||
1658 | if (page) | 1671 | if (page) |
1659 | goto out; | 1672 | goto out; |
1660 | 1673 | ||
1661 | /* The OOM killer will not help higher order allocs */ | 1674 | if (!(gfp_mask & __GFP_NOFAIL)) { |
1662 | if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_NOFAIL)) | 1675 | /* The OOM killer will not help higher order allocs */ |
1663 | goto out; | 1676 | if (order > PAGE_ALLOC_COSTLY_ORDER) |
1664 | 1677 | goto out; | |
1678 | /* | ||
1679 | * GFP_THISNODE contains __GFP_NORETRY and we never hit this. | ||
1680 | * Sanity check for bare calls of __GFP_THISNODE, not real OOM. | ||
1681 | * The caller should handle page allocation failure by itself if | ||
1682 | * it specifies __GFP_THISNODE. | ||
1683 | * Note: Hugepage uses it but will hit PAGE_ALLOC_COSTLY_ORDER. | ||
1684 | */ | ||
1685 | if (gfp_mask & __GFP_THISNODE) | ||
1686 | goto out; | ||
1687 | } | ||
1665 | /* Exhausted what can be done so it's blamo time */ | 1688 | /* Exhausted what can be done so it's blamo time */ |
1666 | out_of_memory(zonelist, gfp_mask, order); | 1689 | out_of_memory(zonelist, gfp_mask, order, nodemask); |
1667 | 1690 | ||
1668 | out: | 1691 | out: |
1669 | clear_zonelist_oom(zonelist, gfp_mask); | 1692 | clear_zonelist_oom(zonelist, gfp_mask); |
@@ -2005,9 +2028,8 @@ void __pagevec_free(struct pagevec *pvec) | |||
2005 | void __free_pages(struct page *page, unsigned int order) | 2028 | void __free_pages(struct page *page, unsigned int order) |
2006 | { | 2029 | { |
2007 | if (put_page_testzero(page)) { | 2030 | if (put_page_testzero(page)) { |
2008 | trace_mm_page_free_direct(page, order); | ||
2009 | if (order == 0) | 2031 | if (order == 0) |
2010 | free_hot_page(page); | 2032 | free_hot_cold_page(page, 0); |
2011 | else | 2033 | else |
2012 | __free_pages_ok(page, order); | 2034 | __free_pages_ok(page, order); |
2013 | } | 2035 | } |
@@ -2172,7 +2194,7 @@ void show_free_areas(void) | |||
2172 | for_each_online_cpu(cpu) { | 2194 | for_each_online_cpu(cpu) { |
2173 | struct per_cpu_pageset *pageset; | 2195 | struct per_cpu_pageset *pageset; |
2174 | 2196 | ||
2175 | pageset = zone_pcp(zone, cpu); | 2197 | pageset = per_cpu_ptr(zone->pageset, cpu); |
2176 | 2198 | ||
2177 | printk("CPU %4d: hi:%5d, btch:%4d usd:%4d\n", | 2199 | printk("CPU %4d: hi:%5d, btch:%4d usd:%4d\n", |
2178 | cpu, pageset->pcp.high, | 2200 | cpu, pageset->pcp.high, |
@@ -2263,7 +2285,7 @@ void show_free_areas(void) | |||
2263 | K(zone_page_state(zone, NR_BOUNCE)), | 2285 | K(zone_page_state(zone, NR_BOUNCE)), |
2264 | K(zone_page_state(zone, NR_WRITEBACK_TEMP)), | 2286 | K(zone_page_state(zone, NR_WRITEBACK_TEMP)), |
2265 | zone->pages_scanned, | 2287 | zone->pages_scanned, |
2266 | (zone_is_all_unreclaimable(zone) ? "yes" : "no") | 2288 | (zone->all_unreclaimable ? "yes" : "no") |
2267 | ); | 2289 | ); |
2268 | printk("lowmem_reserve[]:"); | 2290 | printk("lowmem_reserve[]:"); |
2269 | for (i = 0; i < MAX_NR_ZONES; i++) | 2291 | for (i = 0; i < MAX_NR_ZONES; i++) |
@@ -2395,13 +2417,14 @@ int numa_zonelist_order_handler(ctl_table *table, int write, | |||
2395 | { | 2417 | { |
2396 | char saved_string[NUMA_ZONELIST_ORDER_LEN]; | 2418 | char saved_string[NUMA_ZONELIST_ORDER_LEN]; |
2397 | int ret; | 2419 | int ret; |
2420 | static DEFINE_MUTEX(zl_order_mutex); | ||
2398 | 2421 | ||
2422 | mutex_lock(&zl_order_mutex); | ||
2399 | if (write) | 2423 | if (write) |
2400 | strncpy(saved_string, (char*)table->data, | 2424 | strcpy(saved_string, (char*)table->data); |
2401 | NUMA_ZONELIST_ORDER_LEN); | ||
2402 | ret = proc_dostring(table, write, buffer, length, ppos); | 2425 | ret = proc_dostring(table, write, buffer, length, ppos); |
2403 | if (ret) | 2426 | if (ret) |
2404 | return ret; | 2427 | goto out; |
2405 | if (write) { | 2428 | if (write) { |
2406 | int oldval = user_zonelist_order; | 2429 | int oldval = user_zonelist_order; |
2407 | if (__parse_numa_zonelist_order((char*)table->data)) { | 2430 | if (__parse_numa_zonelist_order((char*)table->data)) { |
@@ -2414,7 +2437,9 @@ int numa_zonelist_order_handler(ctl_table *table, int write, | |||
2414 | } else if (oldval != user_zonelist_order) | 2437 | } else if (oldval != user_zonelist_order) |
2415 | build_all_zonelists(); | 2438 | build_all_zonelists(); |
2416 | } | 2439 | } |
2417 | return 0; | 2440 | out: |
2441 | mutex_unlock(&zl_order_mutex); | ||
2442 | return ret; | ||
2418 | } | 2443 | } |
2419 | 2444 | ||
2420 | 2445 | ||
@@ -2734,10 +2759,29 @@ static void build_zonelist_cache(pg_data_t *pgdat) | |||
2734 | 2759 | ||
2735 | #endif /* CONFIG_NUMA */ | 2760 | #endif /* CONFIG_NUMA */ |
2736 | 2761 | ||
2762 | /* | ||
2763 | * Boot pageset table. One per cpu which is going to be used for all | ||
2764 | * zones and all nodes. The parameters will be set in such a way | ||
2765 | * that an item put on a list will immediately be handed over to | ||
2766 | * the buddy list. This is safe since pageset manipulation is done | ||
2767 | * with interrupts disabled. | ||
2768 | * | ||
2769 | * The boot_pagesets must be kept even after bootup is complete for | ||
2770 | * unused processors and/or zones. They do play a role for bootstrapping | ||
2771 | * hotplugged processors. | ||
2772 | * | ||
2773 | * zoneinfo_show() and maybe other functions do | ||
2774 | * not check if the processor is online before following the pageset pointer. | ||
2775 | * Other parts of the kernel may not check if the zone is available. | ||
2776 | */ | ||
2777 | static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch); | ||
2778 | static DEFINE_PER_CPU(struct per_cpu_pageset, boot_pageset); | ||
2779 | |||
2737 | /* return values int ....just for stop_machine() */ | 2780 | /* return values int ....just for stop_machine() */ |
2738 | static int __build_all_zonelists(void *dummy) | 2781 | static int __build_all_zonelists(void *dummy) |
2739 | { | 2782 | { |
2740 | int nid; | 2783 | int nid; |
2784 | int cpu; | ||
2741 | 2785 | ||
2742 | #ifdef CONFIG_NUMA | 2786 | #ifdef CONFIG_NUMA |
2743 | memset(node_load, 0, sizeof(node_load)); | 2787 | memset(node_load, 0, sizeof(node_load)); |
@@ -2748,6 +2792,23 @@ static int __build_all_zonelists(void *dummy) | |||
2748 | build_zonelists(pgdat); | 2792 | build_zonelists(pgdat); |
2749 | build_zonelist_cache(pgdat); | 2793 | build_zonelist_cache(pgdat); |
2750 | } | 2794 | } |
2795 | |||
2796 | /* | ||
2797 | * Initialize the boot_pagesets that are going to be used | ||
2798 | * for bootstrapping processors. The real pagesets for | ||
2799 | * each zone will be allocated later when the per cpu | ||
2800 | * allocator is available. | ||
2801 | * | ||
2802 | * boot_pagesets are used also for bootstrapping offline | ||
2803 | * cpus if the system is already booted because the pagesets | ||
2804 | * are needed to initialize allocators on a specific cpu too. | ||
2805 | * F.e. the percpu allocator needs the page allocator which | ||
2806 | * needs the percpu allocator in order to allocate its pagesets | ||
2807 | * (a chicken-egg dilemma). | ||
2808 | */ | ||
2809 | for_each_possible_cpu(cpu) | ||
2810 | setup_pageset(&per_cpu(boot_pageset, cpu), 0); | ||
2811 | |||
2751 | return 0; | 2812 | return 0; |
2752 | } | 2813 | } |
2753 | 2814 | ||
@@ -3085,121 +3146,33 @@ static void setup_pagelist_highmark(struct per_cpu_pageset *p, | |||
3085 | pcp->batch = PAGE_SHIFT * 8; | 3146 | pcp->batch = PAGE_SHIFT * 8; |
3086 | } | 3147 | } |
3087 | 3148 | ||
3088 | |||
3089 | #ifdef CONFIG_NUMA | ||
3090 | /* | ||
3091 | * Boot pageset table. One per cpu which is going to be used for all | ||
3092 | * zones and all nodes. The parameters will be set in such a way | ||
3093 | * that an item put on a list will immediately be handed over to | ||
3094 | * the buddy list. This is safe since pageset manipulation is done | ||
3095 | * with interrupts disabled. | ||
3096 | * | ||
3097 | * Some NUMA counter updates may also be caught by the boot pagesets. | ||
3098 | * | ||
3099 | * The boot_pagesets must be kept even after bootup is complete for | ||
3100 | * unused processors and/or zones. They do play a role for bootstrapping | ||
3101 | * hotplugged processors. | ||
3102 | * | ||
3103 | * zoneinfo_show() and maybe other functions do | ||
3104 | * not check if the processor is online before following the pageset pointer. | ||
3105 | * Other parts of the kernel may not check if the zone is available. | ||
3106 | */ | ||
3107 | static struct per_cpu_pageset boot_pageset[NR_CPUS]; | ||
3108 | |||
3109 | /* | 3149 | /* |
3110 | * Dynamically allocate memory for the | 3150 | * Allocate per cpu pagesets and initialize them. |
3111 | * per cpu pageset array in struct zone. | 3151 | * Before this call only boot pagesets were available. |
3152 | * Boot pagesets will no longer be used by this processorr | ||
3153 | * after setup_per_cpu_pageset(). | ||
3112 | */ | 3154 | */ |
3113 | static int __cpuinit process_zones(int cpu) | 3155 | void __init setup_per_cpu_pageset(void) |
3114 | { | 3156 | { |
3115 | struct zone *zone, *dzone; | 3157 | struct zone *zone; |
3116 | int node = cpu_to_node(cpu); | 3158 | int cpu; |
3117 | |||
3118 | node_set_state(node, N_CPU); /* this node has a cpu */ | ||
3119 | 3159 | ||
3120 | for_each_populated_zone(zone) { | 3160 | for_each_populated_zone(zone) { |
3121 | zone_pcp(zone, cpu) = kmalloc_node(sizeof(struct per_cpu_pageset), | 3161 | zone->pageset = alloc_percpu(struct per_cpu_pageset); |
3122 | GFP_KERNEL, node); | ||
3123 | if (!zone_pcp(zone, cpu)) | ||
3124 | goto bad; | ||
3125 | 3162 | ||
3126 | setup_pageset(zone_pcp(zone, cpu), zone_batchsize(zone)); | 3163 | for_each_possible_cpu(cpu) { |
3164 | struct per_cpu_pageset *pcp = per_cpu_ptr(zone->pageset, cpu); | ||
3127 | 3165 | ||
3128 | if (percpu_pagelist_fraction) | 3166 | setup_pageset(pcp, zone_batchsize(zone)); |
3129 | setup_pagelist_highmark(zone_pcp(zone, cpu), | ||
3130 | (zone->present_pages / percpu_pagelist_fraction)); | ||
3131 | } | ||
3132 | 3167 | ||
3133 | return 0; | 3168 | if (percpu_pagelist_fraction) |
3134 | bad: | 3169 | setup_pagelist_highmark(pcp, |
3135 | for_each_zone(dzone) { | 3170 | (zone->present_pages / |
3136 | if (!populated_zone(dzone)) | 3171 | percpu_pagelist_fraction)); |
3137 | continue; | 3172 | } |
3138 | if (dzone == zone) | ||
3139 | break; | ||
3140 | kfree(zone_pcp(dzone, cpu)); | ||
3141 | zone_pcp(dzone, cpu) = &boot_pageset[cpu]; | ||
3142 | } | ||
3143 | return -ENOMEM; | ||
3144 | } | ||
3145 | |||
3146 | static inline void free_zone_pagesets(int cpu) | ||
3147 | { | ||
3148 | struct zone *zone; | ||
3149 | |||
3150 | for_each_zone(zone) { | ||
3151 | struct per_cpu_pageset *pset = zone_pcp(zone, cpu); | ||
3152 | |||
3153 | /* Free per_cpu_pageset if it is slab allocated */ | ||
3154 | if (pset != &boot_pageset[cpu]) | ||
3155 | kfree(pset); | ||
3156 | zone_pcp(zone, cpu) = &boot_pageset[cpu]; | ||
3157 | } | ||
3158 | } | ||
3159 | |||
3160 | static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb, | ||
3161 | unsigned long action, | ||
3162 | void *hcpu) | ||
3163 | { | ||
3164 | int cpu = (long)hcpu; | ||
3165 | int ret = NOTIFY_OK; | ||
3166 | |||
3167 | switch (action) { | ||
3168 | case CPU_UP_PREPARE: | ||
3169 | case CPU_UP_PREPARE_FROZEN: | ||
3170 | if (process_zones(cpu)) | ||
3171 | ret = NOTIFY_BAD; | ||
3172 | break; | ||
3173 | case CPU_UP_CANCELED: | ||
3174 | case CPU_UP_CANCELED_FROZEN: | ||
3175 | case CPU_DEAD: | ||
3176 | case CPU_DEAD_FROZEN: | ||
3177 | free_zone_pagesets(cpu); | ||
3178 | break; | ||
3179 | default: | ||
3180 | break; | ||
3181 | } | 3173 | } |
3182 | return ret; | ||
3183 | } | 3174 | } |
3184 | 3175 | ||
3185 | static struct notifier_block __cpuinitdata pageset_notifier = | ||
3186 | { &pageset_cpuup_callback, NULL, 0 }; | ||
3187 | |||
3188 | void __init setup_per_cpu_pageset(void) | ||
3189 | { | ||
3190 | int err; | ||
3191 | |||
3192 | /* Initialize per_cpu_pageset for cpu 0. | ||
3193 | * A cpuup callback will do this for every cpu | ||
3194 | * as it comes online | ||
3195 | */ | ||
3196 | err = process_zones(smp_processor_id()); | ||
3197 | BUG_ON(err); | ||
3198 | register_cpu_notifier(&pageset_notifier); | ||
3199 | } | ||
3200 | |||
3201 | #endif | ||
3202 | |||
3203 | static noinline __init_refok | 3176 | static noinline __init_refok |
3204 | int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages) | 3177 | int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages) |
3205 | { | 3178 | { |
@@ -3249,11 +3222,11 @@ static int __zone_pcp_update(void *data) | |||
3249 | int cpu; | 3222 | int cpu; |
3250 | unsigned long batch = zone_batchsize(zone), flags; | 3223 | unsigned long batch = zone_batchsize(zone), flags; |
3251 | 3224 | ||
3252 | for (cpu = 0; cpu < NR_CPUS; cpu++) { | 3225 | for_each_possible_cpu(cpu) { |
3253 | struct per_cpu_pageset *pset; | 3226 | struct per_cpu_pageset *pset; |
3254 | struct per_cpu_pages *pcp; | 3227 | struct per_cpu_pages *pcp; |
3255 | 3228 | ||
3256 | pset = zone_pcp(zone, cpu); | 3229 | pset = per_cpu_ptr(zone->pageset, cpu); |
3257 | pcp = &pset->pcp; | 3230 | pcp = &pset->pcp; |
3258 | 3231 | ||
3259 | local_irq_save(flags); | 3232 | local_irq_save(flags); |
@@ -3271,21 +3244,17 @@ void zone_pcp_update(struct zone *zone) | |||
3271 | 3244 | ||
3272 | static __meminit void zone_pcp_init(struct zone *zone) | 3245 | static __meminit void zone_pcp_init(struct zone *zone) |
3273 | { | 3246 | { |
3274 | int cpu; | 3247 | /* |
3275 | unsigned long batch = zone_batchsize(zone); | 3248 | * per cpu subsystem is not up at this point. The following code |
3249 | * relies on the ability of the linker to provide the | ||
3250 | * offset of a (static) per cpu variable into the per cpu area. | ||
3251 | */ | ||
3252 | zone->pageset = &boot_pageset; | ||
3276 | 3253 | ||
3277 | for (cpu = 0; cpu < NR_CPUS; cpu++) { | ||
3278 | #ifdef CONFIG_NUMA | ||
3279 | /* Early boot. Slab allocator not functional yet */ | ||
3280 | zone_pcp(zone, cpu) = &boot_pageset[cpu]; | ||
3281 | setup_pageset(&boot_pageset[cpu],0); | ||
3282 | #else | ||
3283 | setup_pageset(zone_pcp(zone,cpu), batch); | ||
3284 | #endif | ||
3285 | } | ||
3286 | if (zone->present_pages) | 3254 | if (zone->present_pages) |
3287 | printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n", | 3255 | printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%u\n", |
3288 | zone->name, zone->present_pages, batch); | 3256 | zone->name, zone->present_pages, |
3257 | zone_batchsize(zone)); | ||
3289 | } | 3258 | } |
3290 | 3259 | ||
3291 | __meminit int init_currently_empty_zone(struct zone *zone, | 3260 | __meminit int init_currently_empty_zone(struct zone *zone, |
@@ -3424,6 +3393,61 @@ void __init free_bootmem_with_active_regions(int nid, | |||
3424 | } | 3393 | } |
3425 | } | 3394 | } |
3426 | 3395 | ||
3396 | int __init add_from_early_node_map(struct range *range, int az, | ||
3397 | int nr_range, int nid) | ||
3398 | { | ||
3399 | int i; | ||
3400 | u64 start, end; | ||
3401 | |||
3402 | /* need to go over early_node_map to find out good range for node */ | ||
3403 | for_each_active_range_index_in_nid(i, nid) { | ||
3404 | start = early_node_map[i].start_pfn; | ||
3405 | end = early_node_map[i].end_pfn; | ||
3406 | nr_range = add_range(range, az, nr_range, start, end); | ||
3407 | } | ||
3408 | return nr_range; | ||
3409 | } | ||
3410 | |||
3411 | #ifdef CONFIG_NO_BOOTMEM | ||
3412 | void * __init __alloc_memory_core_early(int nid, u64 size, u64 align, | ||
3413 | u64 goal, u64 limit) | ||
3414 | { | ||
3415 | int i; | ||
3416 | void *ptr; | ||
3417 | |||
3418 | /* need to go over early_node_map to find out good range for node */ | ||
3419 | for_each_active_range_index_in_nid(i, nid) { | ||
3420 | u64 addr; | ||
3421 | u64 ei_start, ei_last; | ||
3422 | |||
3423 | ei_last = early_node_map[i].end_pfn; | ||
3424 | ei_last <<= PAGE_SHIFT; | ||
3425 | ei_start = early_node_map[i].start_pfn; | ||
3426 | ei_start <<= PAGE_SHIFT; | ||
3427 | addr = find_early_area(ei_start, ei_last, | ||
3428 | goal, limit, size, align); | ||
3429 | |||
3430 | if (addr == -1ULL) | ||
3431 | continue; | ||
3432 | |||
3433 | #if 0 | ||
3434 | printk(KERN_DEBUG "alloc (nid=%d %llx - %llx) (%llx - %llx) %llx %llx => %llx\n", | ||
3435 | nid, | ||
3436 | ei_start, ei_last, goal, limit, size, | ||
3437 | align, addr); | ||
3438 | #endif | ||
3439 | |||
3440 | ptr = phys_to_virt(addr); | ||
3441 | memset(ptr, 0, size); | ||
3442 | reserve_early_without_check(addr, addr + size, "BOOTMEM"); | ||
3443 | return ptr; | ||
3444 | } | ||
3445 | |||
3446 | return NULL; | ||
3447 | } | ||
3448 | #endif | ||
3449 | |||
3450 | |||
3427 | void __init work_with_active_regions(int nid, work_fn_t work_fn, void *data) | 3451 | void __init work_with_active_regions(int nid, work_fn_t work_fn, void *data) |
3428 | { | 3452 | { |
3429 | int i; | 3453 | int i; |
@@ -3573,7 +3597,7 @@ static unsigned long __meminit zone_spanned_pages_in_node(int nid, | |||
3573 | * Return the number of holes in a range on a node. If nid is MAX_NUMNODES, | 3597 | * Return the number of holes in a range on a node. If nid is MAX_NUMNODES, |
3574 | * then all holes in the requested range will be accounted for. | 3598 | * then all holes in the requested range will be accounted for. |
3575 | */ | 3599 | */ |
3576 | static unsigned long __meminit __absent_pages_in_range(int nid, | 3600 | unsigned long __meminit __absent_pages_in_range(int nid, |
3577 | unsigned long range_start_pfn, | 3601 | unsigned long range_start_pfn, |
3578 | unsigned long range_end_pfn) | 3602 | unsigned long range_end_pfn) |
3579 | { | 3603 | { |
@@ -3988,7 +4012,7 @@ void __init add_active_range(unsigned int nid, unsigned long start_pfn, | |||
3988 | } | 4012 | } |
3989 | 4013 | ||
3990 | /* Merge backward if suitable */ | 4014 | /* Merge backward if suitable */ |
3991 | if (start_pfn < early_node_map[i].end_pfn && | 4015 | if (start_pfn < early_node_map[i].start_pfn && |
3992 | end_pfn >= early_node_map[i].start_pfn) { | 4016 | end_pfn >= early_node_map[i].start_pfn) { |
3993 | early_node_map[i].start_pfn = start_pfn; | 4017 | early_node_map[i].start_pfn = start_pfn; |
3994 | return; | 4018 | return; |
@@ -4102,7 +4126,7 @@ static int __init cmp_node_active_region(const void *a, const void *b) | |||
4102 | } | 4126 | } |
4103 | 4127 | ||
4104 | /* sort the node_map by start_pfn */ | 4128 | /* sort the node_map by start_pfn */ |
4105 | static void __init sort_node_map(void) | 4129 | void __init sort_node_map(void) |
4106 | { | 4130 | { |
4107 | sort(early_node_map, (size_t)nr_nodemap_entries, | 4131 | sort(early_node_map, (size_t)nr_nodemap_entries, |
4108 | sizeof(struct node_active_region), | 4132 | sizeof(struct node_active_region), |
@@ -4366,8 +4390,12 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn) | |||
4366 | for (i = 0; i < MAX_NR_ZONES; i++) { | 4390 | for (i = 0; i < MAX_NR_ZONES; i++) { |
4367 | if (i == ZONE_MOVABLE) | 4391 | if (i == ZONE_MOVABLE) |
4368 | continue; | 4392 | continue; |
4369 | printk(" %-8s %0#10lx -> %0#10lx\n", | 4393 | printk(" %-8s ", zone_names[i]); |
4370 | zone_names[i], | 4394 | if (arch_zone_lowest_possible_pfn[i] == |
4395 | arch_zone_highest_possible_pfn[i]) | ||
4396 | printk("empty\n"); | ||
4397 | else | ||
4398 | printk("%0#10lx -> %0#10lx\n", | ||
4371 | arch_zone_lowest_possible_pfn[i], | 4399 | arch_zone_lowest_possible_pfn[i], |
4372 | arch_zone_highest_possible_pfn[i]); | 4400 | arch_zone_highest_possible_pfn[i]); |
4373 | } | 4401 | } |
@@ -4456,7 +4484,11 @@ void __init set_dma_reserve(unsigned long new_dma_reserve) | |||
4456 | } | 4484 | } |
4457 | 4485 | ||
4458 | #ifndef CONFIG_NEED_MULTIPLE_NODES | 4486 | #ifndef CONFIG_NEED_MULTIPLE_NODES |
4459 | struct pglist_data __refdata contig_page_data = { .bdata = &bootmem_node_data[0] }; | 4487 | struct pglist_data __refdata contig_page_data = { |
4488 | #ifndef CONFIG_NO_BOOTMEM | ||
4489 | .bdata = &bootmem_node_data[0] | ||
4490 | #endif | ||
4491 | }; | ||
4460 | EXPORT_SYMBOL(contig_page_data); | 4492 | EXPORT_SYMBOL(contig_page_data); |
4461 | #endif | 4493 | #endif |
4462 | 4494 | ||
@@ -4799,10 +4831,11 @@ int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write, | |||
4799 | if (!write || (ret == -EINVAL)) | 4831 | if (!write || (ret == -EINVAL)) |
4800 | return ret; | 4832 | return ret; |
4801 | for_each_populated_zone(zone) { | 4833 | for_each_populated_zone(zone) { |
4802 | for_each_online_cpu(cpu) { | 4834 | for_each_possible_cpu(cpu) { |
4803 | unsigned long high; | 4835 | unsigned long high; |
4804 | high = zone->present_pages / percpu_pagelist_fraction; | 4836 | high = zone->present_pages / percpu_pagelist_fraction; |
4805 | setup_pagelist_highmark(zone_pcp(zone, cpu), high); | 4837 | setup_pagelist_highmark( |
4838 | per_cpu_ptr(zone->pageset, cpu), high); | ||
4806 | } | 4839 | } |
4807 | } | 4840 | } |
4808 | return 0; | 4841 | return 0; |
@@ -5002,23 +5035,65 @@ void set_pageblock_flags_group(struct page *page, unsigned long flags, | |||
5002 | int set_migratetype_isolate(struct page *page) | 5035 | int set_migratetype_isolate(struct page *page) |
5003 | { | 5036 | { |
5004 | struct zone *zone; | 5037 | struct zone *zone; |
5005 | unsigned long flags; | 5038 | struct page *curr_page; |
5039 | unsigned long flags, pfn, iter; | ||
5040 | unsigned long immobile = 0; | ||
5041 | struct memory_isolate_notify arg; | ||
5042 | int notifier_ret; | ||
5006 | int ret = -EBUSY; | 5043 | int ret = -EBUSY; |
5007 | int zone_idx; | 5044 | int zone_idx; |
5008 | 5045 | ||
5009 | zone = page_zone(page); | 5046 | zone = page_zone(page); |
5010 | zone_idx = zone_idx(zone); | 5047 | zone_idx = zone_idx(zone); |
5048 | |||
5011 | spin_lock_irqsave(&zone->lock, flags); | 5049 | spin_lock_irqsave(&zone->lock, flags); |
5050 | if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE || | ||
5051 | zone_idx == ZONE_MOVABLE) { | ||
5052 | ret = 0; | ||
5053 | goto out; | ||
5054 | } | ||
5055 | |||
5056 | pfn = page_to_pfn(page); | ||
5057 | arg.start_pfn = pfn; | ||
5058 | arg.nr_pages = pageblock_nr_pages; | ||
5059 | arg.pages_found = 0; | ||
5060 | |||
5012 | /* | 5061 | /* |
5013 | * In future, more migrate types will be able to be isolation target. | 5062 | * It may be possible to isolate a pageblock even if the |
5063 | * migratetype is not MIGRATE_MOVABLE. The memory isolation | ||
5064 | * notifier chain is used by balloon drivers to return the | ||
5065 | * number of pages in a range that are held by the balloon | ||
5066 | * driver to shrink memory. If all the pages are accounted for | ||
5067 | * by balloons, are free, or on the LRU, isolation can continue. | ||
5068 | * Later, for example, when memory hotplug notifier runs, these | ||
5069 | * pages reported as "can be isolated" should be isolated(freed) | ||
5070 | * by the balloon driver through the memory notifier chain. | ||
5014 | */ | 5071 | */ |
5015 | if (get_pageblock_migratetype(page) != MIGRATE_MOVABLE && | 5072 | notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg); |
5016 | zone_idx != ZONE_MOVABLE) | 5073 | notifier_ret = notifier_to_errno(notifier_ret); |
5074 | if (notifier_ret || !arg.pages_found) | ||
5017 | goto out; | 5075 | goto out; |
5018 | set_pageblock_migratetype(page, MIGRATE_ISOLATE); | 5076 | |
5019 | move_freepages_block(zone, page, MIGRATE_ISOLATE); | 5077 | for (iter = pfn; iter < (pfn + pageblock_nr_pages); iter++) { |
5020 | ret = 0; | 5078 | if (!pfn_valid_within(pfn)) |
5079 | continue; | ||
5080 | |||
5081 | curr_page = pfn_to_page(iter); | ||
5082 | if (!page_count(curr_page) || PageLRU(curr_page)) | ||
5083 | continue; | ||
5084 | |||
5085 | immobile++; | ||
5086 | } | ||
5087 | |||
5088 | if (arg.pages_found == immobile) | ||
5089 | ret = 0; | ||
5090 | |||
5021 | out: | 5091 | out: |
5092 | if (!ret) { | ||
5093 | set_pageblock_migratetype(page, MIGRATE_ISOLATE); | ||
5094 | move_freepages_block(zone, page, MIGRATE_ISOLATE); | ||
5095 | } | ||
5096 | |||
5022 | spin_unlock_irqrestore(&zone->lock, flags); | 5097 | spin_unlock_irqrestore(&zone->lock, flags); |
5023 | if (!ret) | 5098 | if (!ret) |
5024 | drain_all_pages(); | 5099 | drain_all_pages(); |
@@ -5085,3 +5160,101 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) | |||
5085 | spin_unlock_irqrestore(&zone->lock, flags); | 5160 | spin_unlock_irqrestore(&zone->lock, flags); |
5086 | } | 5161 | } |
5087 | #endif | 5162 | #endif |
5163 | |||
5164 | #ifdef CONFIG_MEMORY_FAILURE | ||
5165 | bool is_free_buddy_page(struct page *page) | ||
5166 | { | ||
5167 | struct zone *zone = page_zone(page); | ||
5168 | unsigned long pfn = page_to_pfn(page); | ||
5169 | unsigned long flags; | ||
5170 | int order; | ||
5171 | |||
5172 | spin_lock_irqsave(&zone->lock, flags); | ||
5173 | for (order = 0; order < MAX_ORDER; order++) { | ||
5174 | struct page *page_head = page - (pfn & ((1 << order) - 1)); | ||
5175 | |||
5176 | if (PageBuddy(page_head) && page_order(page_head) >= order) | ||
5177 | break; | ||
5178 | } | ||
5179 | spin_unlock_irqrestore(&zone->lock, flags); | ||
5180 | |||
5181 | return order < MAX_ORDER; | ||
5182 | } | ||
5183 | #endif | ||
5184 | |||
5185 | static struct trace_print_flags pageflag_names[] = { | ||
5186 | {1UL << PG_locked, "locked" }, | ||
5187 | {1UL << PG_error, "error" }, | ||
5188 | {1UL << PG_referenced, "referenced" }, | ||
5189 | {1UL << PG_uptodate, "uptodate" }, | ||
5190 | {1UL << PG_dirty, "dirty" }, | ||
5191 | {1UL << PG_lru, "lru" }, | ||
5192 | {1UL << PG_active, "active" }, | ||
5193 | {1UL << PG_slab, "slab" }, | ||
5194 | {1UL << PG_owner_priv_1, "owner_priv_1" }, | ||
5195 | {1UL << PG_arch_1, "arch_1" }, | ||
5196 | {1UL << PG_reserved, "reserved" }, | ||
5197 | {1UL << PG_private, "private" }, | ||
5198 | {1UL << PG_private_2, "private_2" }, | ||
5199 | {1UL << PG_writeback, "writeback" }, | ||
5200 | #ifdef CONFIG_PAGEFLAGS_EXTENDED | ||
5201 | {1UL << PG_head, "head" }, | ||
5202 | {1UL << PG_tail, "tail" }, | ||
5203 | #else | ||
5204 | {1UL << PG_compound, "compound" }, | ||
5205 | #endif | ||
5206 | {1UL << PG_swapcache, "swapcache" }, | ||
5207 | {1UL << PG_mappedtodisk, "mappedtodisk" }, | ||
5208 | {1UL << PG_reclaim, "reclaim" }, | ||
5209 | {1UL << PG_buddy, "buddy" }, | ||
5210 | {1UL << PG_swapbacked, "swapbacked" }, | ||
5211 | {1UL << PG_unevictable, "unevictable" }, | ||
5212 | #ifdef CONFIG_MMU | ||
5213 | {1UL << PG_mlocked, "mlocked" }, | ||
5214 | #endif | ||
5215 | #ifdef CONFIG_ARCH_USES_PG_UNCACHED | ||
5216 | {1UL << PG_uncached, "uncached" }, | ||
5217 | #endif | ||
5218 | #ifdef CONFIG_MEMORY_FAILURE | ||
5219 | {1UL << PG_hwpoison, "hwpoison" }, | ||
5220 | #endif | ||
5221 | {-1UL, NULL }, | ||
5222 | }; | ||
5223 | |||
5224 | static void dump_page_flags(unsigned long flags) | ||
5225 | { | ||
5226 | const char *delim = ""; | ||
5227 | unsigned long mask; | ||
5228 | int i; | ||
5229 | |||
5230 | printk(KERN_ALERT "page flags: %#lx(", flags); | ||
5231 | |||
5232 | /* remove zone id */ | ||
5233 | flags &= (1UL << NR_PAGEFLAGS) - 1; | ||
5234 | |||
5235 | for (i = 0; pageflag_names[i].name && flags; i++) { | ||
5236 | |||
5237 | mask = pageflag_names[i].mask; | ||
5238 | if ((flags & mask) != mask) | ||
5239 | continue; | ||
5240 | |||
5241 | flags &= ~mask; | ||
5242 | printk("%s%s", delim, pageflag_names[i].name); | ||
5243 | delim = "|"; | ||
5244 | } | ||
5245 | |||
5246 | /* check for left over flags */ | ||
5247 | if (flags) | ||
5248 | printk("%s%#lx", delim, flags); | ||
5249 | |||
5250 | printk(")\n"); | ||
5251 | } | ||
5252 | |||
5253 | void dump_page(struct page *page) | ||
5254 | { | ||
5255 | printk(KERN_ALERT | ||
5256 | "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n", | ||
5257 | page, page_count(page), page_mapcount(page), | ||
5258 | page->mapping, page->index); | ||
5259 | dump_page_flags(page->flags); | ||
5260 | } | ||