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

Commit 4ac998d8 authored by Gioh Kim's avatar Gioh Kim Committed by Vinayak Menon
Browse files

staging: ion: shrink page-pool by page unit



This patch shrink page-pool by page unit.

The system shrinker calls ion_heap_shrink_count() to get nr_to_scan,
and pass it to ion_heap_shrink_scan().
The problem is the return value of ion_heap_shrink_count() is the number
of pages but ion_system_heap_shrink(), which is called by
ion_heap_shrink_scan(), gets the number of chunk.

The main root of this is that ion_page_pool_shrink() returns page count
via ion_page_pool_total() if it have to check pool size. But it frees
chunks of pages if it have to free pools.

This patch first fix ion_page_pool_shrink() to count only pages,
not chunks. And then ion_system_heap_shrink() to work on pages.

Signed-off-by: default avatarGioh Kim <gioh.kim@lge.com>
Reviewed-by: default avatarLaura Abbott <labbott@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I27dab94d1a0f8a052d82e4f83ecc000f4780d388
Git-commit: b44d9ce3b81715311198f0c5fa329e518b4f9f18
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


CRs-Fixed: 966661
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 3efa91f5
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ static int ion_page_pool_total(struct ion_page_pool *pool, bool high)
int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
				int nr_to_scan)
{
	int i;
	int freed = 0;
	bool high;

	if (current_is_kswapd())
@@ -136,7 +136,10 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
	else
		high = !!(gfp_mask & __GFP_HIGHMEM);

	for (i = 0; i < nr_to_scan; i++) {
	if (nr_to_scan == 0)
		return ion_page_pool_total(pool, high);

	while (freed < nr_to_scan) {
		struct page *page;

		mutex_lock(&pool->mutex);
@@ -150,9 +153,10 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
		}
		mutex_unlock(&pool->mutex);
		ion_page_pool_free_pages(pool, page);
		freed += (1 << pool->order);
	}

	return ion_page_pool_total(pool, high);
	return freed;
}

struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order)
+16 −3
Original line number Diff line number Diff line
@@ -365,16 +365,29 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask,
{
	struct ion_system_heap *sys_heap;
	int nr_total = 0;
	int i;
	int i, nr_freed = 0;
	int only_scan = 0;

	sys_heap = container_of(heap, struct ion_system_heap, heap);

	if (!nr_to_scan)
		only_scan = 1;

	for (i = 0; i < num_orders; i++) {
		struct ion_page_pool *pool = sys_heap->uncached_pools[i];
		nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
		nr_freed += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
		nr_total += nr_freed;

		pool = sys_heap->cached_pools[i];
		nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
		nr_freed += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
		nr_total += nr_freed;

		if (!only_scan) {
			nr_to_scan -= nr_freed;
			/* shrink completed */
			if (nr_to_scan <= 0)
				break;
		}
	}

	return nr_total;