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

Re: [PATCH v5 03/14] vpci: move lock outside of struct vpci


  • To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 26 Jan 2022 12:13:18 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=8NX03lr0AxXyxB81rw2UgGEiN02nL+aX5LRQzc8eG9w=; b=cs+cM92uNp9oEueLCsf6v30poTi0PSAMy7eulDn7P2Yk6MblA405dCka7+FNR/w/GBZgdR4w64l+9l4bbyXOVfOYnOzJdWnhICVobDYzs6jDHjXY5M4iCI8e5A0aLCN/Slgus5SwPRtS236iui2xPZw6DA3VQ+ZvP+u3xdwNZOAm856tzumZwfjQb5pFc95JPMGmxAPU+5kieA+JHHmfli7eAH2xBgthGiZB2/dYF5vHhgsYinqvioTl5e8+MDaS5O1Miq23CYXwM+RoVCPwbeLUYqYxJ8o72SWMv3hpVNsUU85fS46YDj04VQspQqLeBjXkm2tJRBacSlAvK8/0aA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S4L+8AW3RQzBZCkEBln+yM/JRzWfQxtmD8zV1a0NLiUWou82txA9V8iqrtUBprNV2UCKLX4sTY7VzOdxAucegMmJW6j5jIagHmDMDSUGHbRfhe6z1zTHyrgvmqHpKw4tNLYA4CBsOWzuDcs7lscBUHRFcWQuKQwt2dOIarC0HARvUZN7La2+m7NXqSQ4l7KKM5cRTj4zdK9Y86pJFBERkiVce9+m5MCkXXh+Fdw0srP0DTA7yUQtTnyBiLtjTcDpDEAJkZneACxX93v/FU14L5LX1rbbgKaaSttvfkINlhhHXwcZAcKFaJEWcEsDYuQb4VH23sn9MdJRvRbgBlHllQ==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Wed, 26 Jan 2022 11:13:39 +0000
  • Ironport-data: A9a23:yj/Mn63MQyihAg3c+PbD5ed3kn2cJEfYwER7XKvMYLTBsI5bp2cGz WJNUGzQaPqLYTT8KtpwboXg908BvMTRz9E1TQI5pC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCanAZqTNMEn9700o6wbBh2+aEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhgdsr4 owKts2MEAYzErbzt88zVB1YHHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r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1xFPp3EH0kWiukIy4OviummUkCdahCThLxtHfBOpIzHNYZcPTLqjQFlDDnAj9DAOKmQs6NL8C9 fNgWWUxtIziCUB7w+r6TlKR9i6XAqYqllAi7uWB2tMe4Tpsm5RnaMpuOiG35LipMUBGAKnejvd 4MYkbu57Nf2R/Lf5e2bt0XFqznymlBntd+9kqwLlfWJ1n0JLgQGEhoSijKMXjnjQeZXjuo0Eo8 glSZ/ez17HfMC5Purx+QNklz0NPF7kQ5bS+KrZLiwO1/avNueDUIbRed/FzqkKQ9CMAKSu/UhS a2yCokJ7rn2UYgtzS5Bs5eNr
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 26, 2022 at 08:40:09AM +0000, Oleksandr Andrushchenko wrote:
> Hello, Roger, Jan!
> 
> On 12.01.22 16:42, Jan Beulich wrote:
> > On 11.01.2022 16:17, Roger Pau Monné wrote:
> >> On Thu, Nov 25, 2021 at 01:02:40PM +0200, Oleksandr Andrushchenko wrote:
> >>> diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
> >>> index 657697fe3406..ceaac4516ff8 100644
> >>> --- a/xen/drivers/vpci/vpci.c
> >>> +++ b/xen/drivers/vpci/vpci.c
> >>> @@ -35,12 +35,10 @@ extern vpci_register_init_t *const 
> >>> __start_vpci_array[];
> >>>   extern vpci_register_init_t *const __end_vpci_array[];
> >>>   #define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
> >>>   
> >>> -void vpci_remove_device(struct pci_dev *pdev)
> >>> +static void vpci_remove_device_handlers_locked(struct pci_dev *pdev)
> >>>   {
> >>> -    if ( !has_vpci(pdev->domain) )
> >>> -        return;
> >>> +    ASSERT(spin_is_locked(&pdev->vpci_lock));
> >>>   
> >>> -    spin_lock(&pdev->vpci->lock);
> >>>       while ( !list_empty(&pdev->vpci->handlers) )
> >>>       {
> >>>           struct vpci_register *r = 
> >>> list_first_entry(&pdev->vpci->handlers,
> >>> @@ -50,15 +48,33 @@ void vpci_remove_device(struct pci_dev *pdev)
> >>>           list_del(&r->node);
> >>>           xfree(r);
> >>>       }
> >>> -    spin_unlock(&pdev->vpci->lock);
> >>> +}
> >>> +
> >>> +void vpci_remove_device_locked(struct pci_dev *pdev)
> >> I think this could be static instead, as it's only used by
> >> vpci_remove_device and vpci_add_handlers which are local to the
> >> file.
> This is going to be used outside later on while processing pending mappings,
> so I think it is not worth it defining it static here and then removing the 
> static
> key word later on: please see [PATCH v5 04/14] vpci: cancel pending map/unmap 
> on vpci removal [1]

I have some comments there also, which might change the approach
you are using.

> > Does the splitting out of vpci_remove_device_handlers_locked() belong in
> > this patch in the first place? There's no second caller being added, so
> > this looks to be an orthogonal adjustment.
> I think of it as a preparation for the upcoming code: although the reason for 
> the
> change might not be immediately seen in this patch it is still in line with 
> what
> happens next.

Right - it's generally best if the change is done together as the new
callers are added. Otherwise it's hard to understand why certain changes
are made, and you will likely get asked the same question on next
rounds.

It's also possible that the code that requires this is changed in
further iterations so there's no longer a need for the splitting.

Thanks, Roger.



 


Rackspace

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