Message ID | 1509449704-12068-3-git-send-email-i.maximets@samsung.com |
---|---|
State | Superseded |
Delegated to: | Ian Stokes |
Headers | show |
Series | netdev-dpdk: Mempool creation failure + Appctl | expand |
> > New appctl 'netdev-dpdk/get-mempool-info' implemented to get result of > 'rte_mempool_list_dump()' function if no arguments passed and > 'rte_mempool_dump()' if DPDK netdev passed as argument. > > Could be used for debugging mbuf leaks and other mempool related issues. > Most useful in pair with `grep -v "cache_count.*=0"`. Pardon my ignorance, but do commands like these get put into the documentation, command-line help at some point? Looks like I should peruse source code and commits for other interesting commands. > > Signed-off-by: Ilya Maximets <i.maximets@samsung.com> > --- > lib/netdev-dpdk.c | 54 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 4ec536d..0e4a08c > 100644 > --- a/lib/netdev-dpdk.c > +++ b/lib/netdev-dpdk.c > @@ -2550,6 +2550,56 @@ error: > free(response); > } > > +static void > +netdev_dpdk_get_mempool_info(struct unixctl_conn *conn, > + int argc, const char *argv[], > + void *aux OVS_UNUSED) { > + size_t size; > + FILE *stream; > + char *response = NULL; > + struct netdev *netdev = NULL; > + > + if (argc == 2) { > + netdev = netdev_from_name(argv[1]); > + if (!netdev || !is_dpdk_class(netdev->netdev_class)) { > + unixctl_command_reply_error(conn, "Not a DPDK Interface"); > + goto out; > + } > + } > + > + stream = open_memstream(&response, &size); > + if (!stream) { > + response = xasprintf("Unable to open memstream: %s.", > + ovs_strerror(errno)); > + unixctl_command_reply_error(conn, response); > + goto out; > + } > + > + if (netdev) { > + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); > + > + ovs_mutex_lock(&dev->mutex); > + ovs_mutex_lock(&dpdk_mp_mutex); > + > + rte_mempool_dump(stream, dev->mp); > + > + ovs_mutex_unlock(&dpdk_mp_mutex); > + ovs_mutex_unlock(&dev->mutex); > + } else { > + ovs_mutex_lock(&dpdk_mp_mutex); > + rte_mempool_list_dump(stream); > + ovs_mutex_unlock(&dpdk_mp_mutex); > + } > + > + fclose(stream); > + > + unixctl_command_reply(conn, response); > +out: > + free(response); > + netdev_close(netdev); > +} > + > /* > * Set virtqueue flags so that we do not receive interrupts. > */ > @@ -2806,6 +2856,10 @@ netdev_dpdk_class_init(void) > "pci address of device", 1, 1, > netdev_dpdk_detach, NULL); > > + unixctl_command_register("netdev-dpdk/get-mempool-info", > + "[netdev]", 0, 1, > + netdev_dpdk_get_mempool_info, NULL); > + > ovsthread_once_done(&once); > } > > -- > 2.7.4
On 31.10.2017 14:41, Raymond Burkholder wrote: >> >> New appctl 'netdev-dpdk/get-mempool-info' implemented to get result of >> 'rte_mempool_list_dump()' function if no arguments passed and >> 'rte_mempool_dump()' if DPDK netdev passed as argument. >> >> Could be used for debugging mbuf leaks and other mempool related issues. >> Most useful in pair with `grep -v "cache_count.*=0"`. > > Pardon my ignorance, but do commands like these get put into the > documentation, command-line help at some point? > > Looks like I should peruse source code and commits for other interesting > commands. Hm.. Many appctl commands are described in man for ovs-vswitchd. I guess, it's kind of historical issue that netdev-dpdk, upcall, autoattach and maybe some other commands was never referenced there. So, maybe we need to create a section in vswitchd/ovs-vswitchd.8.in for netdev-dpdk commands later. We can make it as a separate commit after accepting of this change to add all the missing netdev-dpdk appctl calls at once. >> >> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> >> --- >> lib/netdev-dpdk.c | 54 >> ++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 54 insertions(+) >> >> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 4ec536d..0e4a08c >> 100644 >> --- a/lib/netdev-dpdk.c >> +++ b/lib/netdev-dpdk.c >> @@ -2550,6 +2550,56 @@ error: >> free(response); >> } >> >> +static void >> +netdev_dpdk_get_mempool_info(struct unixctl_conn *conn, >> + int argc, const char *argv[], >> + void *aux OVS_UNUSED) { >> + size_t size; >> + FILE *stream; >> + char *response = NULL; >> + struct netdev *netdev = NULL; >> + >> + if (argc == 2) { >> + netdev = netdev_from_name(argv[1]); >> + if (!netdev || !is_dpdk_class(netdev->netdev_class)) { >> + unixctl_command_reply_error(conn, "Not a DPDK Interface"); >> + goto out; >> + } >> + } >> + >> + stream = open_memstream(&response, &size); >> + if (!stream) { >> + response = xasprintf("Unable to open memstream: %s.", >> + ovs_strerror(errno)); >> + unixctl_command_reply_error(conn, response); >> + goto out; >> + } >> + >> + if (netdev) { >> + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); >> + >> + ovs_mutex_lock(&dev->mutex); >> + ovs_mutex_lock(&dpdk_mp_mutex); >> + >> + rte_mempool_dump(stream, dev->mp); >> + >> + ovs_mutex_unlock(&dpdk_mp_mutex); >> + ovs_mutex_unlock(&dev->mutex); >> + } else { >> + ovs_mutex_lock(&dpdk_mp_mutex); >> + rte_mempool_list_dump(stream); >> + ovs_mutex_unlock(&dpdk_mp_mutex); >> + } >> + >> + fclose(stream); >> + >> + unixctl_command_reply(conn, response); >> +out: >> + free(response); >> + netdev_close(netdev); >> +} >> + >> /* >> * Set virtqueue flags so that we do not receive interrupts. >> */ >> @@ -2806,6 +2856,10 @@ netdev_dpdk_class_init(void) >> "pci address of device", 1, 1, >> netdev_dpdk_detach, NULL); >> >> + unixctl_command_register("netdev-dpdk/get-mempool-info", >> + "[netdev]", 0, 1, >> + netdev_dpdk_get_mempool_info, NULL); >> + >> ovsthread_once_done(&once); >> } >> >> -- >> 2.7.4 > >
Thanks Ilya, looks a useful debugging command, I gave it a try. Agree with Raymond, there should be some reference in the doc somewhere. Beside that LGTM. Acked-by: Antonio Fischetti <antonio.fischetti@intel.com> > -----Original Message----- > From: Ilya Maximets [mailto:i.maximets@samsung.com] > Sent: Tuesday, October 31, 2017 11:35 AM > To: ovs-dev@openvswitch.org > Cc: Heetae Ahn <heetae82.ahn@samsung.com>; Fischetti, Antonio > <antonio.fischetti@intel.com>; Loftus, Ciara <ciara.loftus@intel.com>; > Kavanagh, Mark B <mark.b.kavanagh@intel.com>; Stokes, Ian > <ian.stokes@intel.com>; Wojciechowicz, RobertX > <robertx.wojciechowicz@intel.com>; Ilya Maximets <i.maximets@samsung.com> > Subject: [PATCH 2/2] netdev-dpdk: Add debug appctl to get mempool information. > > New appctl 'netdev-dpdk/get-mempool-info' implemented to get result > of 'rte_mempool_list_dump()' function if no arguments passed and > 'rte_mempool_dump()' if DPDK netdev passed as argument. > > Could be used for debugging mbuf leaks and other mempool related > issues. Most useful in pair with `grep -v "cache_count.*=0"`. > > Signed-off-by: Ilya Maximets <i.maximets@samsung.com> > --- > lib/netdev-dpdk.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c > index 4ec536d..0e4a08c 100644 > --- a/lib/netdev-dpdk.c > +++ b/lib/netdev-dpdk.c > @@ -2550,6 +2550,56 @@ error: > free(response); > } > > +static void > +netdev_dpdk_get_mempool_info(struct unixctl_conn *conn, > + int argc, const char *argv[], > + void *aux OVS_UNUSED) > +{ > + size_t size; > + FILE *stream; > + char *response = NULL; > + struct netdev *netdev = NULL; > + > + if (argc == 2) { > + netdev = netdev_from_name(argv[1]); > + if (!netdev || !is_dpdk_class(netdev->netdev_class)) { > + unixctl_command_reply_error(conn, "Not a DPDK Interface"); > + goto out; > + } > + } > + > + stream = open_memstream(&response, &size); > + if (!stream) { > + response = xasprintf("Unable to open memstream: %s.", > + ovs_strerror(errno)); > + unixctl_command_reply_error(conn, response); > + goto out; > + } > + > + if (netdev) { > + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); > + > + ovs_mutex_lock(&dev->mutex); > + ovs_mutex_lock(&dpdk_mp_mutex); > + > + rte_mempool_dump(stream, dev->mp); > + > + ovs_mutex_unlock(&dpdk_mp_mutex); > + ovs_mutex_unlock(&dev->mutex); > + } else { > + ovs_mutex_lock(&dpdk_mp_mutex); > + rte_mempool_list_dump(stream); > + ovs_mutex_unlock(&dpdk_mp_mutex); > + } > + > + fclose(stream); > + > + unixctl_command_reply(conn, response); > +out: > + free(response); > + netdev_close(netdev); > +} > + > /* > * Set virtqueue flags so that we do not receive interrupts. > */ > @@ -2806,6 +2856,10 @@ netdev_dpdk_class_init(void) > "pci address of device", 1, 1, > netdev_dpdk_detach, NULL); > > + unixctl_command_register("netdev-dpdk/get-mempool-info", > + "[netdev]", 0, 1, > + netdev_dpdk_get_mempool_info, NULL); > + > ovsthread_once_done(&once); > } > > -- > 2.7.4
On 31.10.2017 17:01, Fischetti, Antonio wrote: > Thanks Ilya, looks a useful debugging command, I gave it a try. > Agree with Raymond, there should be some reference in the doc somewhere. Thanks for review and testing. I've sent patch with documentation update in reply to cover-letter (with 3/2 tag). Best regards, Ilya Maximets. > Beside that LGTM. > > Acked-by: Antonio Fischetti <antonio.fischetti@intel.com> > >> -----Original Message----- >> From: Ilya Maximets [mailto:i.maximets@samsung.com] >> Sent: Tuesday, October 31, 2017 11:35 AM >> To: ovs-dev@openvswitch.org >> Cc: Heetae Ahn <heetae82.ahn@samsung.com>; Fischetti, Antonio >> <antonio.fischetti@intel.com>; Loftus, Ciara <ciara.loftus@intel.com>; >> Kavanagh, Mark B <mark.b.kavanagh@intel.com>; Stokes, Ian >> <ian.stokes@intel.com>; Wojciechowicz, RobertX >> <robertx.wojciechowicz@intel.com>; Ilya Maximets <i.maximets@samsung.com> >> Subject: [PATCH 2/2] netdev-dpdk: Add debug appctl to get mempool information. >> >> New appctl 'netdev-dpdk/get-mempool-info' implemented to get result >> of 'rte_mempool_list_dump()' function if no arguments passed and >> 'rte_mempool_dump()' if DPDK netdev passed as argument. >> >> Could be used for debugging mbuf leaks and other mempool related >> issues. Most useful in pair with `grep -v "cache_count.*=0"`. >> >> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> >> --- >> lib/netdev-dpdk.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 54 insertions(+) >> >> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c >> index 4ec536d..0e4a08c 100644 >> --- a/lib/netdev-dpdk.c >> +++ b/lib/netdev-dpdk.c >> @@ -2550,6 +2550,56 @@ error: >> free(response); >> } >> >> +static void >> +netdev_dpdk_get_mempool_info(struct unixctl_conn *conn, >> + int argc, const char *argv[], >> + void *aux OVS_UNUSED) >> +{ >> + size_t size; >> + FILE *stream; >> + char *response = NULL; >> + struct netdev *netdev = NULL; >> + >> + if (argc == 2) { >> + netdev = netdev_from_name(argv[1]); >> + if (!netdev || !is_dpdk_class(netdev->netdev_class)) { >> + unixctl_command_reply_error(conn, "Not a DPDK Interface"); >> + goto out; >> + } >> + } >> + >> + stream = open_memstream(&response, &size); >> + if (!stream) { >> + response = xasprintf("Unable to open memstream: %s.", >> + ovs_strerror(errno)); >> + unixctl_command_reply_error(conn, response); >> + goto out; >> + } >> + >> + if (netdev) { >> + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); >> + >> + ovs_mutex_lock(&dev->mutex); >> + ovs_mutex_lock(&dpdk_mp_mutex); >> + >> + rte_mempool_dump(stream, dev->mp); >> + >> + ovs_mutex_unlock(&dpdk_mp_mutex); >> + ovs_mutex_unlock(&dev->mutex); >> + } else { >> + ovs_mutex_lock(&dpdk_mp_mutex); >> + rte_mempool_list_dump(stream); >> + ovs_mutex_unlock(&dpdk_mp_mutex); >> + } >> + >> + fclose(stream); >> + >> + unixctl_command_reply(conn, response); >> +out: >> + free(response); >> + netdev_close(netdev); >> +} >> + >> /* >> * Set virtqueue flags so that we do not receive interrupts. >> */ >> @@ -2806,6 +2856,10 @@ netdev_dpdk_class_init(void) >> "pci address of device", 1, 1, >> netdev_dpdk_detach, NULL); >> >> + unixctl_command_register("netdev-dpdk/get-mempool-info", >> + "[netdev]", 0, 1, >> + netdev_dpdk_get_mempool_info, NULL); >> + >> ovsthread_once_done(&once); >> } >> >> -- >> 2.7.4 > > > >
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 4ec536d..0e4a08c 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2550,6 +2550,56 @@ error: free(response); } +static void +netdev_dpdk_get_mempool_info(struct unixctl_conn *conn, + int argc, const char *argv[], + void *aux OVS_UNUSED) +{ + size_t size; + FILE *stream; + char *response = NULL; + struct netdev *netdev = NULL; + + if (argc == 2) { + netdev = netdev_from_name(argv[1]); + if (!netdev || !is_dpdk_class(netdev->netdev_class)) { + unixctl_command_reply_error(conn, "Not a DPDK Interface"); + goto out; + } + } + + stream = open_memstream(&response, &size); + if (!stream) { + response = xasprintf("Unable to open memstream: %s.", + ovs_strerror(errno)); + unixctl_command_reply_error(conn, response); + goto out; + } + + if (netdev) { + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + + ovs_mutex_lock(&dev->mutex); + ovs_mutex_lock(&dpdk_mp_mutex); + + rte_mempool_dump(stream, dev->mp); + + ovs_mutex_unlock(&dpdk_mp_mutex); + ovs_mutex_unlock(&dev->mutex); + } else { + ovs_mutex_lock(&dpdk_mp_mutex); + rte_mempool_list_dump(stream); + ovs_mutex_unlock(&dpdk_mp_mutex); + } + + fclose(stream); + + unixctl_command_reply(conn, response); +out: + free(response); + netdev_close(netdev); +} + /* * Set virtqueue flags so that we do not receive interrupts. */ @@ -2806,6 +2856,10 @@ netdev_dpdk_class_init(void) "pci address of device", 1, 1, netdev_dpdk_detach, NULL); + unixctl_command_register("netdev-dpdk/get-mempool-info", + "[netdev]", 0, 1, + netdev_dpdk_get_mempool_info, NULL); + ovsthread_once_done(&once); }
New appctl 'netdev-dpdk/get-mempool-info' implemented to get result of 'rte_mempool_list_dump()' function if no arguments passed and 'rte_mempool_dump()' if DPDK netdev passed as argument. Could be used for debugging mbuf leaks and other mempool related issues. Most useful in pair with `grep -v "cache_count.*=0"`. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> --- lib/netdev-dpdk.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)