diff options
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 59d2e88fb47c..74af449b1f1d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1654,12 +1654,22 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, | |||
1654 | if (page) | 1654 | if (page) |
1655 | goto out; | 1655 | goto out; |
1656 | 1656 | ||
1657 | /* The OOM killer will not help higher order allocs */ | 1657 | if (!(gfp_mask & __GFP_NOFAIL)) { |
1658 | if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_NOFAIL)) | 1658 | /* The OOM killer will not help higher order allocs */ |
1659 | goto out; | 1659 | if (order > PAGE_ALLOC_COSTLY_ORDER) |
1660 | 1660 | goto out; | |
1661 | /* | ||
1662 | * GFP_THISNODE contains __GFP_NORETRY and we never hit this. | ||
1663 | * Sanity check for bare calls of __GFP_THISNODE, not real OOM. | ||
1664 | * The caller should handle page allocation failure by itself if | ||
1665 | * it specifies __GFP_THISNODE. | ||
1666 | * Note: Hugepage uses it but will hit PAGE_ALLOC_COSTLY_ORDER. | ||
1667 | */ | ||
1668 | if (gfp_mask & __GFP_THISNODE) | ||
1669 | goto out; | ||
1670 | } | ||
1661 | /* Exhausted what can be done so it's blamo time */ | 1671 | /* Exhausted what can be done so it's blamo time */ |
1662 | out_of_memory(zonelist, gfp_mask, order); | 1672 | out_of_memory(zonelist, gfp_mask, order, nodemask); |
1663 | 1673 | ||
1664 | out: | 1674 | out: |
1665 | clear_zonelist_oom(zonelist, gfp_mask); | 1675 | clear_zonelist_oom(zonelist, gfp_mask); |
@@ -3123,7 +3133,7 @@ static int __cpuinit process_zones(int cpu) | |||
3123 | 3133 | ||
3124 | if (percpu_pagelist_fraction) | 3134 | if (percpu_pagelist_fraction) |
3125 | setup_pagelist_highmark(zone_pcp(zone, cpu), | 3135 | setup_pagelist_highmark(zone_pcp(zone, cpu), |
3126 | (zone->present_pages / percpu_pagelist_fraction)); | 3136 | (zone->present_pages / percpu_pagelist_fraction)); |
3127 | } | 3137 | } |
3128 | 3138 | ||
3129 | return 0; | 3139 | return 0; |
@@ -5081,3 +5091,24 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) | |||
5081 | spin_unlock_irqrestore(&zone->lock, flags); | 5091 | spin_unlock_irqrestore(&zone->lock, flags); |
5082 | } | 5092 | } |
5083 | #endif | 5093 | #endif |
5094 | |||
5095 | #ifdef CONFIG_MEMORY_FAILURE | ||
5096 | bool is_free_buddy_page(struct page *page) | ||
5097 | { | ||
5098 | struct zone *zone = page_zone(page); | ||
5099 | unsigned long pfn = page_to_pfn(page); | ||
5100 | unsigned long flags; | ||
5101 | int order; | ||
5102 | |||
5103 | spin_lock_irqsave(&zone->lock, flags); | ||
5104 | for (order = 0; order < MAX_ORDER; order++) { | ||
5105 | struct page *page_head = page - (pfn & ((1 << order) - 1)); | ||
5106 | |||
5107 | if (PageBuddy(page_head) && page_order(page_head) >= order) | ||
5108 | break; | ||
5109 | } | ||
5110 | spin_unlock_irqrestore(&zone->lock, flags); | ||
5111 | |||
5112 | return order < MAX_ORDER; | ||
5113 | } | ||
5114 | #endif | ||