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

RFC Add extra sync release step for late callbacks.


  • To: "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Martin Harvey <martin.harvey@xxxxxxxxxx>
  • Date: Thu, 28 Apr 2022 13:01:43 +0000
  • Accept-language: 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=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=AWWXzX/R6I0opYthwpkI+scx7T1MZ8nYEbXUywsUqpE=; b=ncURvc97N4pZ7xoAKzNaA26SknO+dQ3w0SI3mrJMfk4vnWkqNa0fqA4NW4TC49zmYgmj5YoiLJ510pfDeuAyhwp/mLmhr3j4HomHJevdLqn1aYwclLtbkPj9MTpzCS39uOHtqMAk9sOmTrOA12oPMhC6+CfwUKxOlOtSmCsFe3TxWWC3C8lBeNClKsQ0liU2h41O40l2aaNMvHtgBMIuB9UzpbIT1UV4Ny1es2ByQmRmnWIXwJvsnCAxpWC8OQiLsbrKZEn1UNdXstuYNeFsRNx7GvURA2LBeszChEFAFnIKOmY/9ZOX/YUJwxq6T53BgxDbiGm3WyRO4UYQhdknKQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OAmj2yX5ocvgMGaOQEYmlphqxmfrE7sZN5HlMOwyGLMjE9TxPlLJDs2nMc8jq5fjMRc91thoWFNnwV54yv/A7ep6IkR1HBDYI0O3WZf24qcYh8Z7bMl1aWMhRTlpn15E36xqyx/CqKCuM02RJCvAxTm+OFthPxruL/2hEmsquwEDP6I2WMt1LyaUO8T98ILt8C39fD3tQP3ahaAnXUiw9qfRmERE+AVzy78CFd5NGkUXMzc3uoOu2uTgN72SkmyPjT3hWyc+CtfESGEr6FAXJpXiTDOUZMjy19Nd9XZCjWRSQPLgvMZRYvj2N4cyfARKW4Erx8zxX4gKrXhZPGCkYg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Thu, 28 Apr 2022 13:02:15 +0000
  • Ironport-data: A9a23:gy9WiqAfwFu/GRVW/3Xiw5YqxClBgxIJ4kV8jS/XYbTApDJ33jNTz GdMUWiEPK2Lajf2e952Ptjk8hwDsZDTn95hQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHGeIdA970Ug5w7Jj0tYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhPm dVmkYSAezsAHYDXxcM+ViF7ITBxaPguFL/veRBTsOS15mieKT7G5awrC0s7e4oF5uxwHGdCs +QCLywAZQyCgOTwx6+nTu5rhYIoK8yD0IE34yk8i22GS6t/B8yZK0nJzYYwMDMYg8lUAffYI coQcyRifTzLYgFVO0dRA5U79AutrianK2QF+QjNzUYxy1Lf6Bx0/+P/CYfEW/eQGMJX2UXC+ 32TqgwVBTlfbrRz0wGt7XOqw/fR2C/2Ro8WPLm57eJxxk2ewHQJDx8bXkf9puO24nNSQPpaI k0QvyAo9K478RT0SsGnB0Hi5nmZohQbRtxcVfUg7x2AwbbV5ADfAXUYSjlGa5ots8peqSEW6 2JlVujBXVRH2IB5g1rDrd94cRva1fApEFI/
  • Ironport-hdrordr: A9a23:PDTilqG2Mcx8b/bJpLqFapHXdLJyesId70hD6qkvc3Fom52j/f xGws5x6fatskd2ZJhSo6H4BEDgewKUyXcR2+Us1NiZLW3bUQeTTb2KjrGSiwEIeReOkdK1vJ 0IG8cRNDSaNykYsS+O2njcLz9W+qjkzEnHv4fj5kYoaTsvR7Br7g9/BAreOFZxXhN6CZ0wE4 fZztZbphK7EE5nJPiTNz0gZazuttfLnJXpbVotHBg88jSDijuu9frTDwWY5BEDSDlCqI1SvF Qt0jaJqplLgcvLhCM05FWjrqi+X+GRiuerMfb8xfT97A+cyTpAKr4RGYFq9wpF2N1HoGxa6+ Uk5S1QdPibokmhBF2dsF/j3RLt3y0p7GKnwViEgWH7qci8Xz4iDdFd7LgpBicxxnBQzu2U6p g7ql5xdqAncy/ojWD4/ZzFRhtqnk27rT4rlvMSlWVWVc8bZKVKpYIS8UtJGNNYdRiKnrwPAa 1rFoXR9fxWeVSVYzTQuXRu2sWlWjA2Eg2dSkYPt8SJ23xdnWx/zUEf2MsD901wg64VWt1B/a DJI65onLZBQosfar98Hv4IRY+tBmnEUXv3QRGvyJTcZdE60l722uLKCe8OlZyXkbQzveQPsY WEVk9EvmgvfE+rAdGS3fRwg2HwfFk=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Thread-index: AdhbABZj/QTUWYFgSjmTyVfnJrSFdw==
  • Thread-topic: RFC Add extra sync release step for late callbacks.

This patch for RFC. I think it solves some longstanding suspend/resume issues we have had.

 

MH.

 

From 5b4cff54f026917d234718976e791717ece474c4 Mon Sep 17 00:00:00 2001

From: Martin Harvey <Martin.Harvey@xxxxxxxxxx>

Date: Thu, 28 Apr 2022 13:52:40 +0100

Subject: [PATCH] Add extra sync release step for late callbacks.

 

Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>

---

src/xenbus/sync.c | 42 ++++++++++++++++++++++++++++++++++++------

1 file changed, 36 insertions(+), 6 deletions(-)

 

diff --git a/src/xenbus/sync.c b/src/xenbus/sync.c

index 615eca8..8f25ea4 100644

--- a/src/xenbus/sync.c

+++ b/src/xenbus/sync.c

@@ -82,7 +82,8 @@ static UCHAR        __Section[PAGE_SIZE];

typedef struct  _SYNC_PROCESSOR {

     KDPC                Dpc;

     BOOLEAN             DisableInterrupts;

-    BOOLEAN             Exit;

+    BOOLEAN             ExitLate;

+    BOOLEAN             ExitFinal;

} SYNC_PROCESSOR, *PSYNC_PROCESSOR;

 typedef struct  _SYNC_CONTEXT {

@@ -143,6 +144,7 @@ SyncWorker(

     ULONG               Index;

     PSYNC_PROCESSOR     Processor;

     PROCESSOR_NUMBER    ProcNumber;

+    ULONG               Sequence;

     UNREFERENCED_PARAMETER(Dpc);

     UNREFERENCED_PARAMETER(_Context);

@@ -160,9 +162,7 @@ SyncWorker(

     InterlockedIncrement(&Context->CompletionCount);

     for (;;) {

-        ULONG   Sequence;

-

-        if (Processor->Exit) {

+        if (Processor->ExitLate) {

             if (Context->Late != NULL)

                 Context->Late(Context->Argument, Index);

@@ -242,10 +242,18 @@ SyncWorker(

         }

     }

-    Trace("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);

+    InterlockedIncrement(&Context->CompletionCount);

+

+    while(!Processor->ExitFinal) {

+        _mm_pause();

+        KeMemoryBarrier();

+    }

+

     InterlockedIncrement(&Context->CompletionCount);

     ASSERT(!InterruptsDisabled);

+

+    Trace("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);

}

 __drv_maxIRQL(DISPATCH_LEVEL)

@@ -443,13 +451,35 @@ SyncRelease(

     if (Context->Late != NULL)

         Context->Late(Context->Argument, SyncOwner);

+    /* First wait to make sure all late completion callbacks are done before spinning released. */

+    Context->Sequence++;

+    Context->CompletionCount = 0;

+

+    KeMemoryBarrier();

+

+    for (Index = 0; Index < Context->ProcessorCount; Index++) {

+        PSYNC_PROCESSOR Processor = &Context->Processor[Index];

+

+        Processor->ExitLate = TRUE;

+    }

+

+    InterlockedIncrement(&Context->CompletionCount);

+

+    while (Context->CompletionCount < Context->ProcessorCount) {

+        _mm_pause();

+        KeMemoryBarrier();

+    }

+

+    /* Second wait to make sure all spinning DPCs release before proceed. */

     Context->Sequence++;

     Context->CompletionCount = 0;

+    KeMemoryBarrier();

+

     for (Index = 0; Index < Context->ProcessorCount; Index++) {

         PSYNC_PROCESSOR Processor = &Context->Processor[Index];

-        Processor->Exit = TRUE;

+        Processor->ExitFinal = TRUE;

     }

     KeMemoryBarrier();

--

2.25.0.windows.1

 


 


Rackspace

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