mempool: add object usage counts for the telemetry api

Message ID 20221115153555.947526-1-rjarry@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series mempool: add object usage counts for the telemetry api |

Checks

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

Commit Message

Robin Jarry Nov. 15, 2022, 3:35 p.m. UTC
  rte_mempool_dump() already returns the number of objects available and
in the cache. This information is missing from the telemetry API. Add it
albeit with less granularity for cached counts (only report the
total_cache_count).

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 lib/mempool/rte_mempool.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Comments

Morten Brørup Nov. 15, 2022, 4:28 p.m. UTC | #1
+CC mempool maintainers

> From: Robin Jarry [mailto:rjarry@redhat.com]
> Sent: Tuesday, 15 November 2022 16.36
> 
> rte_mempool_dump() already returns the number of objects available and
> in the cache. This information is missing from the telemetry API. Add
> it
> albeit with less granularity for cached counts (only report the
> total_cache_count).
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> ---

Please consider that the individual per-lcore cache lengths could be informative for some applications too.

Anyway, they could be provided in a later patch.

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Thomas Monjalon Feb. 5, 2023, 11:30 p.m. UTC | #2
15/11/2022 17:28, Morten Brørup:
> +CC mempool maintainers
> 
> > From: Robin Jarry [mailto:rjarry@redhat.com]
> > Sent: Tuesday, 15 November 2022 16.36
> > 
> > rte_mempool_dump() already returns the number of objects available and
> > in the cache. This information is missing from the telemetry API. Add
> > it
> > albeit with less granularity for cached counts (only report the
> > total_cache_count).
> > 
> > Signed-off-by: Robin Jarry <rjarry@redhat.com>
> > ---
> 
> Please consider that the individual per-lcore cache lengths could be informative for some applications too.
> 
> Anyway, they could be provided in a later patch.
> 
> Acked-by: Morten Brørup <mb@smartsharesystems.com>

Rebased and applied, thanks.
  

Patch

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index f33f45579091..ae56f6d38b35 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -1495,6 +1495,7 @@  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;
+	uint64_t cache_count, common_count;
 
 	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
 		return;
@@ -1513,6 +1514,18 @@  mempool_info_cb(struct rte_mempool *mp, void *arg)
 	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);
+	cache_count = 0;
+	if (mp->cache_size > 0) {
+		int lcore_id;
+		for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
+			cache_count += mp->local_cache[lcore_id].len;
+	}
+	common_count = rte_mempool_ops_get_count(mp);
+	if ((cache_count + common_count) > mp->size)
+		common_count = mp->size - cache_count;
+
+	rte_tel_data_add_dict_u64(info->d, "total_cache_count", cache_count);
+	rte_tel_data_add_dict_u64(info->d, "common_pool_count", common_count);
 
 	mz = mp->mz;
 	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);