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

Commit bc0155b4 authored by Sudarshan Rajagopalan's avatar Sudarshan Rajagopalan
Browse files

ion: defer pool refill on low zone watermarks



Make pool_refill_ok more aggressive to make sure there is
no unwanted repetitive refilling and reclaiming of buddy
pages on the pool. Also defer the pool refilling within a
certain window if the zone watermarks are not ok.

Change-Id: Ib13411cdd75bec49cdd073c00da26168d93af841
Signed-off-by: default avatarSudarshan Rajagopalan <sudaraja@codeaurora.org>
parent c5f80a76
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@
#define ION_POOL_LOW_MARK 0UL
#endif

/* if low watermark of zones have reached, defer the refill in this window */
#define ION_POOL_REFILL_DEFER_WINDOW_MS	10

/**
 * struct ion_platform_heap - defines a heap in the given platform
 * @type:	type of the heap from ion_heap_type enum
@@ -435,6 +438,7 @@ struct ion_page_pool {
	bool cached;
	struct list_head high_items;
	struct list_head low_items;
	ktime_t last_low_watermark_ktime;
	/* Protect the pool */
	struct mutex mutex;
	gfp_t gfp_mask;
+18 −2
Original line number Diff line number Diff line
@@ -19,14 +19,30 @@ static bool pool_refill_ok(struct ion_page_pool *pool)
	struct zoneref *z;
	struct zone *zone;
	int mark;
	int classzone_idx = (int)gfp_zone(pool->gfp_mask);
	enum zone_type classzone_idx = gfp_zone(pool->gfp_mask);
	s64 delta;

	/* check if we are within the refill defer window */
	delta = ktime_ms_delta(ktime_get(), pool->last_low_watermark_ktime);
	if (delta < ION_POOL_REFILL_DEFER_WINDOW_MS)
		return false;

	zonelist = node_zonelist(numa_node_id(), pool->gfp_mask);
	/*
	 * make sure that if we allocate a pool->order page from buddy,
	 * we don't put the zone watermarks go below the high threshold.
	 * This makes sure there's no unwanted repetitive refilling and
	 * reclaiming of buddy pages on the pool.
	 */
	for_each_zone_zonelist(zone, z, zonelist, classzone_idx) {
		mark = high_wmark_pages(zone);
		if (!zone_watermark_ok_safe(zone, 0, mark, classzone_idx))
		mark += 1 << pool->order;
		if (!zone_watermark_ok_safe(zone, pool->order, mark,
					    classzone_idx)) {
			pool->last_low_watermark_ktime = ktime_get();
			return false;
		}
	}

	return true;
}