From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68B0045B37; Mon, 14 Oct 2024 13:58:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4AEF34064F; Mon, 14 Oct 2024 13:58:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A842C40395 for ; Mon, 14 Oct 2024 13:58:45 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49E9kSsa015853; Mon, 14 Oct 2024 04:58:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=p HItS5V6uDKntsqKxsR0MK3/en1MfOjXg16cv7rx3/c=; b=Hf35ZO/AJ84orCnLE KCKSRsUN1sMXFiqEA72AGG0YA3Uf9ITxXMz/j2AbeRKCPQeFb0qhuzQqTwmbaUm/ q/mGFC6TFCiypvLp8Vum8StBZzkfHH8djwwg2J9YblQ9psjvzZRMUn4OQeRVnPsf UxmnRcsLy1izYAxNv8v/RLMs9MEhTXzjNfhMLgXj+AtS5F5RLDdueNIOvsZM4903 bUCOSKoJl4WHFm5FjFkBx7TpnST7KIO/ae5IAW0aBwMj2pQTji/aleWRaFXJTVDR MiLb0SgINpcA3BuCv58cZ4NfxEUVYEIPKoDrHa4E5et8XOCB307GmpZ6MjvXpbzX tAeNg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 4290y706m9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Oct 2024 04:58:39 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 14 Oct 2024 04:58:38 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 14 Oct 2024 04:58:38 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id DE7B55B6926; Mon, 14 Oct 2024 04:58:34 -0700 (PDT) From: To: , , , , , , Zhirun Yan CC: , Pavan Nikhilesh Subject: [PATCH v5 2/3] graph: add node error counters Date: Mon, 14 Oct 2024 17:28:20 +0530 Message-ID: <20241014115821.4204-3-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241014115821.4204-1-pbhagavatula@marvell.com> References: <20240816150926.5789-1-pbhagavatula@marvell.com> <20241014115821.4204-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: KJp39-QEPXvs3biNRj7Aq8mjtaFyt23L X-Proofpoint-ORIG-GUID: KJp39-QEPXvs3biNRj7Aq8mjtaFyt23L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 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 From: Pavan Nikhilesh Add node fastpath error counters advertised during node registration. Add support for retrieving/printing stats for node specific errors using rte_graph_cluster_stats_get(). Add `rte_node_error_increment` API to increment node specific error counters. Signed-off-by: Pavan Nikhilesh Acked-by: Kiran Kumar K Reviewed-by: Robin Jarry --- lib/graph/graph_populate.c | 20 +++++++- lib/graph/graph_private.h | 2 + lib/graph/graph_stats.c | 78 ++++++++++++++++++++++++++++- lib/graph/rte_graph.h | 4 ++ lib/graph/rte_graph_worker_common.h | 23 +++++++++ lib/graph/version.map | 7 +++ 6 files changed, 131 insertions(+), 3 deletions(-) diff --git a/lib/graph/graph_populate.c b/lib/graph/graph_populate.c index ed596a7711..1246f72d0f 100644 --- a/lib/graph/graph_populate.c +++ b/lib/graph/graph_populate.c @@ -39,6 +39,15 @@ graph_fp_mem_calc_size(struct graph *graph) /* Pointer to next nodes(edges) */ sz += sizeof(struct rte_node *) * graph_node->node->nb_edges; } + sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE); + graph->errors_start = sz; + /* For 0..N node objects with error counters */ + STAILQ_FOREACH(graph_node, &graph->node_list, next) { + if (graph_node->node->errs == NULL) + continue; + sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE); + sz += sizeof(uint64_t) * graph_node->node->errs->nb_errors; + } graph->mem_sz = sz; return sz; @@ -64,6 +73,7 @@ graph_header_popluate(struct graph *_graph) static void graph_nodes_populate(struct graph *_graph) { + rte_graph_off_t err_off = _graph->errors_start; rte_graph_off_t off = _graph->nodes_start; struct rte_graph *graph = _graph->graph; struct graph_node *graph_node; @@ -99,6 +109,12 @@ graph_nodes_populate(struct graph *_graph) ->adjacency_list[count] ->node->name[0]; + if (graph_node->node->errs != NULL) { + node->err_off = err_off - off; + err_off += sizeof(uint64_t) * graph_node->node->errs->nb_errors; + err_off = RTE_ALIGN(err_off, RTE_CACHE_LINE_SIZE); + } + off += sizeof(struct rte_node *) * nb_edges; off = RTE_ALIGN(off, RTE_CACHE_LINE_SIZE); node->next = off; @@ -158,7 +174,7 @@ graph_node_nexts_populate(struct graph *_graph) } static int -graph_src_nodes_populate(struct graph *_graph) +graph_src_nodes_offset_populate(struct graph *_graph) { struct rte_graph *graph = _graph->graph; struct graph_node *graph_node; @@ -193,7 +209,7 @@ graph_fp_mem_populate(struct graph *graph) graph_pcap_init(graph); graph_nodes_populate(graph); rc = graph_node_nexts_populate(graph); - rc |= graph_src_nodes_populate(graph); + rc |= graph_src_nodes_offset_populate(graph); return rc; } diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index e663b04d8b..01921b254c 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -103,6 +103,8 @@ struct graph { /**< Memzone to store graph data. */ rte_graph_off_t nodes_start; /**< Node memory start offset in graph reel. */ + rte_graph_off_t errors_start; + /**< Node error memory start offset in graph reel. */ rte_node_t src_node_count; /**< Number of source nodes in a graph. */ struct rte_graph *graph; diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index d71451a17b..44a3ea03a7 100644 --- a/lib/graph/graph_stats.c +++ b/lib/graph/graph_stats.c @@ -121,6 +121,24 @@ print_node(FILE *f, const struct rte_graph_cluster_node_stats *stat, bool dispat } } +static inline void +print_err(FILE *f, const struct rte_graph_cluster_node_stats *stat, bool dispatch) +{ + int i; + + if (dispatch) { + for (i = 0; i < stat->error_cntrs; i++) + fprintf(f, + "|\t%-24s|%15s|%-15" PRIu64 "|%15s|%15s|%15s|%15s|%15s|%11.4s|\n", + stat->error_desc[i], "", stat->error_count[i], "", "", "", "", "", + ""); + } else { + for (i = 0; i < stat->error_cntrs; i++) + fprintf(f, "|\t%-24s|%15s|%-15" PRIu64 "|%15s|%15.3s|%15.6s|%11.4s|\n", + stat->error_desc[i], "", stat->error_count[i], "", "", "", ""); + } +} + static int graph_cluster_stats_cb(bool dispatch, bool is_first, bool is_last, void *cookie, const struct rte_graph_cluster_node_stats *stat) @@ -129,8 +147,11 @@ graph_cluster_stats_cb(bool dispatch, bool is_first, bool is_last, void *cookie, if (unlikely(is_first)) print_banner(f, dispatch); - if (stat->objs) + if (stat->objs) { print_node(f, stat, dispatch); + if (stat->error_cntrs) + print_err(f, stat, dispatch); + } if (unlikely(is_last)) { if (dispatch) boarder_model_dispatch(); @@ -203,6 +224,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, struct cluster_node *cluster; struct rte_node *node; rte_node_t count; + uint8_t i; cluster = stats->clusters; @@ -240,6 +262,36 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, SET_ERR_JMP(ENOENT, free, "Failed to find node %s in graph %s", graph_node->node->name, graph->name); cluster->nodes[cluster->nb_nodes++] = node; + if (graph_node->node->errs) { + cluster->stat.error_cntrs = graph_node->node->errs->nb_errors; + cluster->stat.error_count = rte_zmalloc_socket( + NULL, sizeof(uint64_t) * graph_node->node->errs->nb_errors, + RTE_CACHE_LINE_SIZE, stats->socket_id); + if (cluster->stat.error_count == NULL) + SET_ERR_JMP(ENOMEM, free, "Failed to allocate memory node %s graph %s", + graph_node->node->name, graph->name); + + cluster->stat.error_desc = rte_zmalloc_socket( + NULL, sizeof(RTE_NODE_ERROR_DESC_SIZE) * graph_node->node->errs->nb_errors, + RTE_CACHE_LINE_SIZE, stats->socket_id); + if (cluster->stat.error_desc == NULL) { + rte_free(cluster->stat.error_count); + SET_ERR_JMP(ENOMEM, free, "Failed to allocate memory node %s graph %s", + graph_node->node->name, graph->name); + } + + for (i = 0; i < cluster->stat.error_cntrs; i++) { + if (rte_strscpy(cluster->stat.error_desc[i], + graph_node->node->errs->err_desc[i], + RTE_NODE_ERROR_DESC_SIZE) < 0) { + rte_free(cluster->stat.error_count); + rte_free(cluster->stat.error_desc); + SET_ERR_JMP(E2BIG, free, + "Error description overflow node %s graph %s", + graph_node->node->name, graph->name); + } + } + } stats->sz += stats->cluster_node_size; stats->max_nodes++; @@ -388,6 +440,18 @@ rte_graph_cluster_stats_create(const struct rte_graph_cluster_stats_param *prm) void rte_graph_cluster_stats_destroy(struct rte_graph_cluster_stats *stat) { + struct cluster_node *cluster; + rte_node_t count; + + cluster = stat->clusters; + for (count = 0; count < stat->max_nodes; count++) { + if (cluster->stat.error_cntrs) { + rte_free(cluster->stat.error_count); + rte_free(cluster->stat.error_desc); + } + + cluster = RTE_PTR_ADD(cluster, stat->cluster_node_size); + } return rte_free(stat); } @@ -399,7 +463,10 @@ cluster_node_arregate_stats(struct cluster_node *cluster, bool dispatch) uint64_t sched_objs = 0, sched_fail = 0; struct rte_node *node; rte_node_t count; + uint64_t *err; + uint8_t i; + memset(stat->error_count, 0, sizeof(uint64_t) * stat->error_cntrs); for (count = 0; count < cluster->nb_nodes; count++) { node = cluster->nodes[count]; @@ -412,6 +479,12 @@ cluster_node_arregate_stats(struct cluster_node *cluster, bool dispatch) objs += node->total_objs; cycles += node->total_cycles; realloc_count += node->realloc_count; + + if (node->err_off == 0) + continue; + err = RTE_PTR_ADD(node, node->err_off); + for (i = 0; i < stat->error_cntrs; i++) + stat->error_count[i] += err[i]; } stat->calls = calls; @@ -464,6 +537,7 @@ rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat) { struct cluster_node *cluster; rte_node_t count; + uint8_t i; cluster = stat->clusters; @@ -479,6 +553,8 @@ rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat) node->prev_objs = 0; node->prev_cycles = 0; node->realloc_count = 0; + for (i = 0; i < node->error_cntrs; i++) + node->error_count[i] = 0; cluster = RTE_PTR_ADD(cluster, stat->cluster_node_size); } } diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index b28143d737..6a9620c2d4 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -223,6 +223,10 @@ struct __rte_cache_aligned rte_graph_cluster_node_stats { uint64_t realloc_count; /**< Realloc count. */ + uint8_t error_cntrs; /**< Number of Node error counters. */ + char (*error_desc)[RTE_NODE_ERROR_DESC_SIZE]; /**< Names of the Node error counters. */ + uint64_t *error_count; /**< Total error count per each error. */ + rte_node_t id; /**< Node identifier of stats. */ uint64_t hz; /**< Cycles per seconds. */ char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */ diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 8d8956fddd..ae3282fb66 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -112,6 +112,7 @@ struct __rte_cache_aligned rte_node { uint64_t total_sched_fail; /**< Number of scheduled failure. */ } dispatch; }; + rte_graph_off_t err_off; /**< Offset to error counters. */ /* Fast path area */ __extension__ struct __rte_cache_aligned { #define RTE_NODE_CTX_SZ 16 @@ -584,6 +585,28 @@ uint8_t rte_graph_worker_model_no_check_get(struct rte_graph *graph) return graph->model; } +/** + * Increment Node error count. + * + * Increment the error count of an error for a given node. + * + * @param node + * Pointer to the node. + * @param err_id + * Error ID. + * @param value + * Value to increment. + */ +__rte_experimental +static inline void +rte_node_error_increment(struct rte_node *node, uint16_t err_id, uint64_t value) +{ + if (rte_graph_has_stats_feature()) { + uint64_t *errors = (uint64_t *)RTE_PTR_ADD(node, node->err_off); + errors[err_id] += value; + } +} + #ifdef __cplusplus } #endif diff --git a/lib/graph/version.map b/lib/graph/version.map index 2c83425ddc..b79aca6b3d 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -52,3 +52,10 @@ DPDK_25 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_node_error_increment; +}; -- 2.25.1