Commit b1aced6f authored by John Stultz's avatar John Stultz Committed by Greg Kroah-Hartman

ion: Update system heap shrinker to use the new count/scan interface

Update the ION system heap shrinker to use the new count/scan
interfaces that landed in 3.12
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 024789ae
...@@ -232,15 +232,37 @@ static struct ion_heap_ops system_heap_ops = { ...@@ -232,15 +232,37 @@ static struct ion_heap_ops system_heap_ops = {
.map_user = ion_heap_map_user, .map_user = ion_heap_map_user,
}; };
static int ion_system_heap_shrink(struct shrinker *shrinker, static unsigned long ion_system_heap_shrink_count(struct shrinker *shrinker,
struct shrink_control *sc) { struct shrink_control *sc)
{
struct ion_heap *heap = container_of(shrinker, struct ion_heap, struct ion_heap *heap = container_of(shrinker, struct ion_heap,
shrinker); shrinker);
struct ion_system_heap *sys_heap = container_of(heap, struct ion_system_heap *sys_heap = container_of(heap,
struct ion_system_heap, struct ion_system_heap,
heap); heap);
int nr_total = 0; int nr_total = 0;
int i;
/* total number of items is whatever the page pools are holding
plus whatever's in the freelist */
for (i = 0; i < num_orders; i++) {
struct ion_page_pool *pool = sys_heap->pools[i];
nr_total += ion_page_pool_shrink(pool, sc->gfp_mask, 0);
}
nr_total += ion_heap_freelist_size(heap) / PAGE_SIZE;
return nr_total;
}
static unsigned long ion_system_heap_shrink_scan(struct shrinker *shrinker,
struct shrink_control *sc)
{
struct ion_heap *heap = container_of(shrinker, struct ion_heap,
shrinker);
struct ion_system_heap *sys_heap = container_of(heap,
struct ion_system_heap,
heap);
int nr_freed = 0; int nr_freed = 0;
int i; int i;
...@@ -265,14 +287,7 @@ static int ion_system_heap_shrink(struct shrinker *shrinker, ...@@ -265,14 +287,7 @@ static int ion_system_heap_shrink(struct shrinker *shrinker,
} }
end: end:
/* total number of items is whatever the page pools are holding return nr_freed;
plus whatever's in the freelist */
for (i = 0; i < num_orders; i++) {
struct ion_page_pool *pool = sys_heap->pools[i];
nr_total += ion_page_pool_shrink(pool, sc->gfp_mask, 0);
}
nr_total += ion_heap_freelist_size(heap) / PAGE_SIZE;
return nr_total;
} }
...@@ -323,7 +338,8 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused) ...@@ -323,7 +338,8 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
heap->pools[i] = pool; heap->pools[i] = pool;
} }
heap->heap.shrinker.shrink = ion_system_heap_shrink; heap->heap.shrinker.scan_objects = ion_system_heap_shrink_scan;
heap->heap.shrinker.count_objects = ion_system_heap_shrink_count;
heap->heap.shrinker.seeks = DEFAULT_SEEKS; heap->heap.shrinker.seeks = DEFAULT_SEEKS;
heap->heap.shrinker.batch = 0; heap->heap.shrinker.batch = 0;
register_shrinker(&heap->heap.shrinker); register_shrinker(&heap->heap.shrinker);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment