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

[win-pv-devel] [PATCH 1/3] Affinitize watchdog threads



To avoid bouncing locks between CPUs, affinitize the ring watchdog thread
to the same CPU as the event channel and DPC.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/receiver.c    | 14 ++++++++++++++
 src/xenvif/transmitter.c | 14 ++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 3d37ad2..f2d57ba 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -2174,12 +2174,26 @@ ReceiverRingWatchdog(
     )
 {
     PXENVIF_RECEIVER_RING   Ring = Context;
+    PROCESSOR_NUMBER        ProcNumber;
+    GROUP_AFFINITY          Affinity;
     LARGE_INTEGER           Timeout;
     RING_IDX                rsp_prod;
     RING_IDX                rsp_cons;
+    NTSTATUS                status;
 
     Trace("====>\n");
 
+    //
+    // Affinitize this thread to the same CPU as the event channel
+    // and DPC.
+    //
+    status = KeGetProcessorNumberFromIndex(Ring->Index, &ProcNumber);
+    ASSERT(NT_SUCCESS(status));
+
+    Affinity.Group = ProcNumber.Group;
+    Affinity.Mask = (KAFFINITY)1 << ProcNumber.Number;
+    KeSetSystemGroupAffinityThread(&Affinity, NULL);
+
     Timeout.QuadPart = TIME_RELATIVE(TIME_S(XENVIF_RECEIVER_WATCHDOG_PERIOD));
 
     rsp_prod = 0;
diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 3542a09..19636b3 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -3164,11 +3164,25 @@ TransmitterRingWatchdog(
     )
 {
     PXENVIF_TRANSMITTER_RING    Ring = Context;
+    PROCESSOR_NUMBER            ProcNumber;
+    GROUP_AFFINITY              Affinity;
     LARGE_INTEGER               Timeout;
     ULONG                       PacketsQueued;
+    NTSTATUS                    status;
 
     Trace("====>\n");
 
+    //
+    // Affinitize this thread to the same CPU as the event channel
+    // and DPC.
+    //
+    status = KeGetProcessorNumberFromIndex(Ring->Index, &ProcNumber);
+    ASSERT(NT_SUCCESS(status));
+
+    Affinity.Group = ProcNumber.Group;
+    Affinity.Mask = (KAFFINITY)1 << ProcNumber.Number;
+    KeSetSystemGroupAffinityThread(&Affinity, NULL);
+
     Timeout.QuadPart = 
TIME_RELATIVE(TIME_S(XENVIF_TRANSMITTER_WATCHDOG_PERIOD));
     PacketsQueued = 0;
 
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

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