diff mbox series

[ovs-dev,v2] datapath-windows: Address memory allocation issues for OVS_BUFFER_CONTEXT

Message ID 20190320235430.8300-1-kumaranand@vmware.com
State Accepted
Headers show
Series [ovs-dev,v2] datapath-windows: Address memory allocation issues for OVS_BUFFER_CONTEXT | expand

Commit Message

Li,Rongqing via dev March 20, 2019, 11:54 p.m. UTC
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@vmware.com>
---
 datapath-windows/ovsext/BufferMgmt.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

0-day Robot March 21, 2019, 12:59 a.m. UTC | #1
Bleep bloop.  Greetings Anand Kumar via dev, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author should not be mailing list.
Lines checked: 62, Warnings: 0, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
Alin-Gabriel Serdean March 25, 2019, 5:29 p.m. UTC | #2
-----Original Message-----
From: ovs-dev-bounces@openvswitch.org <ovs-dev-bounces@openvswitch.org> On
Behalf Of Anand Kumar via dev
Sent: Thursday, March 21, 2019 1:55 AM
To: dev@openvswitch.org
Subject: [ovs-dev] [PATCH v2] datapath-windows: Address memory allocation
issues for OVS_BUFFER_CONTEXT

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@vmware.com>
---
 
Thanks a lot for implementing this!

Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Alin-Gabriel Serdean April 3, 2019, 2:21 p.m. UTC | #3
Applied on master!

> On 25 Mar 2019, at 19:29, aserdean@ovn.org wrote:
> 
> -----Original Message-----
> From: ovs-dev-bounces@openvswitch.org <ovs-dev-bounces@openvswitch.org> On
> Behalf Of Anand Kumar via dev
> Sent: Thursday, March 21, 2019 1:55 AM
> To: dev@openvswitch.org
> Subject: [ovs-dev] [PATCH v2] datapath-windows: Address memory allocation
> issues for OVS_BUFFER_CONTEXT
> 
> 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@vmware.com>
> ---
> 
> Thanks a lot for implementing this!
> 
> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h
index dcf310a..2a74988 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 {