[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1652178212-22383-1-git-send-email-quic_charante@quicinc.com>
Date: Tue, 10 May 2022 15:53:32 +0530
From: Charan Teja Kalla <quic_charante@...cinc.com>
To: <sumit.semwal@...aro.org>, <christian.koenig@....com>,
<daniel.vetter@...ll.ch>, <gregkh@...uxfoundation.org>,
<tjmercier@...gle.com>
CC: <linux-media@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>,
<linaro-mm-sig@...ts.linaro.org>, <linux-kernel@...r.kernel.org>,
"Charan Teja Kalla" <quic_charante@...cinc.com>
Subject: [PATCH] dmabuf: ensure unique directory name for dmabuf stats
The dmabuf file uses get_next_ino()(through dma_buf_getfile() ->
alloc_anon_inode()) to get an inode number and uses the same as a
directory name under /sys/kernel/dmabuf/buffers/<ino>. This directory is
used to collect the dmabuf stats and it is created through
dma_buf_stats_setup(). At current, failure to create this directory
entry can make the dma_buf_export() to fail.
Now, as the get_next_ino() can definitely give a repetitive inode no
causing the directory entry creation to fail with -EEXIST. This is a
problem on the systems where dmabuf stats functionality is enabled on
the production builds can make the dma_buf_export(), though the dmabuf
memory is allocated successfully, to fail just because it couldn't
create stats entry.
This issue we are able to see on the snapdragon system within 13 days
where there already exists a directory with inode no "122602" so
dma_buf_stats_setup() failed with -EEXIST as it is trying to create
the same directory entry.
To make the directory entry as unique, append the inode creation time to
the inode. With this change the stats directory entries will be in the
format of: /sys/kernel/dmabuf/buffers/<inode no>-<inode creation time in
secs>.
Signed-off-by: Charan Teja Kalla <quic_charante@...cinc.com>
---
drivers/dma-buf/dma-buf-sysfs-stats.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma-buf/dma-buf-sysfs-stats.c b/drivers/dma-buf/dma-buf-sysfs-stats.c
index 2bba0ba..292cb31 100644
--- a/drivers/dma-buf/dma-buf-sysfs-stats.c
+++ b/drivers/dma-buf/dma-buf-sysfs-stats.c
@@ -192,7 +192,8 @@ int dma_buf_stats_setup(struct dma_buf *dmabuf)
/* create the directory for buffer stats */
ret = kobject_init_and_add(&sysfs_entry->kobj, &dma_buf_ktype, NULL,
- "%lu", file_inode(dmabuf->file)->i_ino);
+ "%lu-%lu", file_inode(dmabuf->file)->i_ino,
+ file_inode(dmabuf->file)->i_ctime.tv_sec);
if (ret)
goto err_sysfs_dmabuf;
--
2.7.4
Powered by blists - more mailing lists