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

Re: [PATCH 2/3] xen-pciback: reconfigure also from backend watch handler


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Fri, 9 Apr 2021 17:43:09 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.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-SenderADCheck; bh=fAT3JuzA/AGYbhQRQxDvrS7UJL7GIl9dCzvUvrlu6WA=; b=Tec0vSwj32qj5axaUZsRIBX3u8BtzSULS1kXHXR9j5r29UjcQ1nTXTzbbo0phfYcKoNIhIdQmZqggBnlUbNz4gyF4tRxpNUffrzTnhTNyt6AvvD4N+t5yP2T57SSfhA6barhy+3ronYOd4yXO7TIOhBqAR+wVvp3fkt3srYoZrgbCjR35c1/oikQihD9V4IDez2guxUHVGdKoZCparX1qykwoI9bMRcVuwVFdkGTBHcxP6OBz7Lt7ddon34Ri5wC8LMnl+AVRAnK6OB6HNzaS+N97S435HN3UhsDqbHxBBjcW2Smq1RtnA4PupMboldYtHeUTkxmin/NuKDR/PKVig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIdNtysWt0DKwI3FoS7daUt0OrxjtMzpyHhSQ9Fg6XG30qZCwAjQV2GJJao+VV9+DiiZIrLD9eTupSjw7X0xMlq7PfgcJBoHim3CguaqNH5R1X7I3/Eiv392eO+k/Hh3CYN8BtIUut0oesoZyqPq1t6zjMfVzQKxVdLCEfleaItAHcTumoDGrGLL8TMAP8uor/CZIjQshXgBThnh8DOxgLhsZiAwBgsSsjWwXZqWdlZDTgGLDXe2efMeOw47oXDoGPlO6w66e7Fzza1AGlhpj9v+gTQLluHJ5/nT9AzD9BjJbyiA2FJScWoHmsxWkUm/myogVCAXjf713CothLIAMQ==
  • Cc: Juergen Gross <jgross@xxxxxxxx>, Konrad Wilk <konrad.wilk@xxxxxxxxxx>
  • Delivery-date: Fri, 09 Apr 2021 21:43:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 4/7/21 10:37 AM, Jan Beulich wrote:
> When multiple PCI devices get assigned to a guest right at boot, libxl
> incrementally populates the backend tree. The writes for the first of
> the devices trigger the backend watch. In turn xen_pcibk_setup_backend()
> will set the XenBus state to Initialised, at which point no further
> reconfigures would happen unless a device got hotplugged. Arrange for
> reconfigure to also get triggered from the backend watch handler.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> I will admit that this isn't entirely race-free (with the guest actually
> attaching in parallel), but from the looks of it such a race ought to be
> benign (not the least thanks to the mutex). Ideally the tool stack
> wouldn't write num_devs until all devices had their information
> populated. I tried doing so in libxl, but xen_pcibk_setup_backend()
> calling xenbus_dev_fatal() when not being able to read that node
> prohibits such an approach (or else libxl and driver changes would need
> to go into use in lock-step).
>
> I wonder why what is being watched isn't just the num_devs node. Right
> now the watch triggers quite frequently without anything relevant
> actually having changed (I suppose in at least some cases in response
> to writes by the backend itself).
>
> --- a/drivers/xen/xen-pciback/xenbus.c
> +++ b/drivers/xen/xen-pciback/xenbus.c
> @@ -359,7 +359,8 @@ out:
>       return err;
>  }
>  
> -static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
> +static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev,
> +                              enum xenbus_state state)
>  {
>       int err = 0;
>       int num_devs;
> @@ -374,8 +375,7 @@ static int xen_pcibk_reconfigure(struct
>  
>       mutex_lock(&pdev->dev_lock);
>       /* Make sure we only reconfigure once */


Is this comment still valid or should it be moved ...


> -     if (xenbus_read_driver_state(pdev->xdev->nodename) !=
> -         XenbusStateReconfiguring)
> +     if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
>               goto out;
>  
>       err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
> @@ -500,6 +500,9 @@ static int xen_pcibk_reconfigure(struct
>               }
>       }
>  
> +     if (state != XenbusStateReconfiguring)
> +             goto out;
> +


... here?


>       err = xenbus_switch_state(pdev->xdev, XenbusStateReconfigured);
>       if (err) {
>               xenbus_dev_fatal(pdev->xdev, err,
> @@ -525,7 +528,7 @@ static void xen_pcibk_frontend_changed(s
>               break;
>  
>       case XenbusStateReconfiguring:
> -             xen_pcibk_reconfigure(pdev);
> +             xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring);
>               break;
>  
>       case XenbusStateConnected:
> @@ -664,6 +667,10 @@ static void xen_pcibk_be_watch(struct xe
>               xen_pcibk_setup_backend(pdev);
>               break;
>  
> +     case XenbusStateInitialised:
> +             xen_pcibk_reconfigure(pdev, XenbusStateInitialised);


Could you add a comment here that this is needed when multiple devices are 
added?


It also looks a bit odd that adding a device is now viewed as a 
reconfiguration. It seems to me that xen_pcibk_setup_backend() and 
xen_pcibk_reconfigure() really should be merged --- initialization code for 
both looks pretty much the same.


-boris




 


Rackspace

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