From 7e32ad8b9afb9ea53002a1ac77a3aef56099e88a Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Wed, 16 Dec 2020 19:24:43 +0800 Subject: [PATCH] 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 --- drivers/dma-buf/dma-buf.c | 6 +++--- drivers/staging/android/ion/ion.c | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index c5f2f789a7e8..f1f0cee2a0a4 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -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), diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 77ebb7e2f3a4..a1721b0bddf0 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -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); }