[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200323080503.6224-4-jaewon31.kim@samsung.com>
Date: Mon, 23 Mar 2020 17:05:03 +0900
From: Jaewon Kim <jaewon31.kim@...sung.com>
To: gregkh@...uxfoundation.org, leon@...nel.org, vbabka@...e.cz,
adobriyan@...il.com, akpm@...ux-foundation.org, labbott@...hat.com,
sumit.semwal@...aro.org, minchan@...nel.org, ngupta@...are.org,
sergey.senozhatsky.work@...il.com, kasong@...hat.com,
bhe@...hat.com
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
jaewon31.kim@...il.com, linux-api@...r.kernel.org,
kexec@...ts.infradead.org, Jaewon Kim <jaewon31.kim@...sung.com>
Subject: [RFC PATCH v2 3/3] android: ion: include system heap size in
meminfo extra
In Android system ion system heap size is huge like hundreds of MB. To
know overal system memory usage, include ion system heap size in
proc/meminfo_extra.
To include heap size, use register_meminfo_extra introduced in previous
patch.
Prior to register we need to add stats to show the ion heap usage. Add
total_allocated into ion heap and count it on allocation and freeing. In
a ion heap using ION_HEAP_FLAG_DEFER_FREE, a buffer can be freed from
user but still live on deferred free list. Keep stats until the buffer
is finally freed so that we can cover situation of deferred free thread
stuck problem.
i.e) cat /proc/meminfo_extra | grep IonSystemHeap
IonSystemHeap: 242620 kB
i.e.) show_mem on oom
<6>[ 420.856428] Mem-Info:
<6>[ 420.856433] IonSystemHeap:32813kB
Signed-off-by: Jaewon Kim <jaewon31.kim@...sung.com>
---
drivers/staging/android/ion/ion.c | 2 ++
drivers/staging/android/ion/ion.h | 1 +
drivers/staging/android/ion/ion_system_heap.c | 2 ++
3 files changed, 5 insertions(+)
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 38b51eace4f9..76db91a9f26a 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -74,6 +74,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
INIT_LIST_HEAD(&buffer->attachments);
mutex_init(&buffer->lock);
+ atomic_long_add(len, &heap->total_allocated);
return buffer;
err1:
@@ -95,6 +96,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
buffer->heap->num_of_buffers--;
buffer->heap->num_of_alloc_bytes -= buffer->size;
spin_unlock(&buffer->heap->stat_lock);
+ atomic_long_sub(buffer->size, &buffer->heap->total_allocated);
kfree(buffer);
}
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index 74914a266e25..10867a2e5728 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -157,6 +157,7 @@ struct ion_heap {
u64 num_of_buffers;
u64 num_of_alloc_bytes;
u64 alloc_bytes_wm;
+ atomic_long_t total_allocated;
/* protect heap statistics */
spinlock_t stat_lock;
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index b83a1d16bd89..f7882fb7505d 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -259,6 +259,8 @@ static struct ion_heap *__ion_system_heap_create(void)
if (ion_system_heap_create_pools(heap->pools))
goto free_heap;
+ register_meminfo_extra(&heap->heap.total_allocated, PAGE_SHIFT,
+ "IonSystemHeap");
return &heap->heap;
free_heap:
--
2.13.7
Powered by blists - more mailing lists