Message ID | 1507737656-31627-6-git-send-email-antonio.fischetti@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | netdev-dpdk: Fix management of pre-existing mempools. | expand |
>From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-bounces@openvswitch.org] >On Behalf Of antonio.fischetti@intel.com >Sent: Wednesday, October 11, 2017 5:01 PM >To: dev@openvswitch.org >Subject: [ovs-dev] [PATCH v5 5/6] netdev-dpdk: Reword mp_size as n_mbufs. > >Rename mp_size as n_mbufs in dpdk_mp structure. >This parameter is passed to rte mempool creation functions >and is meant to contain the number of elements inside >the requested mempool. As previously mentioned, I don't believe that this patch should be part of the 'fix management of pre-existing mempools' patchset, since it's a cosmetic change, rather than an actual fix. Apart from that, I don't really see a need for this change - I think 'mp_size' is sufficiently descriptive. Thanks, Mark > >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 | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > >diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c >index c451bc9..f67c311 100644 >--- a/lib/netdev-dpdk.c >+++ b/lib/netdev-dpdk.c >@@ -308,7 +308,7 @@ struct dpdk_mp { > int mtu; > int socket_id; > char if_name[IFNAMSIZ]; >- unsigned mp_size; >+ unsigned n_mbufs; /* Number of mbufs inside the mempool. */ > struct ovs_list list_node OVS_GUARDED_BY(dpdk_mp_mutex); > }; > >@@ -500,7 +500,7 @@ dpdk_mp_name(struct dpdk_mp *dmp) > uint32_t h = hash_string(dmp->if_name, 0); > char *mp_name = xcalloc(RTE_MEMPOOL_NAMESIZE, sizeof *mp_name); > int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%d_%u", >- h, dmp->socket_id, dmp->mtu, dmp->mp_size); >+ h, dmp->socket_id, dmp->mtu, dmp->n_mbufs); > ovs_assert(ret >= 0 && ret < RTE_MEMPOOL_NAMESIZE); > return mp_name; > } >@@ -518,13 +518,13 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool >*mp_exists) > ovs_strzcpy(dmp->if_name, dev->up.name, IFNAMSIZ); > > /* >- * XXX: rough estimation of memory required for port: >+ * XXX: rough estimation of number of mbufs required for this port: > * <packets required to fill the device rxqs> > * + <packets that could be stuck on other ports txqs> > * + <packets in the pmd threads> > * + <additional memory for corner cases> > */ >- dmp->mp_size = dev->requested_n_rxq * dev->requested_rxq_size >+ dmp->n_mbufs = dev->requested_n_rxq * dev->requested_rxq_size > + dev->requested_n_txq * dev->requested_txq_size > + MIN(RTE_MAX_LCORE, dev->requested_n_rxq) * NETDEV_MAX_BURST > + MIN_NB_MBUF; >@@ -534,11 +534,11 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool >*mp_exists) > > VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s " > "with %d Rx and %d Tx queues, socket id:%d.", >- dmp->mp_size, dev->up.name, >+ dmp->n_mbufs, dev->up.name, > dev->requested_n_rxq, dev->requested_n_txq, > dev->requested_socket_id); > >- dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->mp_size, >+ dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->n_mbufs, > MP_CACHE_SZ, > sizeof (struct dp_packet) > - sizeof (struct rte_mbuf), >@@ -547,7 +547,7 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool >*mp_exists) > dmp->socket_id); > if (dmp->mp) { > VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name, >- dmp->mp_size); >+ dmp->n_mbufs); > /* rte_pktmbuf_pool_create has done some initialization of the > * rte_mbuf part of each dp_packet. Some OvS specific fields > * of the packet still need to be initialized by >@@ -565,14 +565,14 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool >*mp_exists) > *mp_exists = true; > } else { > VLOG_ERR("Failed mempool \"%s\" create request of %u mbufs", >- mp_name, dmp->mp_size); >+ mp_name, dmp->n_mbufs); > } > free(mp_name); > if (dmp->mp) { > return dmp; > } > } while (!(*mp_exists) && >- (rte_errno == ENOMEM && (dmp->mp_size /= 2) >= MIN_NB_MBUF)); >+ (rte_errno == ENOMEM && (dmp->n_mbufs /= 2) >= MIN_NB_MBUF)); > > rte_free(dmp); > return NULL; >-- >2.4.11 > >_______________________________________________ >dev mailing list >dev@openvswitch.org >https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> -----Original Message----- > From: Kavanagh, Mark B > Sent: Friday, October 13, 2017 3:48 PM > To: Fischetti, Antonio <antonio.fischetti@intel.com>; dev@openvswitch.org > Subject: RE: [ovs-dev] [PATCH v5 5/6] netdev-dpdk: Reword mp_size as n_mbufs. > > >From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-bounces@openvswitch.org] > >On Behalf Of antonio.fischetti@intel.com > >Sent: Wednesday, October 11, 2017 5:01 PM > >To: dev@openvswitch.org > >Subject: [ovs-dev] [PATCH v5 5/6] netdev-dpdk: Reword mp_size as n_mbufs. > > > >Rename mp_size as n_mbufs in dpdk_mp structure. > >This parameter is passed to rte mempool creation functions > >and is meant to contain the number of elements inside > >the requested mempool. > > As previously mentioned, I don't believe that this patch should be part of the > 'fix management of pre-existing mempools' patchset, since it's a cosmetic > change, rather than an actual fix. > > Apart from that, I don't really see a need for this change - I think 'mp_size' > is sufficiently descriptive. [Antonio] I'm proposing to reword mp_size because that would mean "mempool size" to me, when instead it stores a number of mbufs. So it's a change similar to adding comments, the purpose is to make code more readable. > > Thanks, > Mark > > > > >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 | 18 +++++++++--------- > > 1 file changed, 9 insertions(+), 9 deletions(-) > > > >diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c > >index c451bc9..f67c311 100644 > >--- a/lib/netdev-dpdk.c > >+++ b/lib/netdev-dpdk.c > >@@ -308,7 +308,7 @@ struct dpdk_mp { > > int mtu; > > int socket_id; > > char if_name[IFNAMSIZ]; > >- unsigned mp_size; > >+ unsigned n_mbufs; /* Number of mbufs inside the mempool. */ > > struct ovs_list list_node OVS_GUARDED_BY(dpdk_mp_mutex); > > }; > > > >@@ -500,7 +500,7 @@ dpdk_mp_name(struct dpdk_mp *dmp) > > uint32_t h = hash_string(dmp->if_name, 0); > > char *mp_name = xcalloc(RTE_MEMPOOL_NAMESIZE, sizeof *mp_name); > > int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%d_%u", > >- h, dmp->socket_id, dmp->mtu, dmp->mp_size); > >+ h, dmp->socket_id, dmp->mtu, dmp->n_mbufs); > > ovs_assert(ret >= 0 && ret < RTE_MEMPOOL_NAMESIZE); > > return mp_name; > > } > >@@ -518,13 +518,13 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool > >*mp_exists) > > ovs_strzcpy(dmp->if_name, dev->up.name, IFNAMSIZ); > > > > /* > >- * XXX: rough estimation of memory required for port: > >+ * XXX: rough estimation of number of mbufs required for this port: > > * <packets required to fill the device rxqs> > > * + <packets that could be stuck on other ports txqs> > > * + <packets in the pmd threads> > > * + <additional memory for corner cases> > > */ > >- dmp->mp_size = dev->requested_n_rxq * dev->requested_rxq_size > >+ dmp->n_mbufs = dev->requested_n_rxq * dev->requested_rxq_size > > + dev->requested_n_txq * dev->requested_txq_size > > + MIN(RTE_MAX_LCORE, dev->requested_n_rxq) * NETDEV_MAX_BURST > > + MIN_NB_MBUF; > >@@ -534,11 +534,11 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool > >*mp_exists) > > > > VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s " > > "with %d Rx and %d Tx queues, socket id:%d.", > >- dmp->mp_size, dev->up.name, > >+ dmp->n_mbufs, dev->up.name, > > dev->requested_n_rxq, dev->requested_n_txq, > > dev->requested_socket_id); > > > >- dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->mp_size, > >+ dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->n_mbufs, > > MP_CACHE_SZ, > > sizeof (struct dp_packet) > > - sizeof (struct rte_mbuf), > >@@ -547,7 +547,7 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool > >*mp_exists) > > dmp->socket_id); > > if (dmp->mp) { > > VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name, > >- dmp->mp_size); > >+ dmp->n_mbufs); > > /* rte_pktmbuf_pool_create has done some initialization of the > > * rte_mbuf part of each dp_packet. Some OvS specific fields > > * of the packet still need to be initialized by > >@@ -565,14 +565,14 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool > >*mp_exists) > > *mp_exists = true; > > } else { > > VLOG_ERR("Failed mempool \"%s\" create request of %u mbufs", > >- mp_name, dmp->mp_size); > >+ mp_name, dmp->n_mbufs); > > } > > free(mp_name); > > if (dmp->mp) { > > return dmp; > > } > > } while (!(*mp_exists) && > >- (rte_errno == ENOMEM && (dmp->mp_size /= 2) >= MIN_NB_MBUF)); > >+ (rte_errno == ENOMEM && (dmp->n_mbufs /= 2) >= MIN_NB_MBUF)); > > > > rte_free(dmp); > > return NULL; > >-- > >2.4.11 > > > >_______________________________________________ > >dev mailing list > >dev@openvswitch.org > >https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index c451bc9..f67c311 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -308,7 +308,7 @@ struct dpdk_mp { int mtu; int socket_id; char if_name[IFNAMSIZ]; - unsigned mp_size; + unsigned n_mbufs; /* Number of mbufs inside the mempool. */ struct ovs_list list_node OVS_GUARDED_BY(dpdk_mp_mutex); }; @@ -500,7 +500,7 @@ dpdk_mp_name(struct dpdk_mp *dmp) uint32_t h = hash_string(dmp->if_name, 0); char *mp_name = xcalloc(RTE_MEMPOOL_NAMESIZE, sizeof *mp_name); int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%d_%u", - h, dmp->socket_id, dmp->mtu, dmp->mp_size); + h, dmp->socket_id, dmp->mtu, dmp->n_mbufs); ovs_assert(ret >= 0 && ret < RTE_MEMPOOL_NAMESIZE); return mp_name; } @@ -518,13 +518,13 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists) ovs_strzcpy(dmp->if_name, dev->up.name, IFNAMSIZ); /* - * XXX: rough estimation of memory required for port: + * XXX: rough estimation of number of mbufs required for this port: * <packets required to fill the device rxqs> * + <packets that could be stuck on other ports txqs> * + <packets in the pmd threads> * + <additional memory for corner cases> */ - dmp->mp_size = dev->requested_n_rxq * dev->requested_rxq_size + dmp->n_mbufs = dev->requested_n_rxq * dev->requested_rxq_size + dev->requested_n_txq * dev->requested_txq_size + MIN(RTE_MAX_LCORE, dev->requested_n_rxq) * NETDEV_MAX_BURST + MIN_NB_MBUF; @@ -534,11 +534,11 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists) VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s " "with %d Rx and %d Tx queues, socket id:%d.", - dmp->mp_size, dev->up.name, + dmp->n_mbufs, dev->up.name, dev->requested_n_rxq, dev->requested_n_txq, dev->requested_socket_id); - dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->mp_size, + dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->n_mbufs, MP_CACHE_SZ, sizeof (struct dp_packet) - sizeof (struct rte_mbuf), @@ -547,7 +547,7 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists) dmp->socket_id); if (dmp->mp) { VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name, - dmp->mp_size); + dmp->n_mbufs); /* rte_pktmbuf_pool_create has done some initialization of the * rte_mbuf part of each dp_packet. Some OvS specific fields * of the packet still need to be initialized by @@ -565,14 +565,14 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists) *mp_exists = true; } else { VLOG_ERR("Failed mempool \"%s\" create request of %u mbufs", - mp_name, dmp->mp_size); + mp_name, dmp->n_mbufs); } free(mp_name); if (dmp->mp) { return dmp; } } while (!(*mp_exists) && - (rte_errno == ENOMEM && (dmp->mp_size /= 2) >= MIN_NB_MBUF)); + (rte_errno == ENOMEM && (dmp->n_mbufs /= 2) >= MIN_NB_MBUF)); rte_free(dmp); return NULL;
Rename mp_size as n_mbufs in dpdk_mp structure. This parameter is passed to rte mempool creation functions and is meant to contain the number of elements inside the requested mempool. 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)