[ovs-dev] [PATCH] datapath-windows: Address memory allocation issues for OVS_BUFFER_CONTEXT
Anand Kumar
kumaranand at vmware.com
Tue Mar 19 18:21:07 UTC 2019
With current implementation, when nbl pool is allocated, context size is
specified as 64 bytes, while the OVS_BUFFER_CONTEXT size is only 32 bytes.
Since context size is never changed, additional memory is not required.
This patch makes it simpler to allocate memory for OVS_BUFFER_CONTEXT so
that it is always aligned to MEMORY_ALLOCATION_ALIGNMENT.
This is acheived by updating "value" field in the context
structure, so that number of elements in array is always a multiple of
MEMORY_ALLOCATION_ALIGNMENT.
Also change the DEFAULT_CONTEXT_SIZE to accomodate OVS_BUFFER_CONTEXT size.
Signed-off-by: Anand Kumar <kumaranand at vmware.com>
---
datapath-windows/ovsext/BufferMgmt.h | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h
index dcf310a..714ab3d 100644
--- a/datapath-windows/ovsext/BufferMgmt.h
+++ b/datapath-windows/ovsext/BufferMgmt.h
@@ -20,11 +20,8 @@
#define MEM_ALIGN MEMORY_ALLOCATION_ALIGNMENT
#define MEM_ALIGN_SIZE(_x) ((MEM_ALIGN - 1 + (_x))/MEM_ALIGN * MEM_ALIGN)
#define OVS_CTX_MAGIC 0xabcd
-
-#define OVS_DEFAULT_NBL_CONTEXT_SIZE MEM_ALIGN_SIZE(64)
-#define OVS_DEFAULT_NBL_CONTEXT_FILL \
- (OVS_DEFAULT_NBL_CONTEXT_SIZE - sizeof (OVS_BUFFER_CONTEXT))
-
+#define OVS_DEFAULT_NBL_CONTEXT_SIZE sizeof(OVS_BUFFER_CONTEXT))
+#define OVS_DEFAULT_NBL_CONTEXT_FILL 0
#define OVS_DEFAULT_DATA_SIZE 256
#define OVS_DEFAULT_HEADROOM_SIZE 128
#define OVS_FIX_NBL_DATA_SIZE (OVS_DEFAULT_DATA_SIZE + OVS_DEFAULT_HEADROOM_SIZE)
@@ -49,7 +46,7 @@ enum {
};
typedef union _OVS_BUFFER_CONTEXT {
- struct {
+ struct dummy {
UINT16 magic;
UINT16 flags;
UINT32 srcPortNo;
@@ -61,7 +58,7 @@ typedef union _OVS_BUFFER_CONTEXT {
UINT16 mru;
};
- UINT64 value[MEM_ALIGN_SIZE(32) >> 3];
+ CHAR value[MEM_ALIGN_SIZE(sizeof(struct dummy))];
} OVS_BUFFER_CONTEXT, *POVS_BUFFER_CONTEXT;
typedef struct _OVS_NBL_POOL {
--
2.9.3.windows.1
More information about the dev
mailing list