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

Re: [PATCH v9 02/16] vpci: use per-domain PCI lock to protect vpci structure


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 21 Sep 2023 11:00:34 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=+8VjF2VLMh6+vOqzB3Jn3ItVhF8Uw5bSo8wDav7Q69o=; b=P/MymKeqk7v3dF5/Cbf6HclJ2KPoGoXftjGjJI34t5qYrECxmA3yJMEkdmqyw0ocRdqNgsENT5fAQLo4Bi/fPce4SRaflPywp87bo2EmN2aJDkysjtJxwdDmrkzfsNX/7kH2/tHPid7bqaI5WYQnN/a+kXBMqshtqI+XvIJ1UmOKhrM380nn7RQ0YKCJBTkR+REtd+fzel1Ik+D0NPwe8Lo/2PFPviMQr1+loykaoxv4R7W2xAeyet5Pn++nZOEAsUMBHji4F0ppZWIWMBZBTQCLe8NjjAghGgTk7+2YGh+dnt3IlwfQx8qXLyJgYC1nT8v01rAGdcgbYIaqOqOGgg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W6WEwHoenIkYIFUSysaTeBhmCTxqoHzaLXKhUS3qx2wexsJWQ6V1rhVZE/XDexXDHGkRZeNylI4IZvuGRuG2b8xCei0d2zP70ZEUiIDfc/No+WtqJXqzBA0GgTWni0UDGQclwac4JCLlb94QVcXgVcuKtYJ89HxdhspQ8DS/qUhwYlTv+qKsoo6R+lttNDu8iOhgbOlwMzef/f9K69qjYmlmq3mApJfAMYF3Gj/rP2x926/iDB0OvppaoIyayY7K+CtQF4oJUdcZiZ3ph334U+85onl6hyIeczTaI1HBE5qMEOK0buR/R+IESej7d5fehWRrLBvz2/sL9kpvk145BQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 21 Sep 2023 09:00:59 +0000
  • Ironport-data: A9a23:HdwswqCgiFJ2zRVW/5Xiw5YqxClBgxIJ4kV8jS/XYbTApGwk0zMPn WIfDG2FOarbNjekKoh3OdvgpkhQvZHXydRgQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48D8kk/nOH+KgYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsMpvlDs15K6p4GJC5wRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw6t5IL2pOp dIjDw8/czC5jfuX742EVbw57igjBJGD0II3nFhFlGicJ9B2BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI9exuvTi7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqCn237CVxnuTtIQ6Ba+U+KFzsHio/HEIBzZIU0WwnaPloxvrMz5YA wlOksY0loAw/kG2Stj2XzWjvWWJ+BUbXrJ4CPE39wiX1uzU4gKVC2IeRzhNQNUjuIk9QjlC/ mGOm9TlFDl+qoq/QHiW9qqXhT6qMC1TJmgHDQcUQA1A79T9rYUbihPUUs0lAKOzlsfyGzz73 3aNtidWr5IXgM0Q3qO352fuhT62u4PJRQ444AbQdm+95wY/b4mgD6S37XDL4PAGK5yWJnGDo X5CncGd5eIPCJillSqRTeFLF7asj96GPSPdhxhzHpAn3zWr53OnO4tX5VlWPE50Nu4UdDmvZ 1Xc0T69/7dWNXquKKVxM4S4Dp1zybC6TIq1EPfJctBJf559Mhed+z1jblKR2Garl1UwlaY4O tGQdsPE4WsmNJmLBQGeH481uYLHDAhlrY8PbfgXFyia7Ic=
  • Ironport-hdrordr: A9a23:JhFUVaCygbS7peblHel255DYdb4zR+YMi2TDsHoBLCC9E/bo9f xG+c5w6faaskdzZJhNo6H6BECgewK7yXcW2/hqAV+iNDOWwFdARbsKheCD/9SJIUzDH4VmpM BdmsZFebnN5JtB4foSIjPULz/t+ra6GduT9J7jJr5WIz1Cb6Fl40NnBh2AEktwLTM2eKYEKA ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Sep 21, 2023 at 09:42:08AM +0200, Jan Beulich wrote:
> On 20.09.2023 15:56, Stewart Hildebrand wrote:
> > On 9/20/23 04:09, Roger Pau Monné wrote:
> >> On Tue, Sep 19, 2023 at 12:20:39PM -0400, Stewart Hildebrand wrote:
> >>> On 9/19/23 11:39, Roger Pau Monné wrote:
> >>>> On Tue, Aug 29, 2023 at 11:19:42PM +0000, Volodymyr Babchuk wrote:
> >>>>> diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c
> >>>>> index 8f2b59e61a..a0733bb2cb 100644
> >>>>> --- a/xen/drivers/vpci/msi.c
> >>>>> +++ b/xen/drivers/vpci/msi.c
> >>>>> @@ -318,15 +321,28 @@ void vpci_dump_msi(void)
> >>>>>                       * holding the lock.
> >>>>>                       */
> >>>>>                      printk("unable to print all MSI-X entries: %d\n", 
> >>>>> rc);
> >>>>> -                    process_pending_softirqs();
> >>>>> -                    continue;
> >>>>> +                    goto pdev_done;
> >>>>>                  }
> >>>>>              }
> >>>>>
> >>>>>              spin_unlock(&pdev->vpci->lock);
> >>>>> + pdev_done:
> >>>>> +            /*
> >>>>> +             * Unlock lock to process pending softirqs. This is
> >>>>> +             * potentially unsafe, as d->pdev_list can be changed in
> >>>>> +             * meantime.
> >>>>> +             */
> >>>>> +            read_unlock(&d->pci_lock);
> >>>>>              process_pending_softirqs();
> >>>>> +            if ( !read_trylock(&d->pci_lock) )
> >>>>> +            {
> >>>>> +                printk("unable to access other devices for the 
> >>>>> domain\n");
> >>>>> +                goto domain_done;
> >>>>
> >>>> Shouldn't the domain_done label be after the read_unlock(), so that we
> >>>> can proceed to try to dump the devices for the next domain?  With the
> >>>> proposed code a failure to acquire one of the domains pci_lock
> >>>> terminates the dump.
> >>>>
> >>>>> +            }
> >>>>>          }
> >>>>> +        read_unlock(&d->pci_lock);
> >>>>>      }
> >>>>> + domain_done:
> >>>>>      rcu_read_unlock(&domlist_read_lock);
> >>>>>  }
> >>>>>
> >>>
> >>> With the label moved, a no-op expression after the label is needed to 
> >>> make the compiler happy:
> >>>
> >>>             }
> >>>         }
> >>>         read_unlock(&d->pci_lock);
> >>>  domain_done:
> >>>         (void)0;
> >>>     }
> >>>     rcu_read_unlock(&domlist_read_lock);
> >>> }
> >>>
> >>>
> >>> If the no-op is omitted, the compiler may complain (gcc 9.4.0):
> >>>
> >>> drivers/vpci/msi.c: In function ‘vpci_dump_msi’:
> >>> drivers/vpci/msi.c:351:2: error: label at end of compound statement
> >>>   351 |  domain_done:
> >>>       |  ^~~~~~~~~~~
> >>
> >>
> >> Might be better to place the label at the start of the loop, and
> >> likely rename to next_domain.
> > 
> > That would bypass the loop condition and increment statements.
> 
> Right, such a label would be bogus even without that; instead of "goto"
> the use site then simply should use "continue".

IIRC continue is not suitable because the code would reach the
read_unlock() without having the lock held.

Anyway, I would leave to the submitter to find a suitable way to
continue the domain iteration.

Thanks, Roger.



 


Rackspace

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