summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGioh Kim <gioh.kim@lge.com>2015-07-06 15:14:41 +0900
committerDaniel Rosenberg <|account-1045980@2620:0:1000:1601:79df:5c52:d7ca:bcd6>2015-11-02 22:01:55 +0000
commit829d8c9e1dc01dca8d68857d8f974a7d36d73d6c (patch)
treec1d7dd26391162da8d37c1f8450125b2ba70c595
parent42f3ea1932e55507372b9926f539a09b05c04091 (diff)
downloadcommon-brillo-m7-mr-dev.tar.gz
staging: ion: debugfs to shrink poolbrillo-m7-releasebrillo-m7-mr-devbrillo-m7-dev
This patch enables debugfs file /sys/kernel/debug/ion/heaps/system_shrink to shrink pool and get pool size. This technically enables debugfs shrinking for all heaps, not just the system heap although the system heap is the only one with a shrinker right now. It is already implemented but not complete. This patch completes and enables it. Reading the file returns pool size in page unit and writing the number of pages shrinks pool. It flushes all pages to write zero at the file. Signed-off-by: Gioh Kim <gioh.kim@lge.com> Reviewed-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit aeb7fa7b4f29ce4d7d16c4c3565c4714f2f62b82)
-rw-r--r--drivers/staging/android/ion/ion.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index b1a3e1a2d936..65b46fab72e5 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1463,7 +1463,6 @@ static const struct file_operations debug_heap_fops = {
.release = single_release,
};
-#ifdef DEBUG_HEAP_SHRINKER
static int debug_shrink_set(void *data, u64 val)
{
struct ion_heap *heap = data;
@@ -1471,15 +1470,14 @@ static int debug_shrink_set(void *data, u64 val)
int objs;
sc.gfp_mask = -1;
- sc.nr_to_scan = 0;
-
- if (!val)
- return 0;
+ sc.nr_to_scan = val;
- objs = heap->shrinker.shrink(&heap->shrinker, &sc);
- sc.nr_to_scan = objs;
+ if (!val) {
+ objs = heap->shrinker.count_objects(&heap->shrinker, &sc);
+ sc.nr_to_scan = objs;
+ }
- heap->shrinker.shrink(&heap->shrinker, &sc);
+ heap->shrinker.scan_objects(&heap->shrinker, &sc);
return 0;
}
@@ -1492,14 +1490,13 @@ static int debug_shrink_get(void *data, u64 *val)
sc.gfp_mask = -1;
sc.nr_to_scan = 0;
- objs = heap->shrinker.shrink(&heap->shrinker, &sc);
+ objs = heap->shrinker.count_objects(&heap->shrinker, &sc);
*val = objs;
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get,
debug_shrink_set, "%llu\n");
-#endif
void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
{
@@ -1534,8 +1531,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
path, heap->name);
}
-#ifdef DEBUG_HEAP_SHRINKER
- if (heap->shrinker.shrink) {
+ if (heap->shrinker.count_objects && heap->shrinker.scan_objects) {
char debug_name[64];
snprintf(debug_name, 64, "%s_shrink", heap->name);
@@ -1550,7 +1546,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
path, debug_name);
}
}
-#endif
+
up_write(&dev->lock);
}