>-----Original Message-----
>From: Cédric Le Goater <[email protected]>
>Subject: Re: [PATCH v7 20/23] vfio: Bypass readonly region for dirty tracking
>
>On 10/24/25 10:43, Zhenzhong Duan wrote:
>> When doing ditry tracking or calculating dirty tracking range, readonly
>> regions can be bypassed, because corresponding DMA mappings are
>readonly
>> and never become dirty.
>>
>> This can optimize dirty tracking a bit for passthrough device.
>>
>> Signed-off-by: Zhenzhong Duan <[email protected]>
>> ---
>>   hw/vfio/listener.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c
>> index 0862b2b834..cbd86c79af 100644
>> --- a/hw/vfio/listener.c
>> +++ b/hw/vfio/listener.c
>> @@ -828,7 +828,8 @@ static void
>vfio_dirty_tracking_update(MemoryListener *listener,
>>           container_of(listener, VFIODirtyRangesListener, listener);
>>       hwaddr iova, end;
>>
>> -    if (!vfio_listener_valid_section(section, false, "tracking_update") ||
>> +    /* Bypass readonly section as it never become dirty */
>> +    if (!vfio_listener_valid_section(section, true, "tracking_update") ||
>>           !vfio_get_section_iova_range(dirty->bcontainer, section,
>>                                        &iova, &end, NULL)) {
>>           return;
>> @@ -1087,6 +1088,12 @@ static void
>vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
>>       if (!mr) {
>>           goto out_unlock;
>>       }
>> +
>> +    if (!(iotlb->perm & IOMMU_WO) || mr->readonly) {
>
>
>In case you resend, please add a trace event.

OK, will add:

  trace_vfio_iommu_map_dirty_notify_skip_ro(iova, iova + iotlb->addr_mask);

Thanks
Zhenzhong

>
>Anyhow,
>
>Reviewed-by: Cédric Le Goater <[email protected]>
>
>Thanks,
>
>C.
>
>
>> +        rcu_read_unlock();
>> +        return;
>> +    }
>> +
>>       translated_addr = memory_region_get_ram_addr(mr) + xlat;
>>
>>       ret = vfio_container_query_dirty_bitmap(bcontainer, iova,
>iotlb->addr_mask + 1,
>> @@ -1222,7 +1229,7 @@ static void
>vfio_listener_log_sync(MemoryListener *listener,
>>       int ret;
>>       Error *local_err = NULL;
>>
>> -    if (vfio_listener_skipped_section(section, false)) {
>> +    if (vfio_listener_skipped_section(section, true)) {
>>           return;
>>       }
>>

Reply via email to