Re: [PATCH rdma-next] IB/mlx5: Symmetric ib_alloc/dealloc_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Dec 09, 2018 at 09:06:45PM +0200, Leon Romanovsky wrote:

> > > > Interesting, I worked on something similar right now, except the fact
> > > > that ib_alloc_device() can return NULL.
> >
> > The build_bug_on takes care of the NULL issue.
> 
> I doubt about that. NULL will be returned at the runtime if kmalloc fails,
> but build_bug_on is checked in compilation phase.

The build_bug_on guarantees that the container_of will only add 0 to
the pointer, and NULL + 0 == NULL.

> > No, this is a kref'd structure with the core code calling kfree, so it
> > is saner for the core code to control the allocation.
> >
> > In both cases the ibdev must be at offset 0, and really, it still
> > needs the macro to enforce that..
> 
> I saw it, but disliked the aesthetic side of your proposal.

Nevertheless, the key thing here is the 0 offset, we must have that
because the core code calls kfree, so any revision to this API must
enforce that property.

Generally the module that calls the alloc should call the kfree to
avoid confusing design.

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux