diff --git a/mm/compaction.c b/mm/compaction.c index 39f599bbb59a0453d821b30055bb4bc4f547782f..8010521ff9697384dc7d8c4816ba8f60f73bf789 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -476,10 +476,11 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, if (PageCompound(page)) { const unsigned int order = compound_order(page); - if (likely(order < MAX_ORDER)) { + if (blockpfn + (1UL << order) <= end_pfn) { blockpfn += (1UL << order) - 1; cursor += (1UL << order) - 1; } + goto isolate_fail; } @@ -544,8 +545,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, spin_unlock_irqrestore(&cc->zone->lock, flags); /* - * There is a tiny chance that we have read bogus compound_order(), - * so be careful to not go outside of the pageblock. + * Be careful to not go outside of the pageblock. */ if (unlikely(blockpfn > end_pfn)) blockpfn = end_pfn; diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 191ed8a6b0d0a906df76a55ee415b6c9ace6a33e..bde2e7b632db4994fdf9c712be38e7dad2fd9b67 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2837,7 +2837,9 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count, if (nid != NUMA_NO_NODE) { unsigned long old_count = count; - count += h->nr_huge_pages - h->nr_huge_pages_node[nid]; + count += persistent_huge_pages(h) - + (h->nr_huge_pages_node[nid] - + h->surplus_huge_pages_node[nid]); /* * User may have specified a large count value which caused the * above calculation to overflow. In this case, they wanted