[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZxvJt740XDjRmEl5@Asurada-Nvidia>
Date: Fri, 25 Oct 2024 09:39:19 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: Alexey Kardashevskiy <aik@....com>, <kevin.tian@...el.com>,
<will@...nel.org>, <joro@...tes.org>, <suravee.suthikulpanit@....com>,
<robin.murphy@....com>, <dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>,
<shuah@...nel.org>, <linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>,
<eric.auger@...hat.com>, <jean-philippe@...aro.org>, <mdf@...nel.org>,
<mshavit@...gle.com>, <shameerali.kolothum.thodi@...wei.com>,
<smostafa@...gle.com>, <yi.l.liu@...el.com>, <zhangfei.gao@...aro.org>,
<patches@...ts.linux.dev>
Subject: Re: [PATCH v4 01/14] iommufd/viommu: Introduce IOMMUFD_OBJ_VDEVICE
and its related struct
On Fri, Oct 25, 2024 at 10:20:54AM -0300, Jason Gunthorpe wrote:
> On Fri, Oct 25, 2024 at 06:53:01PM +1100, Alexey Kardashevskiy wrote:
> > > +#define iommufd_vdevice_alloc(ictx, drv_struct, member) \
> > > + ({ \
> > > + static_assert( \
> > > + __same_type(struct iommufd_vdevice, \
> > > + ((struct drv_struct *)NULL)->member)); \
> > > + static_assert(offsetof(struct drv_struct, member.obj) == 0); \
> > > + container_of(_iommufd_object_alloc(ictx, \
> > > + sizeof(struct drv_struct), \
> > > + IOMMUFD_OBJ_VDEVICE), \
> > > + struct drv_struct, member.obj); \
> > > + })
> > > #endif
> >
> > A nit: it hurts eyes to read:
> >
> > mock_vdev = iommufd_vdevice_alloc(viommu->ictx, mock_vdevice, core);
> >
> > vs.
> >
> > mock_vdev = iommufd_vdevice_alloc(viommu->ictx, struct mock_vdevice, core);
> >
> > as for the former I go searching for a "mock_vdevice" variable and for the
> > latter it is clear it is 1) a macro 2) which does some type checking.
> >
> > also, it makes it impossible to pass things like typeof(..) or a type from
> > typedef. Thanks,
>
> Makes sense to me
Ack. Will change accordingly.
> And the container_of() should not be used in these macros, the point
> was to avoid it to make the PTR_ERR behavior cleraer. Just put a force
> type cast
I recall that I changed it for a compiler complaint. But it seems
to be gone now. Will change it back.
Thanks
Nicolin
Powered by blists - more mailing lists