[PATCH v4 07/24] iommu: Defer __iommu_group_free_device() to be outside group->mutex

Jason Gunthorpe jgg at nvidia.com
Tue May 19 04:47:09 PDT 2026


On Mon, May 18, 2026 at 08:38:50PM -0700, Nicolin Chen wrote:
> __iommu_group_remove_device() holds group->mutex across the entire call to
> __iommu_group_free_device() that performs sysfs removals, tracing, and the
> final kfree(). But in fact, most of these operations don't really need the
> group->mutex.

Are you sure? sysfs requires unique names, and this mutex is providing
a guarentee that will happen. While it shouldn't be possible to race
remove and attach, it is easier to reason about if we don't have to
make this assumption.

> Subsequent changes will introduce sleepable operations to this function:
>  + synchronize_rcu() to defer the gdev->dev put past a grace period.

I'm not keen on that at all.

Jason



More information about the linux-arm-kernel mailing list