Message ID | 1508159716-3656-4-git-send-email-antonio.fischetti@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | netdev-dpdk: Fix mempool management and other cleanup. | expand |
>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 3/5] netdev-dpdk: manage empty mempool names. It's not just empty names - the name could also be too long. Probably best to rephrase the commit name accordingly. > >In case a mempool name could not be generated log a message >and return a null mempool pointer to the caller. > >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 | 7 +++++++ > 1 file changed, 7 insertions(+) > >diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c >index 07c438a..dd5759b 100644 >--- a/lib/netdev-dpdk.c >+++ b/lib/netdev-dpdk.c >@@ -502,6 +502,9 @@ dpdk_mp_name(struct dpdk_mp *dmp) > int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%d_%u", > h, dmp->socket_id, dmp->mtu, dmp->mp_size); > if (ret < 0 || ret >= RTE_MEMPOOL_NAMESIZE) { >+ VLOG_ERR("Failed to generate a mempool name for \"%s\". " >+ "Hash:0x%x, mtu:%d, mbufs:%u, ret:%d", >+ dmp->if_name, h, dmp->mtu, dmp->mp_size, ret); A string from ovs_strerror(ret) would probably be more useful than the return value itself here. I'm not sure how useful the individual values themselves are in an ERR log either (more suited to a DBG log). -Mark > return NULL; > } > return mp_name; >@@ -533,6 +536,10 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool >*mp_exists) > > do { > char *mp_name = dpdk_mp_name(dmp); >+ if (!mp_name) { >+ rte_free(dmp); >+ return NULL; >+ } > > VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s " > "with %d Rx and %d Tx queues, socket id:%d.", >-- >2.4.11
Thanks Mark for your suggestions, I'll rework accordingly. -Antonio > -----Original Message----- > From: Kavanagh, Mark B > Sent: Tuesday, October 17, 2017 2:35 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 3/5] netdev-dpdk: manage empty mempool names. > > >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 3/5] netdev-dpdk: manage empty mempool names. > > It's not just empty names - the name could also be too long. Probably best to > rephrase the commit name accordingly. > > > > >In case a mempool name could not be generated log a message > >and return a null mempool pointer to the caller. > > > >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 | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > >diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c > >index 07c438a..dd5759b 100644 > >--- a/lib/netdev-dpdk.c > >+++ b/lib/netdev-dpdk.c > >@@ -502,6 +502,9 @@ dpdk_mp_name(struct dpdk_mp *dmp) > > int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%d_%u", > > h, dmp->socket_id, dmp->mtu, dmp->mp_size); > > if (ret < 0 || ret >= RTE_MEMPOOL_NAMESIZE) { > >+ VLOG_ERR("Failed to generate a mempool name for \"%s\". " > >+ "Hash:0x%x, mtu:%d, mbufs:%u, ret:%d", > >+ dmp->if_name, h, dmp->mtu, dmp->mp_size, ret); > > A string from ovs_strerror(ret) would probably be more useful than the return > value itself here. > I'm not sure how useful the individual values themselves are in an ERR log > either (more suited to a DBG log). > -Mark > > > return NULL; > > } > > return mp_name; > >@@ -533,6 +536,10 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool > >*mp_exists) > > > > do { > > char *mp_name = dpdk_mp_name(dmp); > >+ if (!mp_name) { > >+ rte_free(dmp); > >+ return NULL; > >+ } > > > > VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s " > > "with %d Rx and %d Tx queues, socket id:%d.", > >-- > >2.4.11
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 07c438a..dd5759b 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -502,6 +502,9 @@ dpdk_mp_name(struct dpdk_mp *dmp) int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%d_%u", h, dmp->socket_id, dmp->mtu, dmp->mp_size); if (ret < 0 || ret >= RTE_MEMPOOL_NAMESIZE) { + VLOG_ERR("Failed to generate a mempool name for \"%s\". " + "Hash:0x%x, mtu:%d, mbufs:%u, ret:%d", + dmp->if_name, h, dmp->mtu, dmp->mp_size, ret); return NULL; } return mp_name; @@ -533,6 +536,10 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists) do { char *mp_name = dpdk_mp_name(dmp); + if (!mp_name) { + rte_free(dmp); + return NULL; + } VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s " "with %d Rx and %d Tx queues, socket id:%d.",
In case a mempool name could not be generated log a message and return a null mempool pointer to the caller. 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 | 7 +++++++ 1 file changed, 7 insertions(+)