[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=hENfMu+OEW7K-WiYqbP7TpksU=0C9e0YZu3xCbqAurNpT9A@mail.gmail.com>
Date: Thu, 30 Sep 2021 19:17:57 +0800
From: Zhu Yanjun <zyjzyj2000@...il.com>
To: Shunsuke Mie <mie@...l.co.jp>
Cc: Christian König <christian.koenig@....com>,
Alex Deucher <alexander.deucher@....com>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Doug Ledford <dledford@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Jianxin Xiong <jianxin.xiong@...el.com>,
Leon Romanovsky <leon@...nel.org>,
Maor Gottlieb <maorg@...dia.com>,
Sean Hefty <sean.hefty@...el.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
dri-devel@...ts.freedesktop.org, linaro-mm-sig@...ts.linaro.org,
linux-media@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
RDMA mailing list <linux-rdma@...r.kernel.org>,
Damian Hobson-Garcia <dhobsong@...l.co.jp>,
Takanari Hayama <taki@...l.co.jp>,
Tomohito Esaki <etom@...l.co.jp>
Subject: Re: [RFC PATCH v2 1/1] Providers/rxe: Add dma-buf support
On Thu, Sep 30, 2021 at 7:06 PM Shunsuke Mie <mie@...l.co.jp> wrote:
>
> 2021年9月30日(木) 16:23 Zhu Yanjun <zyjzyj2000@...il.com>:
> >
> > On Thu, Sep 30, 2021 at 2:58 PM Shunsuke Mie <mie@...l.co.jp> wrote:
> > >
> > > 2021年9月30日(木) 15:37 Zhu Yanjun <zyjzyj2000@...il.com>:
> > > >
> > > > On Thu, Sep 30, 2021 at 2:20 PM Shunsuke Mie <mie@...l.co.jp> wrote:
> > > > >
> > > > > Implement a new provider method for dma-buf base memory registration.
> > > > >
> > > > > Signed-off-by: Shunsuke Mie <mie@...l.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
Powered by blists - more mailing lists