Re: [PATCH v4 2/3] gup: introduce unpin_user_folio_dirty_locked()

From: lizhe . 67
Date: Thu Jun 19 2025 - 08:49:48 EST


On Thu, 19 Jun 2025 09:35:04 -0300, jgg@xxxxxxxx wrote:

> On Thu, Jun 19, 2025 at 05:05:42PM +0800, lizhe.67@xxxxxxxxxxxxx wrote:
>
> > As I understand it, there seem to be some issues with this
> > implementation. How can we obtain the value of dma->has_reserved
> > (acquiring it within vfio_pin_pages_remote() might be a good option)
>
> Yes, you record it during vfio_pin_pages operations. If VFIO call
> iommu_map on something that went down the non-GUP path then it sets
> the flag.
>
> > and ensure that this value remains unchanged from the time of
> > assignment until we perform the unpin operation?
>
> Map/unmap are paired and not allowed to race so that isn't an issue.
>
> > I've searched through the code and it appears that there are
> > instances where SetPageReserved() is called outside of the
> > initialization phase. Please correct me if I am wrong.
>
> It should not be relevant here, pages under use by VFIO are not
> permitted to change it will break things.

Then this approach appears to be no problem, and there’s no need to
introduce any new interfaces. All modifications remain internal to
vfio. I’ll send out a v5 patch based on this approach.

Thanks,
Zhe