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

Re: [RFC PATCH 03/10] xen: pci: introduce ats_list_lock


  • To: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 17 Feb 2023 08:39:23 +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=Vbg/P1bEEq+4IDR//iZ/hp61aCx0MKgYlmu4RpC9bWw=; b=hxs3irqWbna6ToMewCDB+xp+eSnxylP7+6eBMRJNzZc54hW4pK+l9J9vlohNnILb7uad4iTeTTTgSgLq1tOKcB3ujCZI5rvK1PskoLIo4gPz+EA0Cx0SProLsJVzQOPIERZ3Z8zHTzmkHe4wcyvTwYSXg5QWuhgZlzi3X9KBgzUZIq3lRjG6rzd/Z3P3cEDEwsUzqkdQPrjpXzO+cOibb3fefmwJeE2Xjy/tu33cr6wgsUOEdZQr31ZEU9Uv2uO/KqSvxCqKeHRCv6YS++t262NIW4QgZgjelN7IzWaDsrelLcpeiG6YpbJ9WiA05UTp0kk34mC1cTy9uclY3othjQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ml9aIFRZw3pTJL2NrhAduroM9qMr1COUdOvdJJ+1SpLi2ZKYdcozSZjE1A/PO21tuiyGhZ2lVMmBotyA1Fc3IK5huJcs91xdUttj+RO/c4lqzFCIblg0gFtji7HP/CLSAMyr/Ku6MGfVsOQLccObjNmxIsJtRaW27SoZTnumSwa/SxCiHlBmcU1LAuCJNbuPlJRBE/V6MrX9qM+7emR7QyQHxWKH2URPc9+BiH8UkOl8To5zOzCBMVrYHzGJnCbV5VsBVgkGmLYQAMzG7Tpwvw7f/Dqc1T7XIkqG8RvKEfuSY6ybmAdlX29nBPkGH3iuzGpj+wjQOAXI1mydOnHaVw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Fri, 17 Feb 2023 07:39:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17.02.2023 02:20, Volodymyr Babchuk wrote:
> Jan Beulich <jbeulich@xxxxxxxx> writes:
>> On 27.01.2023 00:56, Stefano Stabellini wrote:
>>> On Wed, 31 Aug 2022, Volodymyr Babchuk wrote:
>>>> --- a/xen/drivers/passthrough/pci.c
>>>> +++ b/xen/drivers/passthrough/pci.c
>>>> @@ -1641,6 +1641,7 @@ void iommu_dev_iotlb_flush_timeout(struct domain *d, 
>>>> struct pci_dev *pdev)
>>>>  {
>>>>      pcidevs_lock();
>>>>  
>>>> +    /* iommu->ats_list_lock is taken by the caller of this function */
>>>
>>> This is a locking inversion. In all other places we take pcidevs_lock
>>> first, then ats_list_lock lock. For instance look at
>>> xen/drivers/passthrough/pci.c:deassign_device that is called with
>>> pcidevs_locked and then calls iommu_call(... reassign_device ...) which
>>> ends up taking ats_list_lock.
>>>
>>> This is the only exception. I think we need to move the
>>> spin_lock(ats_list_lock) from qinval.c to here.
>>
>> First question here is what the lock is meant to protect: Just the list,
>> or also the ATS state change (i.e. serializing enable and disable against
>> one another). In the latter case the lock also wants naming differently.
> 
> My intention was to protect list only. But I believe you are right and
> we should protect the whole state. I'll rename the lock to ats_lock.
> 
>> Second question is who is to acquire the lock. Why isn't this done _in_
>> {en,dis}able_ats_device() themselves? That would then allow to further
>> reduce the locked range, because at least the pci_find_ext_capability()
>> call and the final logging can occur without the lock held.
> 
> You are right, I'll extended {en,dis}able_ats_device() API to pass
> pointer to the lock.

Hmm, that'll make for an odd interface. I was wondering in the past
already why we don't have a backref from the PCI dev to its controlling
IOMMU (might be ambiguous and hence better left unset for bridges,
especially host ones, but I think ATS is being fiddled with only for
leaf devices; would need double checking of course).

Jan



 


Rackspace

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