win-pvdrivers

changeset 950:916ea40186fc

Attempted fix for memory hogging in xennet
author James Harper <james.harper@bendigoit.com.au>
date Thu Sep 22 23:47:46 2011 +1000 (2011-09-22)
parents 2edc59bf9e0a
children 013b63248e5d
files xennet/xennet6.h xennet/xennet6_rx.c
line diff
     1.1 --- a/xennet/xennet6.h	Mon Aug 22 23:43:48 2011 +1000
     1.2 +++ b/xennet/xennet6.h	Thu Sep 22 23:47:46 2011 +1000
     1.3 @@ -175,6 +175,7 @@ SET_NET_ULONG(PVOID ptr, ULONG data)
     1.4  #define RX_MIN_TARGET 8
     1.5  #define RX_DFL_MIN_TARGET 256
     1.6  #define RX_MAX_TARGET min(NET_RX_RING_SIZE, 256)
     1.7 +#define RX_MAX_PB_FREELIST (RX_MAX_TARGET * 4)
     1.8  
     1.9  //#define MAX_BUFFERS_PER_PACKET NET_RX_RING_SIZE
    1.10  
     2.1 --- a/xennet/xennet6_rx.c	Mon Aug 22 23:43:48 2011 +1000
     2.2 +++ b/xennet/xennet6_rx.c	Thu Sep 22 23:47:46 2011 +1000
     2.3 @@ -50,8 +50,8 @@ get_pb_from_freelist(struct xennet_info 
     2.4    pb->mdl = IoAllocateMdl(pb->virtual, PAGE_SIZE, FALSE, FALSE, NULL);
     2.5    if (!pb->mdl)
     2.6    {
     2.7 +    NdisFreeMemory(pb->virtual, sizeof(shared_buffer_t), 0);
     2.8      NdisFreeMemory(pb, PAGE_SIZE, 0);
     2.9 -    NdisFreeMemory(pb->virtual, sizeof(shared_buffer_t), 0);
    2.10      return NULL;
    2.11    }
    2.12    pb->gref = (grant_ref_t)xi->vectors.GntTbl_GrantAccess(xi->vectors.context, 0,
    2.13 @@ -59,8 +59,8 @@ get_pb_from_freelist(struct xennet_info 
    2.14    if (pb->gref == INVALID_GRANT_REF)
    2.15    {
    2.16      IoFreeMdl(pb->mdl);
    2.17 +    NdisFreeMemory(pb->virtual, sizeof(shared_buffer_t), 0);
    2.18      NdisFreeMemory(pb, PAGE_SIZE, 0);
    2.19 -    NdisFreeMemory(pb->virtual, sizeof(shared_buffer_t), 0);
    2.20      return NULL;
    2.21    }
    2.22    MmBuildMdlForNonPagedPool(pb->mdl);
    2.23 @@ -82,6 +82,13 @@ put_pb_on_freelist(struct xennet_info *x
    2.24    {
    2.25      //NdisAdjustBufferLength(pb->buffer, PAGE_SIZE);
    2.26      //NDIS_BUFFER_LINKAGE(pb->buffer) = NULL;
    2.27 +    if (xi->rx_pb_free > RX_MAX_PB_FREELIST)
    2.28 +    {
    2.29 +      IoFreeMdl(pb->mdl);
    2.30 +      NdisFreeMemory(pb->virtual, sizeof(shared_buffer_t), 0);
    2.31 +      NdisFreeMemory(pb, PAGE_SIZE, 0);
    2.32 +      return;
    2.33 +    }
    2.34      pb->mdl->ByteCount = PAGE_SIZE;
    2.35      pb->mdl->Next = NULL;
    2.36      pb->next = NULL;