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

[PATCH v2 1/4] Cap the size of the receiver PacketCache


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Wed, 15 Jul 2026 12:19:26 +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: Wed, 15 Jul 2026 10:19:43 +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.

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

diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 14e8d0b..749de28 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;
@@ -2488,7 +2490,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®.