Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9963a697 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm: try to exhaust highatomic reserve before the OOM" into msm-4.9

parents 339af29f 34bd01b7
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -2059,7 +2059,7 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone,
 * intense memory pressure but failed atomic allocations should be easier
 * to recover from than an OOM.
 */
static void unreserve_highatomic_pageblock(const struct alloc_context *ac)
static bool unreserve_highatomic_pageblock(const struct alloc_context *ac)
{
	struct zonelist *zonelist = ac->zonelist;
	unsigned long flags;
@@ -2067,6 +2067,7 @@ static void unreserve_highatomic_pageblock(const struct alloc_context *ac)
	struct zone *zone;
	struct page *page;
	int order;
	bool ret;

	for_each_zone_zonelist_nodemask(zone, z, zonelist, ac->high_zoneidx,
								ac->nodemask) {
@@ -2115,12 +2116,14 @@ static void unreserve_highatomic_pageblock(const struct alloc_context *ac)
			 * may increase.
			 */
			set_pageblock_migratetype(page, ac->migratetype);
			move_freepages_block(zone, page, ac->migratetype);
			ret = move_freepages_block(zone, page, ac->migratetype);
			spin_unlock_irqrestore(&zone->lock, flags);
			return;
			return ret;
		}
		spin_unlock_irqrestore(&zone->lock, flags);
	}

	return false;
}

/* Remove an element from the buddy allocator from the fallback list */
@@ -3444,8 +3447,10 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,
	 * Make sure we converge to OOM if we cannot make any progress
	 * several times in the row.
	 */
	if (*no_progress_loops > MAX_RECLAIM_RETRIES)
		return false;
	if (*no_progress_loops > MAX_RECLAIM_RETRIES) {
		/* Before OOM, exhaust highatomic_reserve */
		return unreserve_highatomic_pageblock(ac);
	}

	/*
	 * Keep reclaiming pages while there is a chance this will lead