From patchwork Tue Nov 15 15:35:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robin Jarry X-Patchwork-Id: 119868 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BFCAA0547; Tue, 15 Nov 2022 16:36:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E4F4410D3; Tue, 15 Nov 2022 16:36:07 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 39FA7410E5 for ; Tue, 15 Nov 2022 16:36:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668526565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8d+8reHH0nuiYBcpD2x4V6EiBgc7ZO2jTLlmWMmDtwY=; b=NhfTCwj2MJRNOo19YO28HYcHs2DXvPF3log8FoeeEA0473pAKwP4tHlVpX88isnHXXq+Ed xR5CyP2Rd1u/EPcWxWbTgXJvJsIm0F00c++fPNHMJTea9T74Zk6reLOjmPyf2V0J2J3f+R lieRqcLdZ1gWpv8f8xTBhNDFpkM/FtQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-1k9019arMdm5_zl5fiFPeA-1; Tue, 15 Nov 2022 10:36:00 -0500 X-MC-Unique: 1k9019arMdm5_zl5fiFPeA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11DC881173C for ; Tue, 15 Nov 2022 15:36:00 +0000 (UTC) Received: from paul.home (unknown [10.39.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EDE12028CE4; Tue, 15 Nov 2022 15:35:59 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org Cc: Robin Jarry Subject: [PATCH] mempool: add object usage counts for the telemetry api Date: Tue, 15 Nov 2022 16:35:55 +0100 Message-Id: <20221115153555.947526-1-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Morten Brørup --- lib/mempool/rte_mempool.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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);