On 25 Apr 2021, at 18:28, Eli Britstein wrote:
New appctl 'dpdk/get-malloc-stats' implemented to get result of
'rte_malloc_dump_stats()' function.
rte_malloc_dump_stats() calls malloc_heap_get_stats(), so I would call
this command dpdk/get-heap-stats to also avoid collision with the other
command (see patch 1/2).
Also, do we need two individual commands? Can we not dump all this
information with a single dpdk/get-malloc-stats? We could make it dump
all socket stats (from patch 1/2) and this information?
Could be used for debugging.
Signed-off-by: Eli Britstein <[email protected]>
Reviewed-by: Salem Sol <[email protected]>
---
NEWS | 1 +
lib/dpdk-unixctl.man | 2 ++
lib/dpdk.c | 29 +++++++++++++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/NEWS b/NEWS
index e0c0f0408..3420c38ce 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Post-v2.15.0
* New command 'record-hostname-if-not-set' to update hostname in
ovsdb.
- DPDK:
* New debug appctl command 'dpdk/get-socket-stats'.
+ * 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 37f02d6c7..dc927c531 100644
--- a/lib/dpdk-unixctl.man
+++ b/lib/dpdk-unixctl.man
@@ -14,5 +14,7 @@ by a colon from the logging \fBlevel\fR to apply.
Prints the statistics information about DPDK socket \fIsocket\fR.
If called without arguments, information of all the available sockets
will
be printed.
+.IP "\fBdpdk/get-malloc-stats\fR"
+Prints the statistics information about DPDK malloc.
I would be a bit more precise, i.e., it is printing heap information.
.RE
.
diff --git a/lib/dpdk.c b/lib/dpdk.c
index 5a6b2015c..c4f223f30 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -414,6 +414,33 @@ out:
free(response);
}
+static void
+dpdk_unixctl_get_malloc_stats(struct unixctl_conn *conn,
+ int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED,
+ void *aux OVS_UNUSED)
Other than changing the function name to be more aligned with the actual
stats, and the actual name of the command, I see no code issues.
+{
+ size_t size;
+ FILE *stream;
+ char *response = NULL;
+
+ 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;
+ }
+
+ rte_malloc_dump_stats(stream, NULL);
+
+ fclose(stream);
+
+ unixctl_command_reply(conn, response);
+out:
+ free(response);
+}
+
static bool
dpdk_init__(const struct smap *ovs_other_config)
{
@@ -585,6 +612,8 @@ dpdk_init__(const struct smap *ovs_other_config)
INT_MAX, dpdk_unixctl_log_set, NULL);
unixctl_command_register("dpdk/get-socket-stats", "[socket]", 0,
INT_MAX,
dpdk_unixctl_get_socket_stats, NULL);
+ unixctl_command_register("dpdk/get-malloc-stats", "", 0, 0,
+ dpdk_unixctl_get_malloc_stats, NULL);
/* We are called from the main thread here */
RTE_PER_LCORE(_lcore_id) = NON_PMD_CORE_ID;
--
2.28.0.2311.g225365fb51
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev