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

Re: [PATCH v12.2 01/15] vpci: use per-domain PCI lock to protect vpci structure


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Wed, 24 Jan 2024 00:00:44 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=daKAEf94PhbZ9hRj/TDn2v6ZtbA/LJclSAowjn1m8Ok=; b=V9hu4g2ZUH5efRDvLaXfoP+CI2/g6mlj98A3YgKRVl0ZKCAj1gNNp14hGRxEJVH3ScmP/uns9P1eQZUR8byWoKOyqWCNB8jw8co2Yqf5s/nv+cTzlQPcCdhn/eyVVYhr9iAJ0Pgmrmpew39wnPMyS403KOETkh16FBJ+0u0ZrRYfryBk3jmmCAD40IhZr/zqd85g01Wr6WNfL7PsMruV7q0aYWqUVJ3coXi5Ki5nx2V9Un/3bl6lAG1+JzlVWUb8YaPNGyREBOMn4eFO7NhlnxmnK0hhcqhUksKADbhDm+AElUkiErlFaVNqCbFWiremgNnxl05xzctPDVD/GQgEbQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FkPDxIit7CVD86FJRxUyHPyGbwghoiJNp3LovfmhA2jPK0bG1jW2Ap9R46rCSF08Xmb3z/mdCiDIRAu2VOlicz7C5/ss5xN60cuRV48uz8brIXkAUdicIAb0Tmc00Uz/vBio85dlRwpfeZTv5WkjpamteWOu1RZKEtuM+ysIYSS3rbPaeW0AM5/wTjFGDwqFXpSGHiomCa76g9vKYBYUoC6pOLDax8uwP+k66idEYAwzmYz11HEF1Yi3t+FGR1Ux1CE39aoAlz3IRmPuUOz+GxeFe01Um5gPXUoXJfZoQUh3DttZoaBnaJOJBEM+kZKEZAVVPWMjUrrJKi7gcTjjQg==
  • Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 24 Jan 2024 05:01:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 1/23/24 10:07, Roger Pau Monné wrote:
> On Tue, Jan 23, 2024 at 03:32:12PM +0100, Jan Beulich wrote:
>> On 15.01.2024 20:43, Stewart Hildebrand wrote:
>>> @@ -2888,6 +2888,8 @@ int allocate_and_map_msi_pirq(struct domain *d, int 
>>> index, int *pirq_p,
>>>  {
>>>      int irq, pirq, ret;
>>>  
>>> +    ASSERT(pcidevs_locked() || rw_is_locked(&d->pci_lock));
>>
>> If either lock is sufficient to hold here, ...
>>
>>> --- a/xen/arch/x86/physdev.c
>>> +++ b/xen/arch/x86/physdev.c
>>> @@ -123,7 +123,9 @@ int physdev_map_pirq(domid_t domid, int type, int 
>>> *index, int *pirq_p,
>>>  
>>>      case MAP_PIRQ_TYPE_MSI:
>>>      case MAP_PIRQ_TYPE_MULTI_MSI:
>>> +        pcidevs_lock();
>>>          ret = allocate_and_map_msi_pirq(d, *index, pirq_p, type, msi);
>>> +        pcidevs_unlock();
>>>          break;
>>
>> ... why is it the global lock that's being acquired here?
>>
> 
> IIRC (Stewart can further comment) this is done holding the pcidevs
> lock to keep the path unmodified, as there's no need to hold the
> per-domain rwlock.
> 

Although allocate_and_map_msi_pirq() was itself acquiring the global 
pcidevs_lock() before this patch, we could just as well use 
read_lock(&d->pci_lock) here instead now. It seems like a good optimization to 
make, so if there aren't any objections I'll change it to 
read_lock(&d->pci_lock).



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.