From: Zhu Yanjun <zyjzyj2000@gmail.com>
To: Shunsuke Mie <mie@igel.co.jp>
Cc: "Christian König" <christian.koenig@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Doug Ledford" <dledford@redhat.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Jianxin Xiong" <jianxin.xiong@intel.com>,
"Leon Romanovsky" <leon@kernel.org>,
"Maor Gottlieb" <maorg@nvidia.com>,
"Sean Hefty" <sean.hefty@intel.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
linux-media@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
"RDMA mailing list" <linux-rdma@vger.kernel.org>,
"Damian Hobson-Garcia" <dhobsong@igel.co.jp>,
"Takanari Hayama" <taki@igel.co.jp>,
"Tomohito Esaki" <etom@igel.co.jp>
Subject: Re: [RFC PATCH v2 1/1] Providers/rxe: Add dma-buf support
Date: Thu, 30 Sep 2021 19:17:57 +0800 [thread overview]
Message-ID: <CAD=hENfMu+OEW7K-WiYqbP7TpksU=0C9e0YZu3xCbqAurNpT9A@mail.gmail.com> (raw)
In-Reply-To: <CANXvt5oZp=Ap3fEm4nsiP2WfG_c_8o57mN4+PHrQAGHcp-EH2A@mail.gmail.com>
On Thu, Sep 30, 2021 at 7:06 PM Shunsuke Mie <mie@igel.co.jp> wrote:
>
> 2021年9月30日(木) 16:23 Zhu Yanjun <zyjzyj2000@gmail.com>:
> >
> > On Thu, Sep 30, 2021 at 2:58 PM Shunsuke Mie <mie@igel.co.jp> wrote:
> > >
> > > 2021年9月30日(木) 15:37 Zhu Yanjun <zyjzyj2000@gmail.com>:
> > > >
> > > > On Thu, Sep 30, 2021 at 2:20 PM Shunsuke Mie <mie@igel.co.jp> wrote:
> > > > >
> > > > > Implement a new provider method for dma-buf base memory registration.
> > > > >
> > > > > Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
> > > > > ---
> > > > > providers/rxe/rxe.c | 21 +++++++++++++++++++++
> > > > > 1 file changed, 21 insertions(+)
> > > > >
> > > > > diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c
> > > > > index 3c3ea8bb..84e00e60 100644
> > > > > --- a/providers/rxe/rxe.c
> > > > > +++ b/providers/rxe/rxe.c
> > > > > @@ -239,6 +239,26 @@ static struct ibv_mr *rxe_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
> > > > > return &vmr->ibv_mr;
> > > > > }
> > > > >
> > > > > +static struct ibv_mr *rxe_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset,
> > > > > + size_t length, uint64_t iova, int fd,
> > > > > + int access)
> > > > > +{
> > > > > + struct verbs_mr *vmr;
> > > > > + int ret;
> > > > > +
> > > > > + vmr = malloc(sizeof(*vmr));
> > > > > + if (!vmr)
> > > > > + return NULL;
> > > > > +
> > > >
> > > > Do we need to set vmr to zero like the following?
> > > >
> > > > memset(vmr, 0, sizeof(*vmr));
> > > >
> > > > Zhu Yanjun
> > > Thank you for your quick response.
> > >
> > > I think it is better to clear the vmr. Actually the mlx5 driver allocates
> > > the vmr using calloc().
> > >
> > > In addition, rxe_reg_mr() (not rxe_reg_dmabuf_mr()) is used the malloc
> > > and not clear the vmr. I think It has to be fixed too. Should I make
> > > another patch to fix this problem?
> >
> > Yes. Please.
> >
> > Zhu Yanjun
> >
> > >
> > > Thanks a lot.
> > > Shunsuke
> > >
> > > ~
>
> I looked into the vmr more, but there was no need to clear it. Moreover,
> some implementations also use malloc without memory clear.
>
I confronted a lot of problems with memory not initialization.
And a latest bug is https://www.spinics.net/lists/linux-rdma/msg105001.html
So it is a good habit to clear a newly allocated memory.
Zhu Yanjun
> Thanks,
> Shunsuke
next prev parent reply other threads:[~2021-09-30 11:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 6:20 [RFC PATCH v2 0/1] Providers/rxe: Add dma-buf support Shunsuke Mie
2021-09-30 6:20 ` [RFC PATCH v2 1/1] " Shunsuke Mie
2021-09-30 6:37 ` Zhu Yanjun
2021-09-30 6:58 ` Shunsuke Mie
2021-09-30 7:23 ` Zhu Yanjun
2021-09-30 11:06 ` Shunsuke Mie
2021-09-30 11:17 ` Zhu Yanjun [this message]
2021-09-30 11:24 ` Shunsuke Mie
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='CAD=hENfMu+OEW7K-WiYqbP7TpksU=0C9e0YZu3xCbqAurNpT9A@mail.gmail.com' \
--to=zyjzyj2000@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dhobsong@igel.co.jp \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=etom@igel.co.jp \
--cc=jgg@ziepe.ca \
--cc=jianxin.xiong@intel.com \
--cc=leon@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@nvidia.com \
--cc=mie@igel.co.jp \
--cc=sean.hefty@intel.com \
--cc=sumit.semwal@linaro.org \
--cc=taki@igel.co.jp \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).