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

Commit eb7c9b7d authored by Patrick Daly's avatar Patrick Daly Committed by Gerrit - the friendly Code Review server
Browse files

ion: Convert allocation counters to long



On 64bit platforms, the amount of memory allocated by ion can exceed
32 bits.  Therefore the counters which track this information must be
64 bits as well.

Change-Id: I81daf2cec78de5787279daaf98264c5462ba6645
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
Signed-off-by: default avatarPrakash Gupta <guptap@codeaurora.org>
parent db4d5501
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -264,7 +264,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_add(len, &heap->total_allocated);
	atomic_long_add(len, &heap->total_allocated);
	return buffer;

err:
@@ -282,7 +282,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
		buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
	buffer->heap->ops->unmap_dma(buffer->heap, buffer);

	atomic_sub(buffer->size, &buffer->heap->total_allocated);
	atomic_long_sub(buffer->size, &buffer->heap->total_allocated);
	buffer->heap->ops->free(buffer);
	vfree(buffer->pages);
	kfree(buffer);
@@ -320,7 +320,7 @@ static void ion_buffer_add_to_handle(struct ion_buffer *buffer)
{
	mutex_lock(&buffer->lock);
	if (buffer->handle_count == 0)
		atomic_add(buffer->size, &buffer->heap->total_handles);
		atomic_long_add(buffer->size, &buffer->heap->total_handles);

	buffer->handle_count++;
	mutex_unlock(&buffer->lock);
@@ -346,7 +346,7 @@ static void ion_buffer_remove_from_handle(struct ion_buffer *buffer)
		task = current->group_leader;
		get_task_comm(buffer->task_comm, task);
		buffer->pid = task_pid_nr(task);
		atomic_sub(buffer->size, &buffer->heap->total_handles);
		atomic_long_sub(buffer->size, &buffer->heap->total_handles);
	}
	mutex_unlock(&buffer->lock);
}
@@ -1951,10 +1951,10 @@ void show_ion_usage(struct ion_device *dev)
					"Total orphaned size");
	pr_info("---------------------------------\n");
	plist_for_each_entry(heap, &dev->heaps, node) {
		pr_info("%16.s 0x%16.x 0x%16.x\n",
			heap->name, atomic_read(&heap->total_allocated),
			atomic_read(&heap->total_allocated) -
			atomic_read(&heap->total_handles));
		pr_info("%16.s 0x%16.lx 0x%16.lx\n",
			heap->name, atomic_long_read(&heap->total_allocated),
			atomic_long_read(&heap->total_allocated) -
			atomic_long_read(&heap->total_handles));
		if (heap->debug_show)
			heap->debug_show(heap, NULL, 0);

+3 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 * drivers/staging/android/ion/ion_priv.h
 *
 * Copyright (C) 2011 Google, Inc.
 * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
@@ -200,8 +200,8 @@ struct ion_heap {
	struct task_struct *task;

	int (*debug_show)(struct ion_heap *heap, struct seq_file *, void *);
	atomic_t total_allocated;
	atomic_t total_handles;
	atomic_long_t total_allocated;
	atomic_long_t total_handles;
};

/**