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

[PATCH 1/3] Track additional Cache stats


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 19 Jul 2021 11:03:32 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Mon, 19 Jul 2021 10:05:45 +0000
  • Ironport-hdrordr: A9a23:Iju5Da36Hqy2mWkPgg/ygwqjBLgkLtp133Aq2lEZdPRUGvb2qy nIpoV/6faUskd3ZJhOo7G90cW7LE80lqQFg7X5X43DYOCOggLBR+tfBOPZslnd8kbFmNK1u5 0NT0EHMqySMWRH
  • Ironport-sdr: Uw74dEL9knS/K3icl7gt37yrtrIN6wA9tEk0PzyBYnG2SlkFMphZ5Mpkp9xC97GLDdQB3gOiOk bZv4PFwHW9VPalp6CzSzpEuGAAX2ZeleXATx6rF0ulCBDoO9jRzEemDt2uH85RCNdPpYklOVaL 0CKf/GIxcNXNEQEK9Xqek5kfbnKwscAEunvDENR0ptBHxFL+kSrqMJ09MqCFFlQ3PVHSRkXvTh 8kXIcHX7Veo7TCPaJxyb1jrT13zonR8xpQKojAw6zK0+CuCncFSbgcyTT9MOUWXqTAXe+WKfM1 R7/iRO2LJZMoZ7Ii7uyVO4jP
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Track Current/Maximum number of slabs, and Current/Maximum number of objects in
use.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenbus/cache.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index 48772d4..247f244 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -88,6 +88,10 @@ struct _XENBUS_CACHE {
     ULONG                   Count;
     PXENBUS_CACHE_MAGAZINE  Magazine;
     ULONG                   MagazineCount;
+    LONG                    CurrentSlabs;
+    LONG                    MaximumSlabs;
+    LONG                    CurrentObjects;
+    LONG                    MaximumObjects;
 };
 
 struct _XENBUS_CACHE_CONTEXT {
@@ -296,6 +300,7 @@ CacheCreateSlab(
     ULONG               Count;
     ULONG               Size;
     LONG                Index;
+    LONG                SlabCount;
     NTSTATUS            status;
 
     NumberOfBytes = P2ROUNDUP(FIELD_OFFSET(XENBUS_CACHE_SLAB, Buffer) +
@@ -340,6 +345,10 @@ CacheCreateSlab(
     CacheInsertSlab(Cache, Slab);
     Cache->Count += Count;
 
+    SlabCount = InterlockedIncrement(&Cache->CurrentSlabs);
+    if (SlabCount > Cache->MaximumSlabs)
+        Cache->MaximumSlabs = SlabCount;
+
     return STATUS_SUCCESS;
 
 fail4:
@@ -400,6 +409,9 @@ CacheDestroySlab(
         __CacheDtor(Cache, Object);
     }
 
+    ASSERT(Cache->CurrentSlabs != 0);
+    InterlockedDecrement(&Cache->CurrentSlabs);
+
     __CacheFree(Slab->Mask);
     __CacheFree(Slab);
 }
@@ -527,6 +539,7 @@ CacheGet(
     ULONG                   Index;
     PXENBUS_CACHE_MAGAZINE  Magazine;
     PVOID                   Object;
+    LONG                    ObjectCount;
 
     UNREFERENCED_PARAMETER(Interface);
 
@@ -575,6 +588,12 @@ again:
         __CacheReleaseLock(Cache);
 
 done:
+    if (Object != NULL) {
+        ObjectCount = InterlockedIncrement(&Cache->CurrentObjects);
+        if (ObjectCount > Cache->MaximumObjects)
+            Cache->MaximumObjects = ObjectCount;
+    }
+
     KeLowerIrql(Irql);
 
     return Object;
@@ -625,6 +644,9 @@ CachePut(
         __CacheReleaseLock(Cache);
 
 done:
+    ASSERT(Cache->CurrentObjects != 0);
+    InterlockedDecrement(&Cache->CurrentObjects);
+
     KeLowerIrql(Irql);
 }
 
@@ -895,6 +917,12 @@ CacheDestroy(
 
     CacheSpill(Cache, 0);
 
+    ASSERT(Cache->CurrentObjects == 0);
+    Cache->MaximumObjects = 0;
+
+    ASSERT(Cache->CurrentSlabs == 0);
+    Cache->MaximumSlabs = 0;
+
     Cache->Cursor = NULL;
     ASSERT(IsListEmpty(&Cache->SlabList));
     RtlZeroMemory(&Cache->SlabList, sizeof (LIST_ENTRY));
@@ -942,10 +970,14 @@ CacheDebugCallback(
 
             XENBUS_DEBUG(Printf,
                          &Context->DebugInterface,
-                         "- %s: Count = %d (Reservation = %d)\n",
+                         "- %s: Count = %d, Reservation = %d, Objects = %d / 
%d, Slabs = %d / %d\n",
                          Cache->Name,
                          Cache->Count,
-                         Cache->Reservation);
+                         Cache->Reservation,
+                         Cache->CurrentObjects,
+                         Cache->MaximumObjects,
+                         Cache->CurrentSlabs,
+                         Cache->MaximumSlabs);
         }
     }
 }
-- 
2.31.1.windows.1




 


Rackspace

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