On 15.09.21 03:25, Stefano Stabellini wrote:
> On Tue, 14 Sep 2021, Oleksandr Andrushchenko wrote:
>>>> What you want to know if how many times register_mmio_handler() will be 
>>>> called from domain_vpci_init().
>>>>
>>>> You introduced a function pci_host_iterate_bridges() that will walk over 
>>>> the bridges and then call the callback vpci_setup_mmio_handler(). So you 
>>>> could introduce a new callback that will return 1 if 
>>>> bridge->ops->register_mmio_handler is not NULL or 0.
>>> Ok, clear. Something like:
>>>
>>>      if ( (rc = domain_vgic_register(d, &count)) != 0 )
>>>          goto fail;
>>>
>>>      *find out how many bridges and update count*
>>>
>>>
>>>      if ( (rc = domain_io_init(d, count + MAX_IO_HANDLER)) != 0 )
>>>          goto fail;
>>>
>> I have the following code now:
>>
>> int domain_vpci_get_num_mmio_handlers(struct domain *d)
>> {
>>       int count;
> count is incremented but not initialized
Excessive cleanup before sending ;)
>
>
>>       if ( is_hardware_domain(d) )
>>           /* For each PCI host bridge's configuration space. */
>>           count += pci_host_get_num_bridges();
>>       else
>>           /*
>>            * VPCI_MSIX_MEM_NUM handlers for MSI-X tables per each PCI device
>>            * being passed through. Maximum number of supported devices
>>            * is 32 as virtual bus topology emulates the devices as embedded
>>            * endpoints.
>>            * +1 for a single emulated host bridge's configuration space. */
>>           count = VPCI_MSIX_MEM_NUM * 32 + 1;
>>       return count;
>> }
>>
>> Please note that we cannot tell how many PCIe devices are going to be passed 
>> through
>>
>> So, worst case for DomU is going to be 65 to what we already have...
>>
>> This sounds scary a bit as most probably we won't pass through 32 devices 
>> most of the
>>
>> time, but will make d->arch.vmmio.handlers almost 4 times bigger then it is 
>> now.
>>
>> This may have influence on the MMIO handlers performance...
> I am OK with that given that it doesn't affect performance until you
> actually start creating too many virtual devices for the DomU. In other
> words, find_mmio_handler restricts the search to vmmio->num_entries, so
> as long as most entries are allocated but unused, we should be fine.

Ok, fine, so I'll have this change as above in v2.

Thanks,

Oleksandr

Reply via email to