Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 986dc35b authored by Liam Mark's avatar Liam Mark
Browse files

staging: android: ion: Track total memory allocations per heap



Add support to track the total amount of memory allocated by each ION
heap. This information makes it easier to identify if an ION client is
responsible for a memory leak.

Change-Id: I44638316b6462d28ec182f58b3b3e5cc99716f33
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
parent 4e80278d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
	mutex_lock(&dev->buffer_lock);
	ion_buffer_add(dev, buffer);
	mutex_unlock(&dev->buffer_lock);
	atomic_long_add(len, &heap->total_allocated);
	return buffer;

err1:
@@ -196,6 +197,7 @@ static void _ion_buffer_destroy(struct ion_buffer *buffer)
	rb_erase(&buffer->node, &dev->buffers);
	mutex_unlock(&dev->buffer_lock);

	atomic_long_sub(buffer->size, &buffer->heap->total_allocated);
	if (heap->flags & ION_HEAP_FLAG_DEFER_FREE)
		ion_heap_freelist_add(heap, buffer);
	else
+1 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ struct ion_heap {
	spinlock_t free_lock;
	wait_queue_head_t waitqueue;
	struct task_struct *task;
	atomic_long_t total_allocated;

	int (*debug_show)(struct ion_heap *heap, struct seq_file *, void *);
};