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

[win-pv-devel] [PATCH xenvif 2/8] Revert "Replace uses of MmAllocatePagesForMdlEx in __AllocatePage"



This reverts commit 4f85d004. This patch was put in place to work around
a bug in Windows but seems to have a serious negative effect on
performance. The bug in Windows has since been fixed so the patch can now
be reverted to recover performance.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/controller.c  | 12 ++------
 src/xenvif/receiver.c    | 56 +++++++++--------------------------
 src/xenvif/transmitter.c | 24 ++++-----------
 src/xenvif/util.h        | 76 ++----------------------------------------------
 4 files changed, 25 insertions(+), 143 deletions(-)

diff --git a/src/xenvif/controller.c b/src/xenvif/controller.c
index cb9d30e..35901a2 100644
--- a/src/xenvif/controller.c
+++ b/src/xenvif/controller.c
@@ -469,9 +469,7 @@ ControllerConnect(
     if (Controller->Mdl == NULL)
         goto fail7;
 
-    ASSERT(Controller->Mdl->MdlFlags
-            & (MDL_MAPPED_TO_SYSTEM_VA
-                | MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Controller->Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     Controller->Shared = Controller->Mdl->MappedSystemVa;
     ASSERT(Controller->Shared != NULL);
 
@@ -906,9 +904,7 @@ ControllerSetHashKey(
     if (Mdl == NULL)
         goto fail1;
 
-    ASSERT(Mdl->MdlFlags
-            & (MDL_MAPPED_TO_SYSTEM_VA
-                | MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     Buffer = Mdl->MappedSystemVa;
     ASSERT(Buffer != NULL);
 
@@ -1087,9 +1083,7 @@ ControllerSetHashMapping(
     if (Mdl == NULL)
         goto fail2;
 
-    ASSERT(Mdl->MdlFlags
-            & (MDL_MAPPED_TO_SYSTEM_VA
-                | MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     Buffer = Mdl->MappedSystemVa;
     ASSERT(Buffer != NULL);
 
diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index f5d572b..4e8046b 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -172,9 +172,7 @@ __ReceiverPacketMdlInit(
     Packet->Mdl.Size = sizeof (MDL) + sizeof (PFN_NUMBER);
     Packet->Mdl.MdlFlags = Mdl->MdlFlags;
 
-    ASSERT(Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     Packet->Mdl.StartVa = Mdl->StartVa;
     Packet->Mdl.MappedSystemVa = Mdl->MappedSystemVa;
 
@@ -411,9 +409,7 @@ ReceiverRingProcessTag(
 
     PayloadLength = Packet->Length - Info->Length;
 
-    ASSERT(Packet->Mdl.MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Packet->Mdl.MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -504,9 +500,7 @@ ReceiverRingProcessChecksum(
     if (Info->IpHeader.Length == 0)
         return;
 
-    ASSERT(Packet->Mdl.MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Packet->Mdl.MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -663,9 +657,7 @@ ReceiverRingPullup(
         PUCHAR  SourceVa;
         ULONG   CopyLength;
 
-        ASSERT(Mdl->MdlFlags &
-               (MDL_MAPPED_TO_SYSTEM_VA |
-                MDL_SOURCE_IS_NONPAGED_POOL));
+        ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
         SourceVa = Mdl->MappedSystemVa;
         ASSERT(SourceVa != NULL);
 
@@ -711,9 +703,7 @@ __ReceiverRingPullupPacket(
     XENVIF_PACKET_PAYLOAD       Payload;
     ULONG                       Length;
 
-    ASSERT(Packet->Mdl.MdlFlags
-            & (MDL_MAPPED_TO_SYSTEM_VA
-                | MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Packet->Mdl.MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -757,9 +747,7 @@ __ReceiverRingBuildSegment(
 
     Info = &Packet->Info;
 
-    ASSERT(Packet->Mdl.MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     InfoVa = Packet->Mdl.MappedSystemVa;
     ASSERT(InfoVa != NULL);
 
@@ -782,9 +770,7 @@ __ReceiverRingBuildSegment(
 
     Mdl = &Segment->Mdl;
 
-    ASSERT(Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Mdl->MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -866,9 +852,7 @@ __ReceiverRingBuildSegment(
 
         Mdl = Mdl->Next;
 
-        ASSERT(Mdl->MdlFlags &
-               (MDL_MAPPED_TO_SYSTEM_VA |
-                MDL_SOURCE_IS_NONPAGED_POOL));
+        ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
         BaseVa = Mdl->MappedSystemVa;
         ASSERT(BaseVa != NULL);
 
@@ -970,9 +954,7 @@ ReceiverRingProcessLargePacket(
 
     Packet->Mdl.Next = NULL;
 
-    ASSERT(Packet->Mdl.MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     InfoVa = Packet->Mdl.MappedSystemVa;
     ASSERT(InfoVa != NULL);
 
@@ -1164,9 +1146,7 @@ ReceiverRingProcessStandardPacket(
         if (Mdl == NULL)
             goto fail2;
 
-        ASSERT(Mdl->MdlFlags &
-               (MDL_MAPPED_TO_SYSTEM_VA |
-                MDL_SOURCE_IS_NONPAGED_POOL));
+        ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
         BaseVa = Mdl->MappedSystemVa;
         ASSERT(BaseVa != NULL);
 
@@ -1269,9 +1249,7 @@ ReceiverRingProcessPacket(
     // Override offset to align
     Packet->Offset = Receiver->IpAlignOffset;
 
-    ASSERT(Packet->Mdl.MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Packet->Mdl.MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -1406,9 +1384,7 @@ __ReceiverRingSwizzle(
                                    XENVIF_RECEIVER_PACKET,
                                    ListEntry);
 
-        ASSERT(Packet->Mdl.MdlFlags &
-               (MDL_MAPPED_TO_SYSTEM_VA |
-                MDL_SOURCE_IS_NONPAGED_POOL));
+        ASSERT(Packet->Mdl.MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
         BaseVa = Packet->Mdl.MappedSystemVa;
         ASSERT(BaseVa != NULL);
 
@@ -2105,9 +2081,7 @@ ReceiverRingPoll(
 
                 ASSERT3U(rsp->id, ==, id);
 
-                ASSERT(Mdl->MdlFlags &
-                       (MDL_MAPPED_TO_SYSTEM_VA |
-                        MDL_SOURCE_IS_NONPAGED_POOL));
+                ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
                 BaseVa = Mdl->MappedSystemVa;
                 ASSERT(BaseVa != NULL);
 
@@ -2498,9 +2472,7 @@ __ReceiverRingConnect(
     if (Ring->Mdl == NULL)
         goto fail3;
 
-    ASSERT(Ring->Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Ring->Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     Ring->Shared = Ring->Mdl->MappedSystemVa;
     ASSERT(Ring->Shared != NULL);
 
diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index b1d9250..eed0a0f 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -866,9 +866,7 @@ __TransmitterRingCopyPayload(
 
         Length = __min(Payload.Length, PAGE_SIZE);
 
-        ASSERT(Mdl->MdlFlags &
-               (MDL_MAPPED_TO_SYSTEM_VA |
-                MDL_SOURCE_IS_NONPAGED_POOL));
+        ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
         BaseVa = Mdl->MappedSystemVa;
         ASSERT(BaseVa != NULL);
 
@@ -1188,9 +1186,7 @@ __TransmitterRingPrepareHeader(
 
     Mdl = Buffer->Mdl;
 
-    ASSERT(Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Mdl->MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -1687,9 +1683,7 @@ __TransmitterRingPreparePacket(
 
             ASSERT3U(Mdl->ByteCount, <=, PAGE_SIZE - Trailer);
 
-            ASSERT(Mdl->MdlFlags &
-                   (MDL_MAPPED_TO_SYSTEM_VA |
-                    MDL_SOURCE_IS_NONPAGED_POOL));
+            ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
             BaseVa = Mdl->MappedSystemVa;
             ASSERT(BaseVa != NULL);
 
@@ -1788,9 +1782,7 @@ __TransmitterRingPrepareArp(
 
     Mdl = Buffer->Mdl;
 
-    ASSERT(Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Mdl->MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -1931,9 +1923,7 @@ __TransmitterRingPrepareNeighbourAdvertisement(
 
     Mdl = Buffer->Mdl;
 
-    ASSERT(Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     BaseVa = Mdl->MappedSystemVa;
     ASSERT(BaseVa != NULL);
 
@@ -3560,9 +3550,7 @@ __TransmitterRingConnect(
     if (Ring->Mdl == NULL)
         goto fail3;
 
-    ASSERT(Ring->Mdl->MdlFlags &
-           (MDL_MAPPED_TO_SYSTEM_VA |
-            MDL_SOURCE_IS_NONPAGED_POOL));
+    ASSERT(Ring->Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     Ring->Shared = Ring->Mdl->MappedSystemVa;
     ASSERT(Ring->Shared != NULL);
 
diff --git a/src/xenvif/util.h b/src/xenvif/util.h
index 52faa1e..30322d8 100644
--- a/src/xenvif/util.h
+++ b/src/xenvif/util.h
@@ -244,63 +244,7 @@ fail1:
     return NULL;
 }
 
-
-static FORCEINLINE PMDL
-__AllocatePage()
-{
-    PHYSICAL_ADDRESS    LowAddress;
-    PHYSICAL_ADDRESS    HighAddress;
-    PHYSICAL_ADDRESS    Align;
-    SIZE_T              TotalBytes;
-    PMDL                Mdl;
-    PUCHAR              MdlMappedSystemVa;
-    NTSTATUS            status;
-
-    ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
-
-    LowAddress.QuadPart  = 0ull;
-    HighAddress.QuadPart = ~0ull;
-    Align.QuadPart       = PAGE_SIZE;
-    TotalBytes           = (SIZE_T)PAGE_SIZE;
-
-    MdlMappedSystemVa = MmAllocateContiguousMemorySpecifyCache(
-                            TotalBytes,
-                            LowAddress,
-                            HighAddress,
-                            Align,
-                            MmCached);
-
-    status = STATUS_NO_MEMORY;
-    if (MdlMappedSystemVa == NULL)
-        goto fail1;
-
-    Mdl = IoAllocateMdl(MdlMappedSystemVa,
-                        (ULONG)TotalBytes,
-                        FALSE,
-                        FALSE,
-                        NULL);
-    if (Mdl == NULL)
-        goto fail2;
-
-    MmBuildMdlForNonPagedPool(Mdl);
-
-    ASSERT3U(Mdl->ByteOffset, ==, 0);
-    ASSERT3P(Mdl->StartVa, ==, MdlMappedSystemVa);
-    ASSERT3P(Mdl->MappedSystemVa, ==, MdlMappedSystemVa);
-
-    RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount);
-
-    return Mdl;
-
-fail2:
-    Error("fail2\n");
-
-    MmFreeContiguousMemory(MdlMappedSystemVa);
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return NULL;
-}
+#define __AllocatePage()    __AllocatePages(1)
 
 static FORCEINLINE VOID
 __FreePages(
@@ -318,23 +262,7 @@ __FreePages(
     ExFreePool(Mdl);
 }
 
-static FORCEINLINE VOID
-__FreePage(
-    IN  PMDL    Mdl
-    )
-{
-    PUCHAR  MdlMappedSystemVa;
-
-    ASSERT(Mdl->MdlFlags &
-            (MDL_MAPPED_TO_SYSTEM_VA |
-             MDL_SOURCE_IS_NONPAGED_POOL));
-
-    MdlMappedSystemVa = Mdl->MappedSystemVa;
-
-    IoFreeMdl(Mdl);
-
-    MmFreeContiguousMemory(MdlMappedSystemVa);
-}
+#define __FreePage(_Mdl)    __FreePages(_Mdl)
 
 static FORCEINLINE PCHAR
 __strtok_r(
-- 
2.5.3


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

 


Rackspace

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