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

[PATCH 1/3] Cap the size of the receiver PacketCache


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Sat, 11 Jul 2026 13:52:33 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Delivery-date: Sat, 11 Jul 2026 11:52:50 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

ReceiverRingFill is triggered every ring poll DPC, and continually
drains RX responses into the packet cache. While code exists to handle
cache allocation failures, the packet cache itself is uncapped; if NDIS
doesn't process the packets quickly enough, it will eventually cause the
packet cache to allocate infinitely and crash the machine.

Add a cap to the packet cache as a workaround. While this will not truly
fix OOM scenarios, nor does it solve lockups caused by excessive
incoming traffic, it will at least allow the VM to recover after a
traffic flood.

Set the cache cap to 8 times the ring size (2048) for 8 MB of packet
cache memory per queue. This value was chosen to be larger than
IN_NDIS_MAX + XENVIF_RECEIVER_RING_SIZE, and was derived from running a
single-stream TCP benchmark, observing a max object count of 836, then
doubling that and rounding up to a power of 2.

Suppress the allocation error message in ReceiverPacketCtor.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenvif/receiver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 14e8d0b..359935c 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -77,6 +77,8 @@ typedef struct _XENVIF_RECEIVER_HASH {
 
 #define XENVIF_RECEIVER_MAXIMUM_FRAGMENT_ID (XENVIF_RECEIVER_RING_SIZE - 1)
 
+#define XENVIF_RECEIVER_PACKET_CACHE_CAP    (XENVIF_RECEIVER_RING_SIZE * 8)
+
 typedef struct _XENVIF_RECEIVER_RING {
     PXENVIF_RECEIVER            Receiver;
     ULONG                       Index;
@@ -219,8 +221,6 @@ ReceiverPacketCtor(
     return STATUS_SUCCESS;
 
 fail1:
-    Error("fail1 (%08x)\n", status);
-    
     ASSERT(IsZeroMemory(Packet, sizeof (XENVIF_RECEIVER_PACKET)));
 
     return status;
@@ -2488,7 +2488,7 @@ __ReceiverRingInitialize(
                           Name,
                           sizeof (XENVIF_RECEIVER_PACKET),
                           0,
-                          0,
+                          XENVIF_RECEIVER_PACKET_CACHE_CAP,
                           ReceiverPacketCtor,
                           ReceiverPacketDtor,
                           ReceiverRingAcquireLock,
-- 
2.54.0.windows.1



--
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®.