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

Re: [RFC PATCH 01/10] xen: pci: add per-domain pci list lock


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 27 Jan 2023 09:01:26 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=0YnwN72aDMnVZqr5t87pf8kep0aqn1v1Av6qUJI9B34=; b=RyaddUlONyHCWP34F9N0glczzX18E1GhAVl5zfelWZuCrRag1lje5xBNAghIBkqqALTGF2tCMjUWumarBdxrc5oSOROPZBYhN+MzkRtpmjnzpRQPgPgtQz52TEddJJdHOLSkGsZHFb6kBqMv9xYqEFjcqBkkd/Z4Pp7Qu43GOuE86moEOivD8hOj7BIfhAvuIUkeR9mflQzkcO8LLD+otYbD9GmhsIBlheOrcTYOPMcd8PQxaj1P50mBRAhYjYxq1CTWgD3rv4OWp8eh6EhEsOOfWBTDVEOsAUk5jojoYUsfQnvuFHZI2qeVW6bLW1uppOFxTdkiHBBWTUgRVKPzxg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GW0OGY1D87CM8jgZm0mLxPeowJ3CtaXPwRD/DlByNkch1mr3PZ6rI9otkp1zAaX9WQedOPip7oF5ecQ3HMqBVO7jnM5YvIyXuS1Ki6pKWm5z6T2JpDHHdnnl2JaXzGgzV/TQ9O4QIzAEHvrMIjUV+ASVX+6Tjlv8GMl5Jh6Ouwzgo5JxmFSk1MUtuor3TtbMTei09DAbwfmnPqoLwXtJxSnLkk3gkkJ8lDGS24dfP+V7ZnrTLIFFYUQZbhw+wPEaganRTiVOx0yhwqchetOWpm9SUPHuL6zyK1MRL4cfOyHAVFQ6PhdaQ4jrmKWeGHymYM+QQoFPsa1yFMWyOVM5/g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Stewart.Hildebrand@xxxxxxx, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 27 Jan 2023 08:01:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.01.2023 00:18, Stefano Stabellini wrote:
> On Wed, 31 Aug 2022, Volodymyr Babchuk wrote:
>> @@ -1571,6 +1595,7 @@ static int iommu_get_device_group(
>>          if ( sdev_id < 0 )
>>          {
>>              pcidevs_unlock();
>> +            spin_unlock(&d->pdevs_lock);
> 
> lock inversion
> 
> 
>>              return sdev_id;
>>          }
>>  
>> @@ -1581,6 +1606,7 @@ static int iommu_get_device_group(
>>              if ( unlikely(copy_to_guest_offset(buf, i, &bdf, 1)) )
>>              {
>>                  pcidevs_unlock();
>> +                spin_unlock(&d->pdevs_lock);
> 
> lock inversion
> 
> 
>>                  return -EFAULT;
>>              }
>>              i++;
>> @@ -1588,6 +1614,7 @@ static int iommu_get_device_group(
>>      }
>>  
>>      pcidevs_unlock();
>> +    spin_unlock(&d->pdevs_lock);
> 
> lock inversion

While from a cosmetic perspective I of course agree that releasing locks
would better be done the opposite order of acquiring whenever possible,
I'd like to point out that lock release alone is never subject to "lock
order" issues. We do have a couple of cases (I think) where we actually
do so because otherwise respective code would end up uglier, or because
we want to limit locking regions as much as possible (I'm sorry, I don't
have an example to hand).

>> --- a/xen/include/xen/sched.h
>> +++ b/xen/include/xen/sched.h
>> @@ -457,6 +457,7 @@ struct domain
>>  
>>  #ifdef CONFIG_HAS_PCI
>>      struct list_head pdev_list;
>> +    spinlock_t pdevs_lock;
> 
> I think it would be better called "pdev_lock" but OK either way

I'm of two minds here: On one hand the lock is to guard all devices, so
plural looks applicable. Otoh the list head field uses singular as well.

Jan



 


Rackspace

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