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

Re: [PATCH v2 2/3] Limit retry in ControllerGetResponse


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Fri, 7 Nov 2025 10:42:22 +0000
  • Accept-language: en-GB, en-US
  • 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=arcselector10001; 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=+hV/qltB9lOINDj/82iFbiPHFfDdm4xlZthkLIpgh4Q=; b=HoJdw0M98mzNuHhncm+2Nq+MmXWc76zMRqfHKSlNMAOfjzoDYpbhHyAuolI0lpUS/hdeT1xgt8T7a9t53EgU34PaQBQnBOL8C2fMRN6pxVC6rvyfsnxht2SndevvVBLfcxSgJaFQpPSeTKQQulJNvP/5W9mPMlpnrMtuEaVz7n1cMW5mUBZY523PjUopKOL8scr7H5P3XDQIqcWWJcvkDYnu2wIMQUl8wQdPmPegfdOpbBZP6rRXPcDjqfkYzFx5yookRRTDH2kO6ajEe9MS/evlQBio8PMgg1HnMAHfVuFDXgDg32xkGQXVtbWBs14M1xzZwLP/hKy2rqkR244fKQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NXCFwA7kN42ffLan5ofYd/HKcyDIYHSZxrXBJEz1oDviHw1J/72NSpFd3kHHOxTpj/S20qkm7zQl6k7N/4CI/WZ+MEQvR/CG1y4wQGAD42/PXIQLfrDmEORUtC5eUfmFoQ4hPusa+1asoZwG6AxAMLoHgmNKtWa8V+ZHOY10O7/cyesSrrKP09ILoeNnKsDBWri5uwUp3GFhzngmumJvA9zvP05C37kYvgo4SS6fk9dozAn3fb89ZK9LhkyW0khZ6YcCv1idO8sw4DOpaFD+HOCdKIlu7PVeN024k+BYqSnFE8K+psUpsilZku0gpOnrQKvPi9Umqiw+rXepXIUe4Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Fri, 07 Nov 2025 10:42:31 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHcTyhPf4yajOGgv025SjSgwRoOp7Tm7gP8gAAEcICAABVgMg==
  • Thread-topic: [PATCH v2 2/3] Limit retry in ControllerGetResponse

Ok,

Reviewed-by: Owen Smith <owen.smith@xxxxxxxxxx>

________________________________________
From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
Sent: 07 November 2025 9:24 AM
To: Owen Smith; win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Subject: Re: [PATCH v2 2/3] Limit retry in ControllerGetResponse

On 07/11/2025 10:11, Owen Smith wrote:
>
> Would keeping a count of the number of STATUS_TIMEOUTs returned by 
> ControllerGetResponse() and breaking out of the loop after 50 timeouts be 
> simpler?
> Or is it required to query the time to ensure a more accurate poll?
>
> Owen
>

The timeout calculation is not required, I just thought it makes more
sense to base the timeout calculation on actual time rather than
multiplying the loops.

> ________________________________________
> From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of 
> Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
> Sent: 06 November 2025 2:18 PM
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Tu Dinh
> Subject: [PATCH v2 2/3] Limit retry in ControllerGetResponse
>
> During unplug, NDIS may issue a hash reconfiguration. However, the
> backend may disappear before the request has had a chance to complete.
> This is observable by e.g. adding a delay at the beginning of
> VifReceiverSetHashAlgorithm and unplugging. If this happens, Xenvif will
> get stuck waiting forever in ControllerGetResponse, at DISPATCH_LEVEL to
> boot.
>
> Limit the total wait time from calling EvtchnWait to 5 seconds, and
> return an error code to the caller if the wait has failed.
>
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
> ---
>   src/xenvif/controller.c | 36 +++++++++++++++++++++++++++++++-----
>   1 file changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/src/xenvif/controller.c b/src/xenvif/controller.c
> index e032972..6a091d6 100644
> --- a/src/xenvif/controller.c
> +++ b/src/xenvif/controller.c
> @@ -246,9 +246,11 @@ fail1:
>
>   #define TIME_US(_us)        ((_us) * 10)
>   #define TIME_MS(_ms)        (TIME_US((_ms) * 1000))
> +#define TIME_S(_s)          (TIME_MS((_s) * 1000))
>   #define TIME_RELATIVE(_t)   (-(_t))
>
> -#define XENVIF_CONTROLLER_POLL_PERIOD 100 // ms
> +#define XENVIF_CONTROLLER_POLL_PERIOD   TIME_MS(100)
> +#define XENVIF_CONTROLLER_MAX_WAIT      TIME_S(5)
>
>   _IRQL_requires_(DISPATCH_LEVEL)
>   static NTSTATUS
> @@ -257,10 +259,15 @@ ControllerGetResponse(
>       OUT PULONG                      Data OPTIONAL
>       )
>   {
> -    LARGE_INTEGER                   Timeout;
> +    LARGE_INTEGER                   PollTimeout;
> +    LARGE_INTEGER                   MaxTimeout;
> +    LARGE_INTEGER                   Start;
>       NTSTATUS                        status;
>
> -    Timeout.QuadPart = TIME_RELATIVE(TIME_MS(XENVIF_CONTROLLER_POLL_PERIOD));
> +    PollTimeout.QuadPart = TIME_RELATIVE(XENVIF_CONTROLLER_POLL_PERIOD);
> +    MaxTimeout.QuadPart = TIME_RELATIVE(XENVIF_CONTROLLER_MAX_WAIT);
> +
> +    KeQuerySystemTime(&Start);
>
>       for (;;) {
>           ULONG   Count;
> @@ -279,9 +286,27 @@ ControllerGetResponse(
>                                  &Controller->EvtchnInterface,
>                                  Controller->Channel,
>                                  Count + 1,
> -                               &Timeout);
> -        if (status == STATUS_TIMEOUT)
> +                               &PollTimeout);
> +        if (status == STATUS_TIMEOUT) {
> +            LARGE_INTEGER       Now;
> +            LONGLONG            Delta;
> +
> +            KeQuerySystemTime(&Now);
> +
> +            // Relative timeout
> +            Delta = Now.QuadPart - Start.QuadPart;
> +            if (Delta > -MaxTimeout.QuadPart)
> +                break;
> +
>               __ControllerSend(Controller);
> +        }
> +    }
> +
> +    // Use STATUS_TRANSACTION_TIMED_OUT as an error code since 
> STATUS_TIMEOUT is
> +    // a success code.
> +    if (Controller->Response.id != Controller->Request.id) {
> +        status = STATUS_TRANSACTION_TIMED_OUT;
> +        goto done;
>       }
>
>       ASSERT3U(Controller->Response.type, ==, Controller->Request.type);
> @@ -311,6 +336,7 @@ ControllerGetResponse(
>       if (NT_SUCCESS(status) && Data != NULL)
>           *Data = Controller->Response.data;
>
> +done:
>       RtlZeroMemory(&Controller->Request,
>                     sizeof (struct xen_netif_ctrl_request));
>       RtlZeroMemory(&Controller->Response,
> --
> 2.51.0.windows.2
>
>
>
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech
>
>
>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

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