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

Re: [PATCH] Add upper bound to receiver ring poll to reduce DPC latency


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Paul Durrant <xadimgnik@xxxxxxxxx>
  • Date: Tue, 14 Feb 2023 16:38:43 +0000
  • Delivery-date: Tue, 14 Feb 2023 16:38:47 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 07/02/2023 14:05, Rachel.Yan@xxxxxxxxxx wrote:
From: Rachel Yan <Rachel.Yan@xxxxxxxxxx>

Adds an upper bound to the ring poll iteration with optimal value found through 
experimentation to avoid going round the ring an infinite (or very large) 
number of times. This has been tested to show improvements in DPC latencies and 
file transfer speeds.


Do you have numbers you can share? The reason for moving to threaded DPCs was to avoid having to play games like this.

  Paul


Signed-off-by: Rachel Yan <rachel.yan@xxxxxxxxxx>

---
  src/xenvif/receiver.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 2145133..d469de4 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -2013,11 +2013,15 @@ ReceiverRingPoll(
      PXENVIF_RECEIVER            Receiver;
      PXENVIF_FRONTEND            Frontend;
      ULONG                       Count;
+    ULONG                       MaxCount;
+    BOOLEAN                     NeedQueueDpc;
Receiver = Ring->Receiver;
      Frontend = Receiver->Frontend;
Count = 0;
+    MaxCount = 10 * XENVIF_RECEIVER_RING_SIZE;
+    NeedQueueDpc = FALSE;
if (!Ring->Enabled || Ring->Paused)
          goto done;
@@ -2068,6 +2072,15 @@ ReceiverRingPoll(
              PXENVIF_RECEIVER_FRAGMENT   Fragment;
              PMDL                        Mdl;
+ // avoid going through the ring an infinite (or very large) amount of times
+            // if the netback producer happens to fill in just enough packets 
to cause us
+            // to go around the ring multiple times. This should reduce Dpc 
latencies.
+
+            if (Count >= MaxCount) {
+                NeedQueueDpc = TRUE;
+                break;
+            }
+
              rsp = RING_GET_RESPONSE(&Ring->Front, rsp_cons);
// netback is required to complete requests in order and place
@@ -2247,7 +2260,7 @@ ReceiverRingPoll(
      if (!__ReceiverRingIsStopped(Ring))
          ReceiverRingFill(Ring);
- if (Ring->PacketQueue != NULL &&
+    if ((NeedQueueDpc || Ring->PacketQueue != NULL) &&
          KeInsertQueueDpc(&Ring->QueueDpc, NULL, NULL))
          Ring->QueueDpcs++;




 


Rackspace

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