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

Commit e7b78cef authored by Shrenuj Bansal's avatar Shrenuj Bansal
Browse files

msm: kgsl: Change the shrinker to not free reserved pages



If the low memory killer runs early in execution, it could free
several reserved pages and for pools which are not allowed to
allocate new pages, those pages are gone forever. Change the
shrinker to not free the reserved pages from pools which are not
allowed to allocate new pages.

Change-Id: I65631628a3043fe7c2f74d41bb116fe1b6255873
Signed-off-by: default avatarShrenuj Bansal <shrenujb@codeaurora.org>
parent 450bd44d
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ _kgsl_pool_shrink(struct kgsl_page_pool *pool, int num_pages)
 * starting from higher order pool.
 */
static unsigned long
kgsl_pool_reduce(unsigned int target_pages)
kgsl_pool_reduce(unsigned int target_pages, bool exit)
{
	int total_pages = 0;
	int i;
@@ -210,6 +210,14 @@ kgsl_pool_reduce(unsigned int target_pages)
	for (i = (KGSL_NUM_POOLS - 1); i >= 0; i--) {
		pool = &kgsl_pools[i];

		/*
		 * Only reduce the pool sizes for pools which are allowed to
		 * allocate memory unless we are at close, in which case the
		 * reserved memory for all pools needs to be freed
		 */
		if (!pool->allocation_allowed && !exit)
			continue;

		total_pages -= pcount;

		nr_removed = total_pages - target_pages;
@@ -417,7 +425,7 @@ kgsl_pool_shrink_scan_objects(struct shrinker *shrinker,
	int target_pages = (nr > total_pages) ? 0 : (total_pages - nr);

	/* Reduce pool size to target_pages */
	return kgsl_pool_reduce(target_pages);
	return kgsl_pool_reduce(target_pages, false);
}

static unsigned long
@@ -448,7 +456,7 @@ void kgsl_init_page_pools(void)
void kgsl_exit_page_pools(void)
{
	/* Release all pages in pools, if any.*/
	kgsl_pool_reduce(0);
	kgsl_pool_reduce(0, true);

	/* Unregister shrinker */
	unregister_shrinker(&kgsl_pool_shrinker);