diff options
author | Colin Cross <ccross@android.com> | 2014-02-17 21:58:38 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-18 19:05:08 (GMT) |
commit | b9daf0b60b8a6a5151fca0e8cbb2dab763a3e92a (patch) | |
tree | c17f16819109566bd0e5a76bc6c8ab7347e39a57 /drivers/staging/android/ion/ion_page_pool.c | |
parent | 2803ac7bf20129365ff7b774adf63e0fd35c4221 (diff) | |
download | linux-b9daf0b60b8a6a5151fca0e8cbb2dab763a3e92a.tar.xz |
staging: ion: Move shrinker out of heaps
Every heap that uses deferred frees is going to need a shrinker
to shrink the freelist under memory pressure. Rather than
requiring each heap to implement a shrinker, automatically
register a shrinker if the deferred free flag is set.
The system heap also needs to shrink its page pools, so add
a shrink function to the heap ops that will be called after
shrinking the freelists.
Cc: Colin Cross <ccross@android.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Colin Cross <ccross@android.com>
[jstultz: Resolved big conflicts with the shrinker api change.
Also minor commit subject tweak.]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/android/ion/ion_page_pool.c')
-rw-r--r-- | drivers/staging/android/ion/ion_page_pool.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index fa693c2..ecb5fc3 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -130,8 +130,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 nr_freed = 0; - int i; + int freed; bool high; high = !!(gfp_mask & __GFP_HIGHMEM); @@ -139,7 +138,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, if (nr_to_scan == 0) return ion_page_pool_total(pool, high); - for (i = 0; i < nr_to_scan; i++) { + for (freed = 0; freed < nr_to_scan; freed++) { struct page *page; mutex_lock(&pool->mutex); @@ -153,10 +152,9 @@ 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); - nr_freed += (1 << pool->order); } - return nr_freed; + return freed; } struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order) |