Re: [GIT pull] core/urgent for v5.18-rc6

From: Jean-Philippe Brucker
Date: Mon May 09 2022 - 11:03:02 EST


Hi,

On Sun, May 08, 2022 at 11:36:23AM -0700, Linus Torvalds wrote:
> And yes, the mmu notifiers do then take that mmgrab reference to the
> mm, so it all works.
>
> But it sure looks horrendously ugly. Saving off a 'struct mm_struct'
> pointer with having basically an accidental reference to it is WRONG.

Yes it is fragile. We're currently reworking iommu_sva_bind_device() to
factor more code into the IOMMU core and to add explicit mmgrab/mmdrop, so
once this lands we won't depend on mmu_notifier_register() anymore to hold
the mm reference.

https://lore.kernel.org/linux-iommu/20220502014842.991097-9-baolu.lu@xxxxxxxxxxxxxxx/

Thanks,
Jean