[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250207235536.GF3660748@nvidia.com>
Date: Fri, 7 Feb 2025 19:55:36 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Dan Williams <dan.j.williams@...el.com>
Cc: Andy Gospodarek <andrew.gospodarek@...adcom.com>,
Aron Silverton <aron.silverton@...cle.com>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Dave Jiang <dave.jiang@...el.com>, David Ahern <dsahern@...nel.org>,
Andy Gospodarek <gospo@...adcom.com>,
Christoph Hellwig <hch@...radead.org>,
Itay Avraham <itayavr@...dia.com>, Jiri Pirko <jiri@...dia.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Jakub Kicinski <kuba@...nel.org>, Leonid Bloch <lbloch@...dia.com>,
Leon Romanovsky <leonro@...dia.com>, linux-cxl@...r.kernel.org,
linux-rdma@...r.kernel.org, netdev@...r.kernel.org,
Saeed Mahameed <saeedm@...dia.com>,
"Nelson, Shannon" <shannon.nelson@....com>
Subject: Re: [PATCH v4 01/10] fwctl: Add basic structure for a class
subsystem with a cdev
On Fri, Feb 07, 2025 at 03:32:00PM -0800, Dan Williams wrote:
> > +#define fwctl_alloc_device(parent, ops, drv_struct, member) \
> > + ({ \
> > + static_assert(__same_type(struct fwctl_device, \
> > + ((drv_struct *)NULL)->member)); \
> > + static_assert(offsetof(drv_struct, member) == 0); \
> > + (drv_struct *)_fwctl_alloc_device(parent, ops, \
> > + sizeof(drv_struct)); \
> > + })
>
> I have already suggested someone else copy this approach to context
> allocation. What do you think of generalizing this in
> include/linux/container_of.h as:
I also have several places doing that too in iommufd and I think we
have a variation in rdma as well.
Let me suggest we go around after the fact and propose a consolidation
patch. I think it will be easier to understand like that?
> #define container_alloc(core_struct, drv_struct, member, alloc_fn, ...) \
> ({ \
> static_assert(__same_type(core_struct, \
> ((drv_struct *)NULL)->member)); \
> static_assert(offsetof(drv_struct, member) == 0); \
> (drv_struct *)(alloc_fn)(sizeof(drv_struct), __VA_ARGS__); \
> })
It makes sense to me
Jason
Powered by blists - more mailing lists