diff mbox series

[ovs-dev,v6,5/5] netdev-dpdk: Rename dpdk_mp_put as dpdk_mp_free.

Message ID 1508159716-3656-6-git-send-email-antonio.fischetti@intel.com
State Superseded
Headers show
Series netdev-dpdk: Fix mempool management and other cleanup. | expand

Commit Message

Fischetti, Antonio Oct. 16, 2017, 1:15 p.m. UTC
For readability purposes dpdk_mp_put is renamed as dpdk_mp_free.
Some other comments are also added to mempool functions.

CC: Mark B Kavanagh <mark.b.kavanagh@intel.com>
CC: Darrell Ball <dlu998@gmail.com>
CC: Ciara Loftus <ciara.loftus@intel.com>
CC: Kevin Traynor <ktraynor@redhat.com>
CC: Aaron Conole <aconole@redhat.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/netdev-dpdk.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Mark Kavanagh Oct. 17, 2017, 1:35 p.m. UTC | #1
>From: Fischetti, Antonio
>Sent: Monday, October 16, 2017 2:15 PM
>To: dev@openvswitch.org
>Cc: Kavanagh, Mark B <mark.b.kavanagh@intel.com>; Darrell Ball
><dlu998@gmail.com>; Loftus, Ciara <ciara.loftus@intel.com>; Kevin Traynor
><ktraynor@redhat.com>; Aaron Conole <aconole@redhat.com>; Fischetti, Antonio
><antonio.fischetti@intel.com>
>Subject: [PATCH v6 5/5] netdev-dpdk: Rename dpdk_mp_put as dpdk_mp_free.
>
>For readability purposes dpdk_mp_put is renamed as dpdk_mp_free.
>Some other comments are also added to mempool functions.

Hey Antonio,

Some minor comments inline.

Thanks,
Mark

>
>CC: Mark B Kavanagh <mark.b.kavanagh@intel.com>
>CC: Darrell Ball <dlu998@gmail.com>
>CC: Ciara Loftus <ciara.loftus@intel.com>
>CC: Kevin Traynor <ktraynor@redhat.com>
>CC: Aaron Conole <aconole@redhat.com>
>Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
>---
> lib/netdev-dpdk.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
>diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>index 5cf1392..ca07918 100644
>--- a/lib/netdev-dpdk.c
>+++ b/lib/netdev-dpdk.c
>@@ -587,6 +587,9 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool
>*mp_exists)
>     return NULL;
> }
>
>+/* Returns a valid pointer when either of the two cases occur:
>+ * a new mempool was just created or the requested mempool is already
>+ * existing. */

It may be clearer to re-write the above as follows:

"
Returns a valid pointer when either of the following is true:
 - a new mempool was just created
 - a matching mempool already exists
"

> static struct dpdk_mp *
> dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
> {
>@@ -599,8 +602,9 @@ dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool
>*mp_exists)
>     return dmp;
> }
>
>+/* Release an existing mempool. */
> static void
>-dpdk_mp_put(struct dpdk_mp *dmp)
>+dpdk_mp_free(struct dpdk_mp *dmp)
> {
>     char *mp_name;
>
>@@ -617,8 +621,8 @@ dpdk_mp_put(struct dpdk_mp *dmp)
>     ovs_mutex_unlock(&dpdk_mp_mutex);
> }
>
>-/* Tries to allocate new mempool on requested_socket_id with
>- * mbuf size corresponding to requested_mtu.
>+/* Tries to allocate a new mempool on requested_socket_id with a size
>+ * determined by requested_mtu and requested Rx/Tx queues.

This comment needs to be updated, as previously described in review comments of patch 1 of the series.


>  * On success new configuration will be applied.
>  * On error, device will be left unchanged. */
> static int
>@@ -644,7 +648,8 @@ netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
>         dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
>         return EEXIST;
>     } else {
>-        dpdk_mp_put(dev->dpdk_mp);
>+        /* A new mempool was created, release the previous one. */
>+        dpdk_mp_free(dev->dpdk_mp);
>         dev->dpdk_mp = mp;
>         dev->mtu = dev->requested_mtu;
>         dev->socket_id = dev->requested_socket_id;
>@@ -1089,7 +1094,7 @@ common_destruct(struct netdev_dpdk *dev)
>     OVS_EXCLUDED(dev->mutex)
> {
>     rte_free(dev->tx_q);
>-    dpdk_mp_put(dev->dpdk_mp);
>+    dpdk_mp_free(dev->dpdk_mp);
>
>     ovs_list_remove(&dev->list_node);
>     free(ovsrcu_get_protected(struct ingress_policer *,
>--
>2.4.11
Fischetti, Antonio Oct. 17, 2017, 5:25 p.m. UTC | #2
Thanks Mark, comments inline.

-Antonio

> -----Original Message-----
> From: Kavanagh, Mark B
> Sent: Tuesday, October 17, 2017 2:36 PM
> To: Fischetti, Antonio <antonio.fischetti@intel.com>; dev@openvswitch.org
> Cc: Darrell Ball <dlu998@gmail.com>; Loftus, Ciara <ciara.loftus@intel.com>;
> Kevin Traynor <ktraynor@redhat.com>; Aaron Conole <aconole@redhat.com>
> Subject: RE: [PATCH v6 5/5] netdev-dpdk: Rename dpdk_mp_put as dpdk_mp_free.
> 
> >From: Fischetti, Antonio
> >Sent: Monday, October 16, 2017 2:15 PM
> >To: dev@openvswitch.org
> >Cc: Kavanagh, Mark B <mark.b.kavanagh@intel.com>; Darrell Ball
> ><dlu998@gmail.com>; Loftus, Ciara <ciara.loftus@intel.com>; Kevin Traynor
> ><ktraynor@redhat.com>; Aaron Conole <aconole@redhat.com>; Fischetti, Antonio
> ><antonio.fischetti@intel.com>
> >Subject: [PATCH v6 5/5] netdev-dpdk: Rename dpdk_mp_put as dpdk_mp_free.
> >
> >For readability purposes dpdk_mp_put is renamed as dpdk_mp_free.
> >Some other comments are also added to mempool functions.
> 
> Hey Antonio,
> 
> Some minor comments inline.
> 
> Thanks,
> Mark
> 
> >
> >CC: Mark B Kavanagh <mark.b.kavanagh@intel.com>
> >CC: Darrell Ball <dlu998@gmail.com>
> >CC: Ciara Loftus <ciara.loftus@intel.com>
> >CC: Kevin Traynor <ktraynor@redhat.com>
> >CC: Aaron Conole <aconole@redhat.com>
> >Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
> >---
> > lib/netdev-dpdk.c | 15 ++++++++++-----
> > 1 file changed, 10 insertions(+), 5 deletions(-)
> >
> >diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> >index 5cf1392..ca07918 100644
> >--- a/lib/netdev-dpdk.c
> >+++ b/lib/netdev-dpdk.c
> >@@ -587,6 +587,9 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool
> >*mp_exists)
> >     return NULL;
> > }
> >
> >+/* Returns a valid pointer when either of the two cases occur:
> >+ * a new mempool was just created or the requested mempool is already
> >+ * existing. */
> 
> It may be clearer to re-write the above as follows:
> 
> "
> Returns a valid pointer when either of the following is true:
>  - a new mempool was just created
>  - a matching mempool already exists
> "
> 

[Antonio]
Thanks, will do that.


> > static struct dpdk_mp *
> > dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
> > {
> >@@ -599,8 +602,9 @@ dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool
> >*mp_exists)
> >     return dmp;
> > }
> >
> >+/* Release an existing mempool. */
> > static void
> >-dpdk_mp_put(struct dpdk_mp *dmp)
> >+dpdk_mp_free(struct dpdk_mp *dmp)
> > {
> >     char *mp_name;
> >
> >@@ -617,8 +621,8 @@ dpdk_mp_put(struct dpdk_mp *dmp)
> >     ovs_mutex_unlock(&dpdk_mp_mutex);
> > }
> >
> >-/* Tries to allocate new mempool on requested_socket_id with
> >- * mbuf size corresponding to requested_mtu.
> >+/* Tries to allocate a new mempool on requested_socket_id with a size
> >+ * determined by requested_mtu and requested Rx/Tx queues.
> 
> This comment needs to be updated, as previously described in review comments of
> patch 1 of the series.

[Antonio] ok, will do.


> 
> 
> >  * On success new configuration will be applied.
> >  * On error, device will be left unchanged. */
> > static int
> >@@ -644,7 +648,8 @@ netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
> >         dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
> >         return EEXIST;
> >     } else {
> >-        dpdk_mp_put(dev->dpdk_mp);
> >+        /* A new mempool was created, release the previous one. */
> >+        dpdk_mp_free(dev->dpdk_mp);
> >         dev->dpdk_mp = mp;
> >         dev->mtu = dev->requested_mtu;
> >         dev->socket_id = dev->requested_socket_id;
> >@@ -1089,7 +1094,7 @@ common_destruct(struct netdev_dpdk *dev)
> >     OVS_EXCLUDED(dev->mutex)
> > {
> >     rte_free(dev->tx_q);
> >-    dpdk_mp_put(dev->dpdk_mp);
> >+    dpdk_mp_free(dev->dpdk_mp);
> >
> >     ovs_list_remove(&dev->list_node);
> >     free(ovsrcu_get_protected(struct ingress_policer *,
> >--
> >2.4.11
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 5cf1392..ca07918 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -587,6 +587,9 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
     return NULL;
 }
 
+/* Returns a valid pointer when either of the two cases occur:
+ * a new mempool was just created or the requested mempool is already
+ * existing. */
 static struct dpdk_mp *
 dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
 {
@@ -599,8 +602,9 @@  dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
     return dmp;
 }
 
+/* Release an existing mempool. */
 static void
-dpdk_mp_put(struct dpdk_mp *dmp)
+dpdk_mp_free(struct dpdk_mp *dmp)
 {
     char *mp_name;
 
@@ -617,8 +621,8 @@  dpdk_mp_put(struct dpdk_mp *dmp)
     ovs_mutex_unlock(&dpdk_mp_mutex);
 }
 
-/* Tries to allocate new mempool on requested_socket_id with
- * mbuf size corresponding to requested_mtu.
+/* Tries to allocate a new mempool on requested_socket_id with a size
+ * determined by requested_mtu and requested Rx/Tx queues.
  * On success new configuration will be applied.
  * On error, device will be left unchanged. */
 static int
@@ -644,7 +648,8 @@  netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
         dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
         return EEXIST;
     } else {
-        dpdk_mp_put(dev->dpdk_mp);
+        /* A new mempool was created, release the previous one. */
+        dpdk_mp_free(dev->dpdk_mp);
         dev->dpdk_mp = mp;
         dev->mtu = dev->requested_mtu;
         dev->socket_id = dev->requested_socket_id;
@@ -1089,7 +1094,7 @@  common_destruct(struct netdev_dpdk *dev)
     OVS_EXCLUDED(dev->mutex)
 {
     rte_free(dev->tx_q);
-    dpdk_mp_put(dev->dpdk_mp);
+    dpdk_mp_free(dev->dpdk_mp);
 
     ovs_list_remove(&dev->list_node);
     free(ovsrcu_get_protected(struct ingress_policer *,