Re: [PATCH v4 07/18] iommufd: Add IOMMU_HWPT_GET_DIRTY_IOVA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/10/2023 07:32, Tian, Kevin wrote:
>> From: Joao Martins <joao.m.martins@xxxxxxxxxx>
>> Sent: Thursday, October 19, 2023 4:27 AM
>>
>> Underneath it uses the IOMMU domain kernel API which will read the dirty
>> bits, as well as atomically clearing the IOPTE dirty bit and flushing the
>> IOTLB at the end. The IOVA bitmaps usage takes care of the iteration of the
> 
> what does 'atomically' try to convey here?
> 
Meaning that the test/update PTE events by IOMMU and CPU must not intersect, iow
in a mutually exclusive manner. e.g. IOMMU hw initiates an atomic transaction
and checks if the PTE dirty bit is set and then update if it's not. CPU uses
locked bit/cmpxchg manipulation instructions to ensure the testing and clearing
is done in that way. iommu hw never clears the bit, but the update needs to
ensure that IOMMU won't lose info and miss setting dirty bits after CPU finishes
its instruction or vice-versa. But sentence this refers to the IOMMU driver
implementation and the IOMMU hardware it is 'frontending'.

>> +/**
>> + * struct iommu_hwpt_get_dirty_iova -
>> ioctl(IOMMU_HWPT_GET_DIRTY_IOVA)
> 
> IOMMU_HWPT_GET_DIRTY_BITMAP? IOVA usually means one address
> but here we talk about a bitmap of which one bit represents a page.
> 
My reading of 'IOVA' was actually in the plural form -- Probably my bad english.

HWPT_GET_DIRTY_BITMAP is OK too (maybe better); I guess more explicit
on how it's structured the reporting/returning data.

>> + * @size: sizeof(struct iommu_hwpt_get_dirty_iova)
>> + * @hwpt_id: HW pagetable ID that represents the IOMMU domain.
>> + * @flags: Flags to control dirty tracking status.
>> + * @iova: base IOVA of the bitmap first bit
>> + * @length: IOVA range size
>> + * @page_size: page size granularity of each bit in the bitmap
>> + * @data: bitmap where to set the dirty bits. The bitmap bits each
>> + * represent a page_size which you deviate from an arbitrary iova.
>> + * Checking a given IOVA is dirty:
>> + *
>> + *  data[(iova / page_size) / 64] & (1ULL << (iova % 64))
> 
> (1ULL << ((iova / page_size) % 64)
> 
Ah!

> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

Thanks



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux