[v2] mempool: add telemetry endpoint for mempool info

Message ID 6dabad2f3b015ea429397e4585f5c47f8ad121ad.1634873109.git.gmuthukrishn@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] mempool: add telemetry endpoint for mempool info |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Gowrishankar Muthukrishnan Oct. 22, 2021, 3:28 a.m. UTC
  Add telemetry endpoint for mempool info.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
---
v2:
 - code alignments fixed

---
 lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
  

Comments

David Marchand Oct. 22, 2021, 5:55 a.m. UTC | #1
On Fri, Oct 22, 2021 at 5:28 AM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> Add telemetry endpoint for mempool info.
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>

Windows compilation is broken.

FAILED: lib/librte_mempool.a.p/mempool_rte_mempool.c.obj
"clang" "-Ilib\librte_mempool.a.p" "-Ilib" "-I..\lib" "-Ilib\mempool"
"-I..\lib\mempool" "-I." "-I.." "-Iconfig" "-I..\config"
"-Ilib\eal\include" "-I..\lib\eal\include" "-Ilib\eal\windows\include"
"-I..\lib\eal\windows\include" "-Ilib\eal\x86\include"
"-I..\lib\eal\x86\include" "-Ilib\eal\common" "-I..\lib\eal\common"
"-Ilib\eal" "-I..\lib\eal" "-Ilib\kvargs" "-I..\lib\kvargs"
"-Ilib\ring" "-I..\lib\ring" "-Xclang" "-fcolor-diagnostics" "-pipe"
"-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-Werror" "-O3"
"-include" "rte_config.h" "-Wextra" "-Wcast-qual" "-Wdeprecated"
"-Wformat" "-Wformat-nonliteral" "-Wformat-security"
"-Wmissing-declarations" "-Wmissing-prototypes" "-Wnested-externs"
"-Wold-style-definition" "-Wpointer-arith" "-Wsign-compare"
"-Wstrict-prototypes" "-Wundef" "-Wwrite-strings"
"-Wno-address-of-packed-member" "-Wno-missing-field-initializers"
"-D_GNU_SOURCE" "-D_WIN32_WINNT=0x0A00" "-D_CRT_SECURE_NO_WARNINGS"
"-march=native" "-DALLOW_EXPERIMENTAL_API" "-DALLOW_INTERNAL_API"
"-DRTE_LOG_DEFAULT_LOGTYPE=lib.mempool" -MD -MQ
lib/librte_mempool.a.p/mempool_rte_mempool.c.obj -MF
"lib\librte_mempool.a.p\mempool_rte_mempool.c.obj.d" -o
lib/librte_mempool.a.p/mempool_rte_mempool.c.obj "-c"
../lib/mempool/rte_mempool.c
../lib/mempool/rte_mempool.c:34:10: fatal error: 'rte_telemetry.h'
file not found
#include <rte_telemetry.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.


Linux builds are fine, I checked locally:
[1/212] ccache cc -Ilib/librte_mempool.a.p -Ilib -I../lib
-Ilib/mempool -I../lib/mempool -I. -I.. -Iconfig -I../config
-Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include
-I../lib/eal/linux/include -Ilib/eal/x86/include
-I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common
-Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/metrics
-I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/ring
-I../lib/ring -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror
-O2 -g -include rte_config.h -Wextra -Wcast-qual -Wdeprecated -Wformat
-Wformat-nonliteral -Wformat-security -Wmissing-declarations
-Wmissing-prototypes -Wnested-externs -Wold-style-definition
-Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef
-Wwrite-strings -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC
-march=native -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API
-DRTE_LOG_DEFAULT_LOGTYPE=lib.mempool -MD -MQ
lib/librte_mempool.a.p/mempool_rte_mempool.c.o -MF
lib/librte_mempool.a.p/mempool_rte_mempool.c.o.d -o
lib/librte_mempool.a.p/mempool_rte_mempool.c.o -c
../lib/mempool/rte_mempool.c

I guess there is an implicit dependency pulling telemetry for Linux.

mempool had no dependency to telemetry so far, you need to add en
explicit dependency in meson.build deps array.
  

Patch

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index b75d26c82a..2d915e591d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,7 @@ 
 #include <rte_spinlock.h>
 #include <rte_tailq.h>
 #include <rte_eal_paging.h>
+#include <rte_telemetry.h>
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
@@ -1483,3 +1484,86 @@  rte_mempool_event_callback_unregister(rte_mempool_event_callback *func,
 	rte_errno = -ret;
 	return ret;
 }
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_handle_list(const char *cmd __rte_unused,
+		    const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+struct mempool_info_cb_arg {
+	char *pool_name;
+	struct rte_tel_data *d;
+};
+
+static void
+mempool_info_cb(struct rte_mempool *mp, void *arg)
+{
+	struct mempool_info_cb_arg *info = (struct mempool_info_cb_arg *)arg;
+	const struct rte_memzone *mz;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	rte_tel_data_add_dict_string(info->d, "name", mp->name);
+	rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
+	rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
+	rte_tel_data_add_dict_int(info->d, "size", mp->size);
+	rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
+	rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
+	rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
+	rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
+	rte_tel_data_add_dict_int(info->d, "private_data_size",
+				  mp->private_data_size);
+	rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
+	rte_tel_data_add_dict_int(info->d, "populated_size",
+				  mp->populated_size);
+
+	mz = mp->mz;
+	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
+	rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
+	rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
+				  mz->hugepage_sz);
+	rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
+	rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
+}
+
+static int
+mempool_handle_info(const char *cmd __rte_unused, const char *params,
+		    struct rte_tel_data *d)
+{
+	struct mempool_info_cb_arg mp_arg;
+	char name[RTE_MEMZONE_NAMESIZE];
+
+	if (!params || strlen(params) == 0)
+		return -EINVAL;
+
+	rte_strlcpy(name, params, RTE_MEMZONE_NAMESIZE);
+
+	rte_tel_data_start_dict(d);
+	mp_arg.pool_name = name;
+	mp_arg.d = d;
+	rte_mempool_walk(mempool_info_cb, &mp_arg);
+
+	return 0;
+}
+
+RTE_INIT(mempool_init_telemetry)
+{
+	rte_telemetry_register_cmd("/mempool/list", mempool_handle_list,
+		"Returns list of available mempool. Takes no parameters");
+	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
+		"Returns mempool info. Parameters: pool_name");
+}