android: ion: show heaptype in the buffer list
authorCho KyongHo <pullip.cho@samsung.com>
Wed, 11 Jul 2018 07:37:26 +0000 (16:37 +0900)
committerhskang <hs1218.kang@samsung.com>
Wed, 29 Aug 2018 07:34:06 +0000 (16:34 +0900)
Heap name tells the purpose of heaps and heap type shows how heaps
really work. Showing heap types in the list of buffers helps
identifying the property of buffers more accurately.

Change-Id: I77c97a589e199797ba1898dc696b4d369ea3538a
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/staging/android/ion/ion_debug.c

index 832c9c462a64382c48914757e300b39bb9d81b7e..7141c54bd7b5cc17e16668e6b880ce5927507e30 100644 (file)
 
 #define ION_MAX_LOGBUF 128
 
+const static char *heap_type_name[] = {
+       "system",
+       "syscntig",
+       "carveout",
+       "chunk",
+       "cma",
+       "hpa",
+};
+
 static size_t ion_print_buffer(struct ion_buffer *buffer, bool alive,
                               char *logbuf, int buflen)
 {
        struct ion_iovm_map *iovm;
        int count;
+       unsigned int heaptype = buffer->heap->type;
+
+       if (heaptype >= ARRAY_SIZE(heap_type_name))
+               heaptype = 0; /* forces it to 0 to prevent buffer overrun */
 
-       count = scnprintf(logbuf, buflen, "[%4d] %15s %#5lx %8zu : ",
-                         buffer->id, buffer->heap->name, buffer->flags,
+       count = scnprintf(logbuf, buflen, "[%4d] %15s %8s %#5lx %8zu : ",
+                         buffer->id, buffer->heap->name,
+                         heap_type_name[heaptype], buffer->flags,
                          buffer->size / SZ_1K);
        buflen = max(0, buflen - count);
        /*
@@ -65,8 +79,8 @@ static int ion_debug_buffers_show(struct seq_file *s, void *unused)
        char logbuf[ION_MAX_LOGBUF];
        size_t total = 0;
 
-       seq_printf(s, "[  id] %15s %5s %8s : %s\n",
-                  "heap", "flags", "size(kb)", "iommu_mapped...");
+       seq_printf(s, "[  id] %15s %8s %5s %8s : %s\n",
+                  "heap", "heaptype", "flags", "size(kb)", "iommu_mapped...");
 
        mutex_lock(&idev->buffer_lock);
        for (n = rb_first(&idev->buffers); n; n = rb_next(n)) {
@@ -136,8 +150,8 @@ static int ion_oom_notifier_fn(struct notifier_block *nb,
        char logbuf[ION_MAX_LOGBUF];
        size_t total = 0;
 
-       pr_info("[  id] %15s %5s %8s : %s\n",
-               "heap", "flags", "size(kb)", "iommu_mapped...");
+       pr_info("[  id] %15s %8s %5s %8s : %s\n",
+               "heap", "heaptype", "flags", "size(kb)", "iommu_mapped...");
 
        mutex_lock(&idev->buffer_lock);
        for (n = rb_first(&idev->buffers); n; n = rb_next(n)) {