diff mbox series

[ovs-dev,V3,1/1] dpdk: Add debug appctl to get malloc statistics.

Message ID 20210519080053.12890-1-elibr@nvidia.com
State Accepted
Headers show
Series [ovs-dev,V3,1/1] dpdk: Add debug appctl to get malloc statistics. | expand

Commit Message

Eli Britstein May 19, 2021, 8 a.m. UTC
New appctl 'dpdk/get-malloc-stats' implemented to get result of
'rte_malloc_dump_stats()' function.

Could be used for debugging.

Signed-off-by: Eli Britstein <elibr@nvidia.com>
Reviewed-by: Salem Sol <salems@nvidia.com>
---

v2:
- Following Eelco Chaudron's comments, abandoned get-socket-stats.
- Acked-by: Eelco Chaudron <echaudro@redhat.com>
  https://mail.openvswitch.org/pipermail/ovs-dev/2021-May/382920.html
- Acked-by: Kevin Traynor <Kevin Traynor <ktraynor@redhat.com>
  https://mail.openvswitch.org/pipermail/ovs-dev/2021-May/382932.html
v3:
- Following Ilya Maximets's comment, using dpdk_unixctl_mem_stream.

 NEWS                 |  1 +
 lib/dpdk-unixctl.man |  2 ++
 lib/dpdk.c           | 10 ++++++++++
 3 files changed, 13 insertions(+)

Comments

Ilya Maximets June 18, 2021, 11:15 a.m. UTC | #1
On 5/19/21 10:00 AM, Eli Britstein wrote:
> New appctl 'dpdk/get-malloc-stats' implemented to get result of
> 'rte_malloc_dump_stats()' function.
> 
> Could be used for debugging.
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> Reviewed-by: Salem Sol <salems@nvidia.com>
> ---
> 
> v2:
> - Following Eelco Chaudron's comments, abandoned get-socket-stats.
> - Acked-by: Eelco Chaudron <echaudro@redhat.com>
>   https://mail.openvswitch.org/pipermail/ovs-dev/2021-May/382920.html
> - Acked-by: Kevin Traynor <Kevin Traynor <ktraynor@redhat.com>
>   https://mail.openvswitch.org/pipermail/ovs-dev/2021-May/382932.html
> v3:
> - Following Ilya Maximets's comment, using dpdk_unixctl_mem_stream.
> 

Thanks!  Applied.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index 402ce5969..bcb44e045 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@  Post-v2.15.0
    - DPDK:
      * OVS validated with DPDK 20.11.1. It is recommended to use this version
        until further releases.
+     * New debug appctl command 'dpdk/get-malloc-stats'.
 
 
 v2.15.0 - 15 Feb 2021
diff --git a/lib/dpdk-unixctl.man b/lib/dpdk-unixctl.man
index 2d6d576f2..a0d1fa2ea 100644
--- a/lib/dpdk-unixctl.man
+++ b/lib/dpdk-unixctl.man
@@ -10,5 +10,7 @@  list of words separated by spaces: a word can be either a logging \fBlevel\fR
 \fBnotice\fR, \fBinfo\fR or \fBdebug\fR) or a \fBpattern\fR matching DPDK
 components (see \fBdpdk/log-list\fR command on \fBovs\-appctl\fR(8)) separated
 by a colon from the logging \fBlevel\fR to apply.
+.IP "\fBdpdk/get-malloc-stats\fR"
+Prints the heap information statistics about DPDK malloc.
 .RE
 .
diff --git a/lib/dpdk.c b/lib/dpdk.c
index 319540394..2eaaa569c 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -25,6 +25,7 @@ 
 #include <rte_cpuflags.h>
 #include <rte_errno.h>
 #include <rte_log.h>
+#include <rte_malloc.h>
 #include <rte_memzone.h>
 #include <rte_version.h>
 
@@ -356,6 +357,12 @@  dpdk_unixctl_log_set(struct unixctl_conn *conn, int argc, const char *argv[],
     unixctl_command_reply(conn, NULL);
 }
 
+static void
+malloc_dump_stats_wrapper(FILE *stream)
+{
+    rte_malloc_dump_stats(stream, NULL);
+}
+
 static bool
 dpdk_init__(const struct smap *ovs_other_config)
 {
@@ -525,6 +532,9 @@  dpdk_init__(const struct smap *ovs_other_config)
                              dpdk_unixctl_mem_stream, rte_log_dump);
     unixctl_command_register("dpdk/log-set", "{level | pattern:level}", 0,
                              INT_MAX, dpdk_unixctl_log_set, NULL);
+    unixctl_command_register("dpdk/get-malloc-stats", "", 0, 0,
+                             dpdk_unixctl_mem_stream,
+                             malloc_dump_stats_wrapper);
 
     /* We are called from the main thread here */
     RTE_PER_LCORE(_lcore_id) = NON_PMD_CORE_ID;