]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Remove MINIMUM_OBJECT_SIZE
authorOwen Smith <owen.smith@citrix.com>
Mon, 19 Jul 2021 10:03:34 +0000 (11:03 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 19 Jul 2021 14:14:31 +0000 (15:14 +0100)
MINIMUM_OBJECT_SIZE would make all cached objects at least 0x80 bytes, which
would limit the number of objects in each slab to 31 objects.

This limitation is not needed, as the slab's mask is dynamically allocated to
cope with the correct number of objects that can fit into a single slab.
Cache object's sizes are rounded up to the nearest pointer boundary to maintain
object alignment. Removing the minimum size allows more objects per cache slab,
reducing the memory overhead of caches.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xenbus/cache.c

index 247f2444d9bfb00a3f637e271fe45e281a4367a3..8dcb3a78172fb9cf3732b2055fceb487021473ea 100644 (file)
@@ -65,12 +65,8 @@ typedef struct _XENBUS_CACHE_SLAB {
     UCHAR           Buffer[1];
 } XENBUS_CACHE_SLAB, *PXENBUS_CACHE_SLAB;
 
-#define BITS_PER_ULONG (sizeof (ULONG) * 8)
-#define MINIMUM_OBJECT_SIZE (PAGE_SIZE / BITS_PER_ULONG)
-
-C_ASSERT(sizeof (XENBUS_CACHE_SLAB) <= MINIMUM_OBJECT_SIZE);
-
-#define MAXNAMELEN  128
+#define BITS_PER_ULONG  (sizeof (ULONG) * 8)
+#define MAXNAMELEN      128
 
 struct _XENBUS_CACHE {
     LIST_ENTRY              ListEntry;
@@ -783,7 +779,6 @@ CacheCreate(
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    Size = __max(Size, MINIMUM_OBJECT_SIZE);
     Size = P2ROUNDUP(Size, sizeof (ULONG_PTR));
 
     if (Cap == 0)