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

Commit fec152ac authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ion: skip refilling for order 0 pools"

parents 86fd01bb 835abc0e
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;
+22 −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;
}
@@ -65,6 +81,10 @@ void ion_page_pool_refill(struct ion_page_pool *pool)
	gfp_t gfp_refill = (pool->gfp_mask | __GFP_RECLAIM) & ~__GFP_NORETRY;
	struct device *dev = pool->heap.priv;

	/* skip refilling order 0 pools */
	if (!pool->order)
		return;

	while (!pool_fillmark_reached(pool) && pool_refill_ok(pool)) {
		page = alloc_pages(gfp_refill, pool->order);
		if (!page)
+2 −1
Original line number Diff line number Diff line
@@ -479,7 +479,8 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask,
	if (!nr_to_scan)
		only_scan = 1;

	for (i = 0; i < NUM_ORDERS; i++) {
	/* shrink the pools starting from lower order ones */
	for (i = NUM_ORDERS - 1; i >= 0; i--) {
		nr_freed = 0;

		for (j = 0; j < VMID_LAST; j++) {