aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c284
1 files changed, 200 insertions, 84 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a0de15f46987..5717f27a0704 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -48,6 +48,7 @@
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 <trace/events/kmem.h>
51 52
52#include <asm/tlbflush.h> 53#include <asm/tlbflush.h>
53#include <asm/div64.h> 54#include <asm/div64.h>
@@ -71,7 +72,6 @@ EXPORT_SYMBOL(node_states);
71 72
72unsigned long totalram_pages __read_mostly; 73unsigned long totalram_pages __read_mostly;
73unsigned long totalreserve_pages __read_mostly; 74unsigned long totalreserve_pages __read_mostly;
74unsigned long highest_memmap_pfn __read_mostly;
75int percpu_pagelist_fraction; 75int percpu_pagelist_fraction;
76gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; 76gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK;
77 77
@@ -123,8 +123,8 @@ static char * const zone_names[MAX_NR_ZONES] = {
123 123
124int min_free_kbytes = 1024; 124int min_free_kbytes = 1024;
125 125
126unsigned long __meminitdata nr_kernel_pages; 126static unsigned long __meminitdata nr_kernel_pages;
127unsigned long __meminitdata nr_all_pages; 127static unsigned long __meminitdata nr_all_pages;
128static unsigned long __meminitdata dma_reserve; 128static unsigned long __meminitdata dma_reserve;
129 129
130#ifdef CONFIG_ARCH_POPULATES_NODE_MAP 130#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
@@ -510,7 +510,7 @@ static inline int free_pages_check(struct page *page)
510} 510}
511 511
512/* 512/*
513 * Frees a list of pages. 513 * Frees a number of pages from the PCP lists
514 * Assumes all pages on list are in same zone, and of same order. 514 * Assumes all pages on list are in same zone, and of same order.
515 * count is the number of pages to free. 515 * count is the number of pages to free.
516 * 516 *
@@ -520,22 +520,42 @@ static inline int free_pages_check(struct page *page)
520 * And clear the zone's pages_scanned counter, to hold off the "all pages are 520 * And clear the zone's pages_scanned counter, to hold off the "all pages are
521 * pinned" detection logic. 521 * pinned" detection logic.
522 */ 522 */
523static void free_pages_bulk(struct zone *zone, int count, 523static void free_pcppages_bulk(struct zone *zone, int count,
524 struct list_head *list, int order) 524 struct per_cpu_pages *pcp)
525{ 525{
526 int migratetype = 0;
527 int batch_free = 0;
528
526 spin_lock(&zone->lock); 529 spin_lock(&zone->lock);
527 zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE); 530 zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE);
528 zone->pages_scanned = 0; 531 zone->pages_scanned = 0;
529 532
530 __mod_zone_page_state(zone, NR_FREE_PAGES, count << order); 533 __mod_zone_page_state(zone, NR_FREE_PAGES, count);
531 while (count--) { 534 while (count) {
532 struct page *page; 535 struct page *page;
536 struct list_head *list;
533 537
534 VM_BUG_ON(list_empty(list)); 538 /*
535 page = list_entry(list->prev, struct page, lru); 539 * Remove pages from lists in a round-robin fashion. A
536 /* have to delete it as __free_one_page list manipulates */ 540 * batch_free count is maintained that is incremented when an
537 list_del(&page->lru); 541 * empty list is encountered. This is so more pages are freed
538 __free_one_page(page, zone, order, page_private(page)); 542 * off fuller lists instead of spinning excessively around empty
543 * lists
544 */
545 do {
546 batch_free++;
547 if (++migratetype == MIGRATE_PCPTYPES)
548 migratetype = 0;
549 list = &pcp->lists[migratetype];
550 } while (list_empty(list));
551
552 do {
553 page = list_entry(list->prev, struct page, lru);
554 /* must delete as __free_one_page list manipulates */
555 list_del(&page->lru);
556 __free_one_page(page, zone, 0, migratetype);
557 trace_mm_page_pcpu_drain(page, 0, migratetype);
558 } while (--count && --batch_free && !list_empty(list));
539 } 559 }
540 spin_unlock(&zone->lock); 560 spin_unlock(&zone->lock);
541} 561}
@@ -557,7 +577,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
557 unsigned long flags; 577 unsigned long flags;
558 int i; 578 int i;
559 int bad = 0; 579 int bad = 0;
560 int wasMlocked = TestClearPageMlocked(page); 580 int wasMlocked = __TestClearPageMlocked(page);
561 581
562 kmemcheck_free_shadow(page, order); 582 kmemcheck_free_shadow(page, order);
563 583
@@ -783,6 +803,17 @@ static int move_freepages_block(struct zone *zone, struct page *page,
783 return move_freepages(zone, start_page, end_page, migratetype); 803 return move_freepages(zone, start_page, end_page, migratetype);
784} 804}
785 805
806static void change_pageblock_range(struct page *pageblock_page,
807 int start_order, int migratetype)
808{
809 int nr_pageblocks = 1 << (start_order - pageblock_order);
810
811 while (nr_pageblocks--) {
812 set_pageblock_migratetype(pageblock_page, migratetype);
813 pageblock_page += pageblock_nr_pages;
814 }
815}
816
786/* Remove an element from the buddy allocator from the fallback list */ 817/* Remove an element from the buddy allocator from the fallback list */
787static inline struct page * 818static inline struct page *
788__rmqueue_fallback(struct zone *zone, int order, int start_migratetype) 819__rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
@@ -836,11 +867,16 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
836 list_del(&page->lru); 867 list_del(&page->lru);
837 rmv_page_order(page); 868 rmv_page_order(page);
838 869
839 if (current_order == pageblock_order) 870 /* Take ownership for orders >= pageblock_order */
840 set_pageblock_migratetype(page, 871 if (current_order >= pageblock_order)
872 change_pageblock_range(page, current_order,
841 start_migratetype); 873 start_migratetype);
842 874
843 expand(zone, page, order, current_order, area, migratetype); 875 expand(zone, page, order, current_order, area, migratetype);
876
877 trace_mm_page_alloc_extfrag(page, order, current_order,
878 start_migratetype, migratetype);
879
844 return page; 880 return page;
845 } 881 }
846 } 882 }
@@ -874,6 +910,7 @@ retry_reserve:
874 } 910 }
875 } 911 }
876 912
913 trace_mm_page_alloc_zone_locked(page, order, migratetype);
877 return page; 914 return page;
878} 915}
879 916
@@ -934,7 +971,7 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
934 to_drain = pcp->batch; 971 to_drain = pcp->batch;
935 else 972 else
936 to_drain = pcp->count; 973 to_drain = pcp->count;
937 free_pages_bulk(zone, to_drain, &pcp->list, 0); 974 free_pcppages_bulk(zone, to_drain, pcp);
938 pcp->count -= to_drain; 975 pcp->count -= to_drain;
939 local_irq_restore(flags); 976 local_irq_restore(flags);
940} 977}
@@ -960,7 +997,7 @@ static void drain_pages(unsigned int cpu)
960 997
961 pcp = &pset->pcp; 998 pcp = &pset->pcp;
962 local_irq_save(flags); 999 local_irq_save(flags);
963 free_pages_bulk(zone, pcp->count, &pcp->list, 0); 1000 free_pcppages_bulk(zone, pcp->count, pcp);
964 pcp->count = 0; 1001 pcp->count = 0;
965 local_irq_restore(flags); 1002 local_irq_restore(flags);
966 } 1003 }
@@ -1026,7 +1063,8 @@ static void free_hot_cold_page(struct page *page, int cold)
1026 struct zone *zone = page_zone(page); 1063 struct zone *zone = page_zone(page);
1027 struct per_cpu_pages *pcp; 1064 struct per_cpu_pages *pcp;
1028 unsigned long flags; 1065 unsigned long flags;
1029 int wasMlocked = TestClearPageMlocked(page); 1066 int migratetype;
1067 int wasMlocked = __TestClearPageMlocked(page);
1030 1068
1031 kmemcheck_free_shadow(page, 0); 1069 kmemcheck_free_shadow(page, 0);
1032 1070
@@ -1043,35 +1081,49 @@ static void free_hot_cold_page(struct page *page, int cold)
1043 kernel_map_pages(page, 1, 0); 1081 kernel_map_pages(page, 1, 0);
1044 1082
1045 pcp = &zone_pcp(zone, get_cpu())->pcp; 1083 pcp = &zone_pcp(zone, get_cpu())->pcp;
1046 set_page_private(page, get_pageblock_migratetype(page)); 1084 migratetype = get_pageblock_migratetype(page);
1085 set_page_private(page, migratetype);
1047 local_irq_save(flags); 1086 local_irq_save(flags);
1048 if (unlikely(wasMlocked)) 1087 if (unlikely(wasMlocked))
1049 free_page_mlock(page); 1088 free_page_mlock(page);
1050 __count_vm_event(PGFREE); 1089 __count_vm_event(PGFREE);
1051 1090
1091 /*
1092 * We only track unmovable, reclaimable and movable on pcp lists.
1093 * Free ISOLATE pages back to the allocator because they are being
1094 * offlined but treat RESERVE as movable pages so we can get those
1095 * areas back if necessary. Otherwise, we may have to free
1096 * excessively into the page allocator
1097 */
1098 if (migratetype >= MIGRATE_PCPTYPES) {
1099 if (unlikely(migratetype == MIGRATE_ISOLATE)) {
1100 free_one_page(zone, page, 0, migratetype);
1101 goto out;
1102 }
1103 migratetype = MIGRATE_MOVABLE;
1104 }
1105
1052 if (cold) 1106 if (cold)
1053 list_add_tail(&page->lru, &pcp->list); 1107 list_add_tail(&page->lru, &pcp->lists[migratetype]);
1054 else 1108 else
1055 list_add(&page->lru, &pcp->list); 1109 list_add(&page->lru, &pcp->lists[migratetype]);
1056 pcp->count++; 1110 pcp->count++;
1057 if (pcp->count >= pcp->high) { 1111 if (pcp->count >= pcp->high) {
1058 free_pages_bulk(zone, pcp->batch, &pcp->list, 0); 1112 free_pcppages_bulk(zone, pcp->batch, pcp);
1059 pcp->count -= pcp->batch; 1113 pcp->count -= pcp->batch;
1060 } 1114 }
1115
1116out:
1061 local_irq_restore(flags); 1117 local_irq_restore(flags);
1062 put_cpu(); 1118 put_cpu();
1063} 1119}
1064 1120
1065void free_hot_page(struct page *page) 1121void free_hot_page(struct page *page)
1066{ 1122{
1123 trace_mm_page_free_direct(page, 0);
1067 free_hot_cold_page(page, 0); 1124 free_hot_cold_page(page, 0);
1068} 1125}
1069 1126
1070void free_cold_page(struct page *page)
1071{
1072 free_hot_cold_page(page, 1);
1073}
1074
1075/* 1127/*
1076 * split_page takes a non-compound higher-order page, and splits it into 1128 * split_page takes a non-compound higher-order page, and splits it into
1077 * n (1<<order) sub-pages: page[0..n] 1129 * n (1<<order) sub-pages: page[0..n]
@@ -1119,35 +1171,23 @@ again:
1119 cpu = get_cpu(); 1171 cpu = get_cpu();
1120 if (likely(order == 0)) { 1172 if (likely(order == 0)) {
1121 struct per_cpu_pages *pcp; 1173 struct per_cpu_pages *pcp;
1174 struct list_head *list;
1122 1175
1123 pcp = &zone_pcp(zone, cpu)->pcp; 1176 pcp = &zone_pcp(zone, cpu)->pcp;
1177 list = &pcp->lists[migratetype];
1124 local_irq_save(flags); 1178 local_irq_save(flags);
1125 if (!pcp->count) { 1179 if (list_empty(list)) {
1126 pcp->count = rmqueue_bulk(zone, 0, 1180 pcp->count += rmqueue_bulk(zone, 0,
1127 pcp->batch, &pcp->list, 1181 pcp->batch, list,
1128 migratetype, cold); 1182 migratetype, cold);
1129 if (unlikely(!pcp->count)) 1183 if (unlikely(list_empty(list)))
1130 goto failed; 1184 goto failed;
1131 } 1185 }
1132 1186
1133 /* Find a page of the appropriate migrate type */ 1187 if (cold)
1134 if (cold) { 1188 page = list_entry(list->prev, struct page, lru);
1135 list_for_each_entry_reverse(page, &pcp->list, lru) 1189 else
1136 if (page_private(page) == migratetype) 1190 page = list_entry(list->next, struct page, lru);
1137 break;
1138 } else {
1139 list_for_each_entry(page, &pcp->list, lru)
1140 if (page_private(page) == migratetype)
1141 break;
1142 }
1143
1144 /* Allocate more to the pcp list if necessary */
1145 if (unlikely(&page->lru == &pcp->list)) {
1146 pcp->count += rmqueue_bulk(zone, 0,
1147 pcp->batch, &pcp->list,
1148 migratetype, cold);
1149 page = list_entry(pcp->list.next, struct page, lru);
1150 }
1151 1191
1152 list_del(&page->lru); 1192 list_del(&page->lru);
1153 pcp->count--; 1193 pcp->count--;
@@ -1627,10 +1667,6 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
1627 1667
1628 /* We now go into synchronous reclaim */ 1668 /* We now go into synchronous reclaim */
1629 cpuset_memory_pressure_bump(); 1669 cpuset_memory_pressure_bump();
1630
1631 /*
1632 * The task's cpuset might have expanded its set of allowable nodes
1633 */
1634 p->flags |= PF_MEMALLOC; 1670 p->flags |= PF_MEMALLOC;
1635 lockdep_set_current_reclaim_state(gfp_mask); 1671 lockdep_set_current_reclaim_state(gfp_mask);
1636 reclaim_state.reclaimed_slab = 0; 1672 reclaim_state.reclaimed_slab = 0;
@@ -1765,6 +1801,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
1765 1801
1766 wake_all_kswapd(order, zonelist, high_zoneidx); 1802 wake_all_kswapd(order, zonelist, high_zoneidx);
1767 1803
1804restart:
1768 /* 1805 /*
1769 * OK, we're below the kswapd watermark and have kicked background 1806 * OK, we're below the kswapd watermark and have kicked background
1770 * reclaim. Now things get more complex, so set up alloc_flags according 1807 * reclaim. Now things get more complex, so set up alloc_flags according
@@ -1772,7 +1809,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
1772 */ 1809 */
1773 alloc_flags = gfp_to_alloc_flags(gfp_mask); 1810 alloc_flags = gfp_to_alloc_flags(gfp_mask);
1774 1811
1775restart:
1776 /* This is the last chance, in general, before the goto nopage. */ 1812 /* This is the last chance, in general, before the goto nopage. */
1777 page = get_page_from_freelist(gfp_mask, nodemask, order, zonelist, 1813 page = get_page_from_freelist(gfp_mask, nodemask, order, zonelist,
1778 high_zoneidx, alloc_flags & ~ALLOC_NO_WATERMARKS, 1814 high_zoneidx, alloc_flags & ~ALLOC_NO_WATERMARKS,
@@ -1907,6 +1943,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
1907 zonelist, high_zoneidx, nodemask, 1943 zonelist, high_zoneidx, nodemask,
1908 preferred_zone, migratetype); 1944 preferred_zone, migratetype);
1909 1945
1946 trace_mm_page_alloc(page, order, gfp_mask, migratetype);
1910 return page; 1947 return page;
1911} 1948}
1912EXPORT_SYMBOL(__alloc_pages_nodemask); 1949EXPORT_SYMBOL(__alloc_pages_nodemask);
@@ -1916,44 +1953,41 @@ EXPORT_SYMBOL(__alloc_pages_nodemask);
1916 */ 1953 */
1917unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) 1954unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
1918{ 1955{
1919 struct page * page; 1956 struct page *page;
1957
1958 /*
1959 * __get_free_pages() returns a 32-bit address, which cannot represent
1960 * a highmem page
1961 */
1962 VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0);
1963
1920 page = alloc_pages(gfp_mask, order); 1964 page = alloc_pages(gfp_mask, order);
1921 if (!page) 1965 if (!page)
1922 return 0; 1966 return 0;
1923 return (unsigned long) page_address(page); 1967 return (unsigned long) page_address(page);
1924} 1968}
1925
1926EXPORT_SYMBOL(__get_free_pages); 1969EXPORT_SYMBOL(__get_free_pages);
1927 1970
1928unsigned long get_zeroed_page(gfp_t gfp_mask) 1971unsigned long get_zeroed_page(gfp_t gfp_mask)
1929{ 1972{
1930 struct page * page; 1973 return __get_free_pages(gfp_mask | __GFP_ZERO, 0);
1931
1932 /*
1933 * get_zeroed_page() returns a 32-bit address, which cannot represent
1934 * a highmem page
1935 */
1936 VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0);
1937
1938 page = alloc_pages(gfp_mask | __GFP_ZERO, 0);
1939 if (page)
1940 return (unsigned long) page_address(page);
1941 return 0;
1942} 1974}
1943
1944EXPORT_SYMBOL(get_zeroed_page); 1975EXPORT_SYMBOL(get_zeroed_page);
1945 1976
1946void __pagevec_free(struct pagevec *pvec) 1977void __pagevec_free(struct pagevec *pvec)
1947{ 1978{
1948 int i = pagevec_count(pvec); 1979 int i = pagevec_count(pvec);
1949 1980
1950 while (--i >= 0) 1981 while (--i >= 0) {
1982 trace_mm_pagevec_free(pvec->pages[i], pvec->cold);
1951 free_hot_cold_page(pvec->pages[i], pvec->cold); 1983 free_hot_cold_page(pvec->pages[i], pvec->cold);
1984 }
1952} 1985}
1953 1986
1954void __free_pages(struct page *page, unsigned int order) 1987void __free_pages(struct page *page, unsigned int order)
1955{ 1988{
1956 if (put_page_testzero(page)) { 1989 if (put_page_testzero(page)) {
1990 trace_mm_page_free_direct(page, order);
1957 if (order == 0) 1991 if (order == 0)
1958 free_hot_page(page); 1992 free_hot_page(page);
1959 else 1993 else
@@ -2128,23 +2162,28 @@ void show_free_areas(void)
2128 } 2162 }
2129 } 2163 }
2130 2164
2131 printk("Active_anon:%lu active_file:%lu inactive_anon:%lu\n" 2165 printk("active_anon:%lu inactive_anon:%lu isolated_anon:%lu\n"
2132 " inactive_file:%lu" 2166 " active_file:%lu inactive_file:%lu isolated_file:%lu\n"
2133 " unevictable:%lu" 2167 " unevictable:%lu"
2134 " dirty:%lu writeback:%lu unstable:%lu\n" 2168 " dirty:%lu writeback:%lu unstable:%lu buffer:%lu\n"
2135 " free:%lu slab:%lu mapped:%lu pagetables:%lu bounce:%lu\n", 2169 " free:%lu slab_reclaimable:%lu slab_unreclaimable:%lu\n"
2170 " mapped:%lu shmem:%lu pagetables:%lu bounce:%lu\n",
2136 global_page_state(NR_ACTIVE_ANON), 2171 global_page_state(NR_ACTIVE_ANON),
2137 global_page_state(NR_ACTIVE_FILE),
2138 global_page_state(NR_INACTIVE_ANON), 2172 global_page_state(NR_INACTIVE_ANON),
2173 global_page_state(NR_ISOLATED_ANON),
2174 global_page_state(NR_ACTIVE_FILE),
2139 global_page_state(NR_INACTIVE_FILE), 2175 global_page_state(NR_INACTIVE_FILE),
2176 global_page_state(NR_ISOLATED_FILE),
2140 global_page_state(NR_UNEVICTABLE), 2177 global_page_state(NR_UNEVICTABLE),
2141 global_page_state(NR_FILE_DIRTY), 2178 global_page_state(NR_FILE_DIRTY),
2142 global_page_state(NR_WRITEBACK), 2179 global_page_state(NR_WRITEBACK),
2143 global_page_state(NR_UNSTABLE_NFS), 2180 global_page_state(NR_UNSTABLE_NFS),
2181 nr_blockdev_pages(),
2144 global_page_state(NR_FREE_PAGES), 2182 global_page_state(NR_FREE_PAGES),
2145 global_page_state(NR_SLAB_RECLAIMABLE) + 2183 global_page_state(NR_SLAB_RECLAIMABLE),
2146 global_page_state(NR_SLAB_UNRECLAIMABLE), 2184 global_page_state(NR_SLAB_UNRECLAIMABLE),
2147 global_page_state(NR_FILE_MAPPED), 2185 global_page_state(NR_FILE_MAPPED),
2186 global_page_state(NR_SHMEM),
2148 global_page_state(NR_PAGETABLE), 2187 global_page_state(NR_PAGETABLE),
2149 global_page_state(NR_BOUNCE)); 2188 global_page_state(NR_BOUNCE));
2150 2189
@@ -2162,7 +2201,21 @@ void show_free_areas(void)
2162 " active_file:%lukB" 2201 " active_file:%lukB"
2163 " inactive_file:%lukB" 2202 " inactive_file:%lukB"
2164 " unevictable:%lukB" 2203 " unevictable:%lukB"
2204 " isolated(anon):%lukB"
2205 " isolated(file):%lukB"
2165 " present:%lukB" 2206 " present:%lukB"
2207 " mlocked:%lukB"
2208 " dirty:%lukB"
2209 " writeback:%lukB"
2210 " mapped:%lukB"
2211 " shmem:%lukB"
2212 " slab_reclaimable:%lukB"
2213 " slab_unreclaimable:%lukB"
2214 " kernel_stack:%lukB"
2215 " pagetables:%lukB"
2216 " unstable:%lukB"
2217 " bounce:%lukB"
2218 " writeback_tmp:%lukB"
2166 " pages_scanned:%lu" 2219 " pages_scanned:%lu"
2167 " all_unreclaimable? %s" 2220 " all_unreclaimable? %s"
2168 "\n", 2221 "\n",
@@ -2176,7 +2229,22 @@ void show_free_areas(void)
2176 K(zone_page_state(zone, NR_ACTIVE_FILE)), 2229 K(zone_page_state(zone, NR_ACTIVE_FILE)),
2177 K(zone_page_state(zone, NR_INACTIVE_FILE)), 2230 K(zone_page_state(zone, NR_INACTIVE_FILE)),
2178 K(zone_page_state(zone, NR_UNEVICTABLE)), 2231 K(zone_page_state(zone, NR_UNEVICTABLE)),
2232 K(zone_page_state(zone, NR_ISOLATED_ANON)),
2233 K(zone_page_state(zone, NR_ISOLATED_FILE)),
2179 K(zone->present_pages), 2234 K(zone->present_pages),
2235 K(zone_page_state(zone, NR_MLOCK)),
2236 K(zone_page_state(zone, NR_FILE_DIRTY)),
2237 K(zone_page_state(zone, NR_WRITEBACK)),
2238 K(zone_page_state(zone, NR_FILE_MAPPED)),
2239 K(zone_page_state(zone, NR_SHMEM)),
2240 K(zone_page_state(zone, NR_SLAB_RECLAIMABLE)),
2241 K(zone_page_state(zone, NR_SLAB_UNRECLAIMABLE)),
2242 zone_page_state(zone, NR_KERNEL_STACK) *
2243 THREAD_SIZE / 1024,
2244 K(zone_page_state(zone, NR_PAGETABLE)),
2245 K(zone_page_state(zone, NR_UNSTABLE_NFS)),
2246 K(zone_page_state(zone, NR_BOUNCE)),
2247 K(zone_page_state(zone, NR_WRITEBACK_TEMP)),
2180 zone->pages_scanned, 2248 zone->pages_scanned,
2181 (zone_is_all_unreclaimable(zone) ? "yes" : "no") 2249 (zone_is_all_unreclaimable(zone) ? "yes" : "no")
2182 ); 2250 );
@@ -2783,7 +2851,8 @@ static void setup_zone_migrate_reserve(struct zone *zone)
2783{ 2851{
2784 unsigned long start_pfn, pfn, end_pfn; 2852 unsigned long start_pfn, pfn, end_pfn;
2785 struct page *page; 2853 struct page *page;
2786 unsigned long reserve, block_migratetype; 2854 unsigned long block_migratetype;
2855 int reserve;
2787 2856
2788 /* Get the start pfn, end pfn and the number of blocks to reserve */ 2857 /* Get the start pfn, end pfn and the number of blocks to reserve */
2789 start_pfn = zone->zone_start_pfn; 2858 start_pfn = zone->zone_start_pfn;
@@ -2791,6 +2860,15 @@ static void setup_zone_migrate_reserve(struct zone *zone)
2791 reserve = roundup(min_wmark_pages(zone), pageblock_nr_pages) >> 2860 reserve = roundup(min_wmark_pages(zone), pageblock_nr_pages) >>
2792 pageblock_order; 2861 pageblock_order;
2793 2862
2863 /*
2864 * Reserve blocks are generally in place to help high-order atomic
2865 * allocations that are short-lived. A min_free_kbytes value that
2866 * would result in more than 2 reserve blocks for atomic allocations
2867 * is assumed to be in place to help anti-fragmentation for the
2868 * future allocation of hugepages at runtime.
2869 */
2870 reserve = min(2, reserve);
2871
2794 for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { 2872 for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) {
2795 if (!pfn_valid(pfn)) 2873 if (!pfn_valid(pfn))
2796 continue; 2874 continue;
@@ -2961,6 +3039,7 @@ static int zone_batchsize(struct zone *zone)
2961static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) 3039static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
2962{ 3040{
2963 struct per_cpu_pages *pcp; 3041 struct per_cpu_pages *pcp;
3042 int migratetype;
2964 3043
2965 memset(p, 0, sizeof(*p)); 3044 memset(p, 0, sizeof(*p));
2966 3045
@@ -2968,7 +3047,8 @@ static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
2968 pcp->count = 0; 3047 pcp->count = 0;
2969 pcp->high = 6 * batch; 3048 pcp->high = 6 * batch;
2970 pcp->batch = max(1UL, 1 * batch); 3049 pcp->batch = max(1UL, 1 * batch);
2971 INIT_LIST_HEAD(&pcp->list); 3050 for (migratetype = 0; migratetype < MIGRATE_PCPTYPES; migratetype++)
3051 INIT_LIST_HEAD(&pcp->lists[migratetype]);
2972} 3052}
2973 3053
2974/* 3054/*
@@ -3146,6 +3226,32 @@ int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages)
3146 return 0; 3226 return 0;
3147} 3227}
3148 3228
3229static int __zone_pcp_update(void *data)
3230{
3231 struct zone *zone = data;
3232 int cpu;
3233 unsigned long batch = zone_batchsize(zone), flags;
3234
3235 for (cpu = 0; cpu < NR_CPUS; cpu++) {
3236 struct per_cpu_pageset *pset;
3237 struct per_cpu_pages *pcp;
3238
3239 pset = zone_pcp(zone, cpu);
3240 pcp = &pset->pcp;
3241
3242 local_irq_save(flags);
3243 free_pcppages_bulk(zone, pcp->count, pcp);
3244 setup_pageset(pset, batch);
3245 local_irq_restore(flags);
3246 }
3247 return 0;
3248}
3249
3250void zone_pcp_update(struct zone *zone)
3251{
3252 stop_machine(__zone_pcp_update, zone, NULL);
3253}
3254
3149static __meminit void zone_pcp_init(struct zone *zone) 3255static __meminit void zone_pcp_init(struct zone *zone)
3150{ 3256{
3151 int cpu; 3257 int cpu;
@@ -3720,7 +3826,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
3720 zone_pcp_init(zone); 3826 zone_pcp_init(zone);
3721 for_each_lru(l) { 3827 for_each_lru(l) {
3722 INIT_LIST_HEAD(&zone->lru[l].list); 3828 INIT_LIST_HEAD(&zone->lru[l].list);
3723 zone->lru[l].nr_saved_scan = 0; 3829 zone->reclaim_stat.nr_saved_scan[l] = 0;
3724 } 3830 }
3725 zone->reclaim_stat.recent_rotated[0] = 0; 3831 zone->reclaim_stat.recent_rotated[0] = 0;
3726 zone->reclaim_stat.recent_rotated[1] = 0; 3832 zone->reclaim_stat.recent_rotated[1] = 0;
@@ -4509,7 +4615,7 @@ void setup_per_zone_wmarks(void)
4509 calculate_totalreserve_pages(); 4615 calculate_totalreserve_pages();
4510} 4616}
4511 4617
4512/** 4618/*
4513 * The inactive anon list should be small enough that the VM never has to 4619 * The inactive anon list should be small enough that the VM never has to
4514 * do too much work, but large enough that each inactive page has a chance 4620 * do too much work, but large enough that each inactive page has a chance
4515 * to be referenced again before it is swapped out. 4621 * to be referenced again before it is swapped out.
@@ -4732,7 +4838,14 @@ void *__init alloc_large_system_hash(const char *tablename,
4732 numentries <<= (PAGE_SHIFT - scale); 4838 numentries <<= (PAGE_SHIFT - scale);
4733 4839
4734 /* Make sure we've got at least a 0-order allocation.. */ 4840 /* Make sure we've got at least a 0-order allocation.. */
4735 if (unlikely((numentries * bucketsize) < PAGE_SIZE)) 4841 if (unlikely(flags & HASH_SMALL)) {
4842 /* Makes no sense without HASH_EARLY */
4843 WARN_ON(!(flags & HASH_EARLY));
4844 if (!(numentries >> *_hash_shift)) {
4845 numentries = 1UL << *_hash_shift;
4846 BUG_ON(!numentries);
4847 }
4848 } else if (unlikely((numentries * bucketsize) < PAGE_SIZE))
4736 numentries = PAGE_SIZE / bucketsize; 4849 numentries = PAGE_SIZE / bucketsize;
4737 } 4850 }
4738 numentries = roundup_pow_of_two(numentries); 4851 numentries = roundup_pow_of_two(numentries);
@@ -4874,13 +4987,16 @@ int set_migratetype_isolate(struct page *page)
4874 struct zone *zone; 4987 struct zone *zone;
4875 unsigned long flags; 4988 unsigned long flags;
4876 int ret = -EBUSY; 4989 int ret = -EBUSY;
4990 int zone_idx;
4877 4991
4878 zone = page_zone(page); 4992 zone = page_zone(page);
4993 zone_idx = zone_idx(zone);
4879 spin_lock_irqsave(&zone->lock, flags); 4994 spin_lock_irqsave(&zone->lock, flags);
4880 /* 4995 /*
4881 * In future, more migrate types will be able to be isolation target. 4996 * In future, more migrate types will be able to be isolation target.
4882 */ 4997 */
4883 if (get_pageblock_migratetype(page) != MIGRATE_MOVABLE) 4998 if (get_pageblock_migratetype(page) != MIGRATE_MOVABLE &&
4999 zone_idx != ZONE_MOVABLE)
4884 goto out; 5000 goto out;
4885 set_pageblock_migratetype(page, MIGRATE_ISOLATE); 5001 set_pageblock_migratetype(page, MIGRATE_ISOLATE);
4886 move_freepages_block(zone, page, MIGRATE_ISOLATE); 5002 move_freepages_block(zone, page, MIGRATE_ISOLATE);