On Fri, May 23, 2025 at 07:49:40AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicol...@nvidia.com>
> > Sent: Sunday, May 18, 2025 11:21 AM
> > 
> > Now the new ucmd-based object allocator eases the finalize/abort routine,
> > apply this to all existing allocators that aren't protected by any lock.
> > 
> > Upgrade the for-driver vIOMMU alloctor too, and pass down to all existing
> > viommu_alloc op accordingly.
> > 
> > Note that __iommufd_object_alloc_ucmd() builds in some static tests that
> > cover both static_asserts in the iommufd_viommu_alloc(). Thus drop them.
> 
> I may overlook something, but at a quick glance the following check
> Is not covered?
> 
> -             static_assert(__same_type(struct iommufd_viommu,               \
> -                                       ((drv_struct *)NULL)->member));      \

The container_of() inside __iommufd_object_alloc_ucmd() covers that:

#define container_of(ptr, type, member) ({                              \
        void *__mptr = (void *)(ptr);                                   \
        static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \ <<== 
here
                      __same_type(*(ptr), void),                        \
                      "pointer type mismatch in container_of()");       \
        ((type *)(__mptr - offsetof(type, member))); })

> Btw this patch doesn't convert all object allocations to the new helper,
> e.g. ioas. What is the criteria for when to use the old helpers vs. the
> new helpers?

Criteria is "that aren't protected by any lock" mentioned in the
line 2. The ioas has an ioas_creation_lock around finalize() :(

Thanks
Nic

Reply via email to