android: ion: add exp_name for dma buffer

Add the exp_name for dma buffer with KBUILD_MODNAME, heap->name, current->tgid
and task_comm.

Such as ion_alloc-ion_system_heap-263-allocator@4.0-service

Module: ion_alloc
Heap  : ion_system_heap
tgid  : 263
task  : allocator@4.0-service

Change-Id: I4f11394ae2470dcd2b113b4cfd01d70be9c67c8d
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
Jianqun Xu
2020-12-16 19:24:43 +08:00
committed by Tao Huang
parent d9d3e43de1
commit 7e32ad8b9a
2 changed files with 10 additions and 3 deletions

View File

@@ -1344,8 +1344,8 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
return ret;
seq_puts(s, "\nDma-buf Objects:\n");
seq_printf(s, "%-8s\t%-8s\t%-8s\t%-8s\texp_name\t%-8s\n",
"size", "flags", "mode", "count", "ino");
seq_printf(s, "%-8s\t%-8s\t%-8s\t%-8s\t%-60s\t%-8s\n",
"size", "flags", "mode", "count", "exp_name", "ino");
list_for_each_entry(buf_obj, &db_list.head, list_node) {
ret = mutex_lock_interruptible(&buf_obj->lock);
@@ -1356,7 +1356,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
continue;
}
seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\t%s\n",
seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%-60s\t%08lu\t%s\n",
buf_obj->size,
buf_obj->file->f_flags, buf_obj->file->f_mode,
file_count(buf_obj->file),

View File

@@ -326,6 +326,7 @@ static void ion_dma_buf_release(struct dma_buf *dmabuf)
struct ion_buffer *buffer = dmabuf->priv;
_ion_buffer_destroy(buffer);
kfree(dmabuf->exp_name);
}
static void *ion_dma_buf_vmap(struct dma_buf *dmabuf)
@@ -461,6 +462,7 @@ int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags)
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
int fd;
struct dma_buf *dmabuf;
char task_comm[TASK_COMM_LEN];
pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__,
len, heap_id_mask, flags);
@@ -492,14 +494,19 @@ int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags)
if (IS_ERR(buffer))
return PTR_ERR(buffer);
get_task_comm(task_comm, current->group_leader);
exp_info.ops = &dma_buf_ops;
exp_info.size = buffer->size;
exp_info.flags = O_RDWR;
exp_info.priv = buffer;
exp_info.exp_name = kasprintf(GFP_KERNEL, "%s-%s-%d-%s", KBUILD_MODNAME,
heap->name, current->tgid, task_comm);
dmabuf = dma_buf_export(&exp_info);
if (IS_ERR(dmabuf)) {
_ion_buffer_destroy(buffer);
kfree(exp_info.exp_name);
return PTR_ERR(dmabuf);
}