From: Greg KH <gregkh@linuxfoundation.org>
To: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: daniel.vetter@ffwll.ch, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, tjmercier@google.com,
linaro-mm-sig@lists.linaro.org, hridya@google.com,
sumit.semwal@linaro.org, christian.koenig@amd.com,
linux-media@vger.kernel.org
Subject: Re: [PATCH V3] dma-buf: ensure unique directory name for dmabuf stats
Date: Fri, 13 May 2022 12:11:28 +0200 [thread overview]
Message-ID: <Yn4u0AG8iC33S3jO@kroah.com> (raw)
In-Reply-To: <1652434689-6203-1-git-send-email-quic_charante@quicinc.com>
On Fri, May 13, 2022 at 03:08:09PM +0530, Charan Teja Kalla wrote:
> 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 dentry name as unique, use the dmabuf fs specific inode
> which is based on the simple atomic variable increment. There is tmpfs
> subsystem too which relies on its own inode generation rather than
> relying on the get_next_ino() for the same reason of avoiding the
> duplicate inodes[1].
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/?id=e809d5f0b5c912fe981dce738f3283b2010665f0
>
> Reported-by: kernel test robot <lkp@intel.com>
The trest robot did not say that the dmabuf stat name was being
duplicated, did it?
> Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
> ---
> Changes in V3:
> -- Used the atomic64 variable to have dmabuf files its own inodes.
> -- Ensured no UAPI breakage as suggested by Christian.
>
> Changes in V2:
> -- Used the atomic64_t variable to generate a unique_id to be appended to inode
> to have an unique directory with name <inode_number-unique_id> -- Suggested by christian
> -- Updated the ABI documentation -- Identified by Greg.
> -- Massaged the commit log.
> -- https://lore.kernel.org/all/1652191562-18700-1-git-send-email-quic_charante@quicinc.com/
>
> Changes in V1:
> -- Used the inode->i_ctime->tv_secs as an id appended to inode to create the
> unique directory with name <inode_number-time_in_secs>.
> -- https://lore.kernel.org/all/1652178212-22383-1-git-send-email-quic_charante@quicinc.com/
>
> drivers/dma-buf/dma-buf.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index a6fc96e..0ad5039 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -407,6 +407,7 @@ static inline int is_dma_buf_file(struct file *file)
>
> static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
> {
> + static atomic64_t dmabuf_inode = ATOMIC64_INIT(0);
> struct file *file;
> struct inode *inode = alloc_anon_inode(dma_buf_mnt->mnt_sb);
>
> @@ -416,6 +417,13 @@ static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
> inode->i_size = dmabuf->size;
> inode_set_bytes(inode, dmabuf->size);
>
> + /*
> + * The ->i_ino acquired from get_next_ino() is not unique thus
> + * not suitable for using it as dentry name by dmabuf stats.
> + * Override ->i_ino with the unique and dmabuffs specific
> + * value.
> + */
> + inode->i_ino = atomic64_add_return(1, &dmabuf_inode);
> file = alloc_file_pseudo(inode, dma_buf_mnt, "dmabuf",
> flags, &dma_buf_fops);
> if (IS_ERR(file))
> --
> 2.7.4
>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: christian.koenig@amd.com, sumit.semwal@linaro.org,
hridya@google.com, daniel.vetter@ffwll.ch, tjmercier@google.com,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3] dma-buf: ensure unique directory name for dmabuf stats
Date: Fri, 13 May 2022 12:11:28 +0200 [thread overview]
Message-ID: <Yn4u0AG8iC33S3jO@kroah.com> (raw)
In-Reply-To: <1652434689-6203-1-git-send-email-quic_charante@quicinc.com>
On Fri, May 13, 2022 at 03:08:09PM +0530, Charan Teja Kalla wrote:
> 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 dentry name as unique, use the dmabuf fs specific inode
> which is based on the simple atomic variable increment. There is tmpfs
> subsystem too which relies on its own inode generation rather than
> relying on the get_next_ino() for the same reason of avoiding the
> duplicate inodes[1].
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/?id=e809d5f0b5c912fe981dce738f3283b2010665f0
>
> Reported-by: kernel test robot <lkp@intel.com>
The trest robot did not say that the dmabuf stat name was being
duplicated, did it?
> Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
> ---
> Changes in V3:
> -- Used the atomic64 variable to have dmabuf files its own inodes.
> -- Ensured no UAPI breakage as suggested by Christian.
>
> Changes in V2:
> -- Used the atomic64_t variable to generate a unique_id to be appended to inode
> to have an unique directory with name <inode_number-unique_id> -- Suggested by christian
> -- Updated the ABI documentation -- Identified by Greg.
> -- Massaged the commit log.
> -- https://lore.kernel.org/all/1652191562-18700-1-git-send-email-quic_charante@quicinc.com/
>
> Changes in V1:
> -- Used the inode->i_ctime->tv_secs as an id appended to inode to create the
> unique directory with name <inode_number-time_in_secs>.
> -- https://lore.kernel.org/all/1652178212-22383-1-git-send-email-quic_charante@quicinc.com/
>
> drivers/dma-buf/dma-buf.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index a6fc96e..0ad5039 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -407,6 +407,7 @@ static inline int is_dma_buf_file(struct file *file)
>
> static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
> {
> + static atomic64_t dmabuf_inode = ATOMIC64_INIT(0);
> struct file *file;
> struct inode *inode = alloc_anon_inode(dma_buf_mnt->mnt_sb);
>
> @@ -416,6 +417,13 @@ static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
> inode->i_size = dmabuf->size;
> inode_set_bytes(inode, dmabuf->size);
>
> + /*
> + * The ->i_ino acquired from get_next_ino() is not unique thus
> + * not suitable for using it as dentry name by dmabuf stats.
> + * Override ->i_ino with the unique and dmabuffs specific
> + * value.
> + */
> + inode->i_ino = atomic64_add_return(1, &dmabuf_inode);
> file = alloc_file_pseudo(inode, dma_buf_mnt, "dmabuf",
> flags, &dma_buf_fops);
> if (IS_ERR(file))
> --
> 2.7.4
>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
next prev parent reply other threads:[~2022-05-13 10:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 9:38 [PATCH V3] dma-buf: ensure unique directory name for dmabuf stats Charan Teja Kalla
2022-05-13 9:38 ` Charan Teja Kalla
2022-05-13 10:11 ` Greg KH [this message]
2022-05-13 10:11 ` Greg KH
2022-05-13 10:18 ` Charan Teja Kalla
2022-05-13 10:18 ` Charan Teja Kalla
2022-05-13 10:26 ` Greg KH
2022-05-13 10:26 ` Greg KH
2022-05-13 10:29 ` Christian König
2022-05-13 10:29 ` Christian König
2022-05-13 10:38 ` Charan Teja Kalla
2022-05-13 10:38 ` Charan Teja Kalla
2022-05-13 10:42 ` Christian König
2022-05-13 10:42 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yn4u0AG8iC33S3jO@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hridya@google.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=quic_charante@quicinc.com \
--cc=sumit.semwal@linaro.org \
--cc=tjmercier@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.