From patchwork Fri Mar 24 02:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125485 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 DA13E4281E; Fri, 24 Mar 2023 04:16:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4030427F2; Fri, 24 Mar 2023 04:16:35 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 242E34068E for ; Fri, 24 Mar 2023 04:16:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627793; x=1711163793; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hpt9SgmheKNTT+hXa2+7TC+TY6i5yOyzm4b34bUIb5w=; b=RX5S167uO6VC6SMdT+/rg11nLyGzbugvWAXvjwHgkTdr8S/S/MjoMwDk pN7gWKRttl3vYPV4fXGGpmWAuGwOTstisjLyhbtDHjwDI16eJ4XyZJiXX O79fg4qXUDsA8WYQOfL9t36OFoyzewKZXbk6xH/D3amF4afMKzvBBEZO7 Ba3yVPquRAeTbxi2qnyhNqFK50XdTa0nLdlPmxHbQy/bAr2lp3DnDGxd8 cDacgwXHzZyMU8URup9XADPvJQuTU5VcvJpuG2HU3kd/DjObWVQgdZsWd Hc+zwiCIDXfLfWybmKzHR/3ER36SdfoTYmzSYpI2DIeEPaq7vYtsAZLot w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266405" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266405" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998509" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998509" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:30 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 01/15] graph: rename rte_graph_work as common Date: Fri, 24 Mar 2023 11:16:08 +0900 Message-Id: <20230324021622.1369006-2-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Rename rte_graph_work.h to rte_graph_work_common.h for supporting multiple graph worker model. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- MAINTAINERS | 1 + lib/graph/graph_pcap.c | 2 +- lib/graph/graph_private.h | 2 +- lib/graph/meson.build | 2 +- lib/graph/{rte_graph_worker.h => rte_graph_worker_common.h} | 6 +++--- 5 files changed, 7 insertions(+), 6 deletions(-) rename lib/graph/{rte_graph_worker.h => rte_graph_worker_common.h} (99%) diff --git a/MAINTAINERS b/MAINTAINERS index 1a33ad8592..2608afba7b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1715,6 +1715,7 @@ F: doc/guides/prog_guide/bpf_lib.rst Graph - EXPERIMENTAL M: Jerin Jacob M: Kiran Kumar K +M: Zhirun Yan F: lib/graph/ F: doc/guides/prog_guide/graph_lib.rst F: app/test/test_graph* diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c index 6c43330029..8a220370fa 100644 --- a/lib/graph/graph_pcap.c +++ b/lib/graph/graph_pcap.c @@ -10,7 +10,7 @@ #include #include -#include "rte_graph_worker.h" +#include "rte_graph_worker_common.h" #include "graph_pcap_private.h" diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index 7d1b30b8ac..f08dbc7e9d 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -12,7 +12,7 @@ #include #include "rte_graph.h" -#include "rte_graph_worker.h" +#include "rte_graph_worker_common.h" extern int rte_graph_logtype; diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 3526d1b5d4..4e2b612ad3 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -16,6 +16,6 @@ sources = files( 'graph_populate.c', 'graph_pcap.c', ) -headers = files('rte_graph.h', 'rte_graph_worker.h') +headers = files('rte_graph.h', 'rte_graph_worker_common.h') deps += ['eal', 'pcapng'] diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker_common.h similarity index 99% rename from lib/graph/rte_graph_worker.h rename to lib/graph/rte_graph_worker_common.h index 438595b15c..0bad2938f3 100644 --- a/lib/graph/rte_graph_worker.h +++ b/lib/graph/rte_graph_worker_common.h @@ -2,8 +2,8 @@ * Copyright(C) 2020 Marvell International Ltd. */ -#ifndef _RTE_GRAPH_WORKER_H_ -#define _RTE_GRAPH_WORKER_H_ +#ifndef _RTE_GRAPH_WORKER_COMMON_H_ +#define _RTE_GRAPH_WORKER_COMMON_H_ /** * @file rte_graph_worker.h @@ -518,4 +518,4 @@ rte_node_next_stream_move(struct rte_graph *graph, struct rte_node *src, } #endif -#endif /* _RTE_GRAPH_WORKER_H_ */ +#endif /* _RTE_GRAPH_WORKER_COIMMON_H_ */ From patchwork Fri Mar 24 02:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125486 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 46C6F4281E; Fri, 24 Mar 2023 04:16:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1D6A42B8C; Fri, 24 Mar 2023 04:16:36 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 3AF3641151 for ; Fri, 24 Mar 2023 04:16:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627795; x=1711163795; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lf71wihasENtQbFGYC7KX/IvY97dKz3RS3iszWg6WiU=; b=E3GLCx5lJ8kjonxW5Kro/uik7BiVLZFlsdJpq14coSmbBFNjIv4J0NJO 8A4dBJQffz+ASVBftrfrwljvDrTJTuqg5HtDuZj3z1UtF82ZQM7/PddWI 1wbYJ3gNswBMhkUWrlJUvsbmYKrposKR345uMC3WcX1b5eiXRJRaOkELd Gm/TYPwic0PbnIWe8aZvd22wiAkl4gACSGrdKeZBQYNPLLtjvUUwJ+lf3 mgsr8xXoafQIHnKH5O3uX2jfN/G0jObHRTIi/WwWbX4h5e3w8XA/17DEm i4VqCE3CaY6Zsfd2+qGHnhdXx8ogFZsAUe0Ohj5vo0diaZvx2Ka/UltWd w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266412" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266412" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998512" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998512" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:32 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 02/15] graph: split graph worker into common and default model Date: Fri, 24 Mar 2023 11:16:09 +0900 Message-Id: <20230324021622.1369006-3-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 To support multiple graph worker model, split graph into common and default. Naming the current walk function as rte_graph_model_rtc cause the default model is RTC(Run-to-completion). Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph_pcap.c | 2 +- lib/graph/graph_private.h | 2 +- lib/graph/meson.build | 2 +- lib/graph/rte_graph_model_rtc.h | 61 +++++++++++++++++++++++++++++ lib/graph/rte_graph_worker.h | 34 ++++++++++++++++ lib/graph/rte_graph_worker_common.h | 57 --------------------------- 6 files changed, 98 insertions(+), 60 deletions(-) create mode 100644 lib/graph/rte_graph_model_rtc.h create mode 100644 lib/graph/rte_graph_worker.h diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c index 8a220370fa..6c43330029 100644 --- a/lib/graph/graph_pcap.c +++ b/lib/graph/graph_pcap.c @@ -10,7 +10,7 @@ #include #include -#include "rte_graph_worker_common.h" +#include "rte_graph_worker.h" #include "graph_pcap_private.h" diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index f08dbc7e9d..7d1b30b8ac 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -12,7 +12,7 @@ #include #include "rte_graph.h" -#include "rte_graph_worker_common.h" +#include "rte_graph_worker.h" extern int rte_graph_logtype; diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 4e2b612ad3..3526d1b5d4 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -16,6 +16,6 @@ sources = files( 'graph_populate.c', 'graph_pcap.c', ) -headers = files('rte_graph.h', 'rte_graph_worker_common.h') +headers = files('rte_graph.h', 'rte_graph_worker.h') deps += ['eal', 'pcapng'] diff --git a/lib/graph/rte_graph_model_rtc.h b/lib/graph/rte_graph_model_rtc.h new file mode 100644 index 0000000000..665560f831 --- /dev/null +++ b/lib/graph/rte_graph_model_rtc.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#include "rte_graph_worker_common.h" + +/** + * Perform graph walk on the circular buffer and invoke the process function + * of the nodes and collect the stats. + * + * @param graph + * Graph pointer returned from rte_graph_lookup function. + * + * @see rte_graph_lookup() + */ +static inline void +rte_graph_walk_rtc(struct rte_graph *graph) +{ + const rte_graph_off_t *cir_start = graph->cir_start; + const rte_node_t mask = graph->cir_mask; + uint32_t head = graph->head; + struct rte_node *node; + uint64_t start; + uint16_t rc; + void **objs; + + /* + * Walk on the source node(s) ((cir_start - head) -> cir_start) and then + * on the pending streams (cir_start -> (cir_start + mask) -> cir_start) + * in a circular buffer fashion. + * + * +-----+ <= cir_start - head [number of source nodes] + * | | + * | ... | <= source nodes + * | | + * +-----+ <= cir_start [head = 0] [tail = 0] + * | | + * | ... | <= pending streams + * | | + * +-----+ <= cir_start + mask + */ + while (likely(head != graph->tail)) { + node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]); + RTE_ASSERT(node->fence == RTE_GRAPH_FENCE); + objs = node->objs; + rte_prefetch0(objs); + + if (rte_graph_has_stats_feature()) { + start = rte_rdtsc(); + rc = node->process(graph, node, objs, node->idx); + node->total_cycles += rte_rdtsc() - start; + node->total_calls++; + node->total_objs += rc; + } else { + node->process(graph, node, objs, node->idx); + } + node->idx = 0; + head = likely((int32_t)head > 0) ? head & mask : head; + } + graph->tail = 0; +} diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h new file mode 100644 index 0000000000..7ea18ba80a --- /dev/null +++ b/lib/graph/rte_graph_worker.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#ifndef _RTE_GRAPH_WORKER_H_ +#define _RTE_GRAPH_WORKER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "rte_graph_model_rtc.h" + +/** + * Perform graph walk on the circular buffer and invoke the process function + * of the nodes and collect the stats. + * + * @param graph + * Graph pointer returned from rte_graph_lookup function. + * + * @see rte_graph_lookup() + */ +__rte_experimental +static inline void +rte_graph_walk(struct rte_graph *graph) +{ + rte_graph_walk_rtc(graph); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_GRAPH_WORKER_H_ */ diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 0bad2938f3..b58f8f6947 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -128,63 +128,6 @@ __rte_experimental void __rte_node_stream_alloc_size(struct rte_graph *graph, struct rte_node *node, uint16_t req_size); -/** - * Perform graph walk on the circular buffer and invoke the process function - * of the nodes and collect the stats. - * - * @param graph - * Graph pointer returned from rte_graph_lookup function. - * - * @see rte_graph_lookup() - */ -__rte_experimental -static inline void -rte_graph_walk(struct rte_graph *graph) -{ - const rte_graph_off_t *cir_start = graph->cir_start; - const rte_node_t mask = graph->cir_mask; - uint32_t head = graph->head; - struct rte_node *node; - uint64_t start; - uint16_t rc; - void **objs; - - /* - * Walk on the source node(s) ((cir_start - head) -> cir_start) and then - * on the pending streams (cir_start -> (cir_start + mask) -> cir_start) - * in a circular buffer fashion. - * - * +-----+ <= cir_start - head [number of source nodes] - * | | - * | ... | <= source nodes - * | | - * +-----+ <= cir_start [head = 0] [tail = 0] - * | | - * | ... | <= pending streams - * | | - * +-----+ <= cir_start + mask - */ - while (likely(head != graph->tail)) { - node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]); - RTE_ASSERT(node->fence == RTE_GRAPH_FENCE); - objs = node->objs; - rte_prefetch0(objs); - - if (rte_graph_has_stats_feature()) { - start = rte_rdtsc(); - rc = node->process(graph, node, objs, node->idx); - node->total_cycles += rte_rdtsc() - start; - node->total_calls++; - node->total_objs += rc; - } else { - node->process(graph, node, objs, node->idx); - } - node->idx = 0; - head = likely((int32_t)head > 0) ? head & mask : head; - } - graph->tail = 0; -} - /* Fast path helper functions */ /** From patchwork Fri Mar 24 02:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125487 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 A36424281E; Fri, 24 Mar 2023 04:16:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02488427E9; Fri, 24 Mar 2023 04:16:39 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 442FA42BAC for ; Fri, 24 Mar 2023 04:16:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627797; x=1711163797; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EoeDHzSoMCh9gW/nQpMjzg2WI1Xo6w5PxEC7qbrHzkk=; b=MAGHhZtypJAfpvisvIPGv/JbvAGA7WxrErWiL3oRg05to5FCd3oNZmN2 efISb8wg3xmv95z8MgQBJP0viRFTGpU6niXcElA/fGDd6VxOTsI57GgBR Dq4yoe1SoOwIv5I2RLENVcjt4LUiDbll9EpcRdqjboaUE19xixc9z1pMm Bq0qhrCNswEgGRMp0AdbPrgmEWoSJ1Kp77FYK1kQH/k+d953J6j5dW+gu zCzy9633Bnbw7BB/6vVv2Z5OcxavdvtifeuFTMJRMuxAg+Z2gW9v8hsAD Kia3cbxaDM2L6bbvSVwoRNUwCguDeTC4c3QFH9mgHoOYjV587qaVuFTMX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266417" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266417" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998519" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998519" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:34 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 03/15] graph: move node process into inline function Date: Fri, 24 Mar 2023 11:16:10 +0900 Message-Id: <20230324021622.1369006-4-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Node process is a single and reusable block, move the code into an inline function. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/rte_graph_model_rtc.h | 20 ++--------------- lib/graph/rte_graph_worker_common.h | 33 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/lib/graph/rte_graph_model_rtc.h b/lib/graph/rte_graph_model_rtc.h index 665560f831..0dcb7151e9 100644 --- a/lib/graph/rte_graph_model_rtc.h +++ b/lib/graph/rte_graph_model_rtc.h @@ -20,9 +20,6 @@ rte_graph_walk_rtc(struct rte_graph *graph) const rte_node_t mask = graph->cir_mask; uint32_t head = graph->head; struct rte_node *node; - uint64_t start; - uint16_t rc; - void **objs; /* * Walk on the source node(s) ((cir_start - head) -> cir_start) and then @@ -41,21 +38,8 @@ rte_graph_walk_rtc(struct rte_graph *graph) */ while (likely(head != graph->tail)) { node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]); - RTE_ASSERT(node->fence == RTE_GRAPH_FENCE); - objs = node->objs; - rte_prefetch0(objs); - - if (rte_graph_has_stats_feature()) { - start = rte_rdtsc(); - rc = node->process(graph, node, objs, node->idx); - node->total_cycles += rte_rdtsc() - start; - node->total_calls++; - node->total_objs += rc; - } else { - node->process(graph, node, objs, node->idx); - } - node->idx = 0; - head = likely((int32_t)head > 0) ? head & mask : head; + __rte_node_process(graph, node); + head = likely((int32_t)head > 0) ? head & mask : head; } graph->tail = 0; } diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index b58f8f6947..41428974db 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -130,6 +130,39 @@ void __rte_node_stream_alloc_size(struct rte_graph *graph, /* Fast path helper functions */ +/** + * @internal + * + * Enqueue a given node to the tail of the graph reel. + * + * @param graph + * Pointer Graph object. + * @param node + * Pointer to node object to be enqueued. + */ +static __rte_always_inline void +__rte_node_process(struct rte_graph *graph, struct rte_node *node) +{ + uint64_t start; + uint16_t rc; + void **objs; + + RTE_ASSERT(node->fence == RTE_GRAPH_FENCE); + objs = node->objs; + rte_prefetch0(objs); + + if (rte_graph_has_stats_feature()) { + start = rte_rdtsc(); + rc = node->process(graph, node, objs, node->idx); + node->total_cycles += rte_rdtsc() - start; + node->total_calls++; + node->total_objs += rc; + } else { + node->process(graph, node, objs, node->idx); + } + node->idx = 0; +} + /** * @internal * From patchwork Fri Mar 24 02:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125488 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 790424281E; Fri, 24 Mar 2023 04:16:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 206DE42C24; Fri, 24 Mar 2023 04:16:42 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 9966842B7E for ; Fri, 24 Mar 2023 04:16:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627800; x=1711163800; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vdJxbPGuKUZXYPHOkmrzrKeHmSxebUYv+5Vsb/m2KWQ=; b=WkAWZRH9Wl45jzbeUAHG+YPD8WxKN5h+bowmgD+IP8uSPIIQWJMmg7Sw 40othKlvbrFl552ks4965Tq83d7BPwj9vfk9jPTBIOm1hqhAgvJnZhLRY vRv+WDHLscY30R5tdyT/BKDg9Uk8Yqj1qSWmBRGvq8b6xvDwQTYBh30Eo maLji532v+sXPLyI2VBiMXk1QIMgJ/zj/KlAFCIuROBlP/PDUNjQDbysI R63JVcCiz0EjBVuJDuwmABbapMtGknUq/3lojqpPiGMYVPpLxCPZgtnGt CkwaEwESuzKRXzKRce8fS02rkZCJICPqF1M2AYfTW5QyPaPC9HSn+fYl2 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266423" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266423" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998523" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998523" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:36 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 04/15] graph: add get/set graph worker model APIs Date: Fri, 24 Mar 2023 11:16:11 +0900 Message-Id: <20230324021622.1369006-5-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Add new get/set APIs to configure graph worker model which is used to determine which model will be chosen. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/meson.build | 1 + lib/graph/rte_graph_worker.c | 54 +++++++++++++++++++++++++++++ lib/graph/rte_graph_worker_common.h | 16 +++++++++ lib/graph/version.map | 3 ++ 4 files changed, 74 insertions(+) create mode 100644 lib/graph/rte_graph_worker.c diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 3526d1b5d4..9fab8243da 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -15,6 +15,7 @@ sources = files( 'graph_stats.c', 'graph_populate.c', 'graph_pcap.c', + 'rte_graph_worker.c', ) headers = files('rte_graph.h', 'rte_graph_worker.h') diff --git a/lib/graph/rte_graph_worker.c b/lib/graph/rte_graph_worker.c new file mode 100644 index 0000000000..692ee1b0d2 --- /dev/null +++ b/lib/graph/rte_graph_worker.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#include "rte_graph_worker_common.h" + +RTE_DEFINE_PER_LCORE(enum rte_graph_worker_model, worker_model) = RTE_GRAPH_MODEL_DEFAULT; + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * Set the graph worker model + * + * @note This function does not perform any locking, and is only safe to call + * before graph running. + * + * @param name + * Name of the graph worker model. + * + * @return + * 0 on success, -1 otherwise. + */ +inline int +rte_graph_worker_model_set(enum rte_graph_worker_model model) +{ + if (model >= RTE_GRAPH_MODEL_LIST_END) + goto fail; + + RTE_PER_LCORE(worker_model) = model; + return 0; + +fail: + RTE_PER_LCORE(worker_model) = RTE_GRAPH_MODEL_DEFAULT; + return -1; +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * Get the graph worker model + * + * @param name + * Name of the graph worker model. + * + * @return + * Graph worker model on success. + */ +inline +enum rte_graph_worker_model +rte_graph_worker_model_get(void) +{ + return RTE_PER_LCORE(worker_model); +} diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 41428974db..64d777bd5f 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -95,6 +95,14 @@ struct rte_node { struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */ } __rte_cache_aligned; +/** Graph worker models */ +enum rte_graph_worker_model { + RTE_GRAPH_MODEL_DEFAULT, + RTE_GRAPH_MODEL_RTC = RTE_GRAPH_MODEL_DEFAULT, + RTE_GRAPH_MODEL_MCORE_DISPATCH, + RTE_GRAPH_MODEL_LIST_END +}; + /** * @internal * @@ -490,6 +498,14 @@ rte_node_next_stream_move(struct rte_graph *graph, struct rte_node *src, } } +__rte_experimental +enum rte_graph_worker_model +rte_graph_worker_model_get(void); + +__rte_experimental +int +rte_graph_worker_model_set(enum rte_graph_worker_model model); + #ifdef __cplusplus } #endif diff --git a/lib/graph/version.map b/lib/graph/version.map index 13b838752d..eea73ec9ca 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -43,5 +43,8 @@ EXPERIMENTAL { rte_node_next_stream_put; rte_node_next_stream_move; + rte_graph_worker_model_set; + rte_graph_worker_model_get; + local: *; }; From patchwork Fri Mar 24 02:16:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125489 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 1C3224281E; Fri, 24 Mar 2023 04:17:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 928C742C76; Fri, 24 Mar 2023 04:16:45 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id EFAB5406B8 for ; Fri, 24 Mar 2023 04:16:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627802; x=1711163802; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FktimrAftgdUvTqSuKu1EH+pk6wkvDCyjMuWxES05ng=; b=OhE3L0jCsP8LWE+qZsw8ohJ/Pnwk93R1EcsO2w6Du8fRSBvrhfjwPCZu /ZR2wovM9nX4eO/vvEXsG8Key8nYLzdaFquTm++TiaggNoAuKzxQLFdMk OAH7BQzYea5TOA2gviVeK4vLS9pEL1Tc7lzrt/Wt8UYbsR7LdV0vvqw9/ x1n148NDjLseF/z5ZfqQI2RUu45gblvRkBv2KKtcoxYyZlmWCqP8vw8oU /WEYqLT3vP9TkKU2KXYmlWlA702Sgi9FTMn9wpt+VejoRvrOBvumlFEJw EoIKUIYIb8T7s9hRZQS1MpRLDiR5HTNMXD+yu2M2DQlONc0rR58b/eYu3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266431" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266431" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998526" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998526" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:39 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 05/15] graph: introduce graph node core affinity API Date: Fri, 24 Mar 2023 11:16:12 +0900 Message-Id: <20230324021622.1369006-6-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Add lcore_id for node to hold affinity core id and impl rte_graph_model_dispatch_lcore_affinity_set to set node affinity with specific lcore. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph_private.h | 1 + lib/graph/meson.build | 1 + lib/graph/node.c | 1 + lib/graph/rte_graph_model_dispatch.c | 31 ++++++++++++++++++++ lib/graph/rte_graph_model_dispatch.h | 43 ++++++++++++++++++++++++++++ lib/graph/version.map | 2 ++ 6 files changed, 79 insertions(+) create mode 100644 lib/graph/rte_graph_model_dispatch.c create mode 100644 lib/graph/rte_graph_model_dispatch.h diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index 7d1b30b8ac..409eed3284 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -50,6 +50,7 @@ struct node { STAILQ_ENTRY(node) next; /**< Next node in the list. */ char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */ uint64_t flags; /**< Node configuration flag. */ + unsigned int lcore_id; /**< Node runs on the Lcore ID */ rte_node_process_t process; /**< Node process function. */ rte_node_init_t init; /**< Node init function. */ rte_node_fini_t fini; /**< Node fini function. */ diff --git a/lib/graph/meson.build b/lib/graph/meson.build index 9fab8243da..c729d984b6 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -16,6 +16,7 @@ sources = files( 'graph_populate.c', 'graph_pcap.c', 'rte_graph_worker.c', + 'rte_graph_model_dispatch.c', ) headers = files('rte_graph.h', 'rte_graph_worker.h') diff --git a/lib/graph/node.c b/lib/graph/node.c index 149414dcd9..339b4a0da5 100644 --- a/lib/graph/node.c +++ b/lib/graph/node.c @@ -100,6 +100,7 @@ __rte_node_register(const struct rte_node_register *reg) goto free; } + node->lcore_id = RTE_MAX_LCORE; node->id = node_id++; /* Add the node at tail */ diff --git a/lib/graph/rte_graph_model_dispatch.c b/lib/graph/rte_graph_model_dispatch.c new file mode 100644 index 0000000000..4a2f99496d --- /dev/null +++ b/lib/graph/rte_graph_model_dispatch.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#include "graph_private.h" +#include "rte_graph_model_dispatch.h" + +int +rte_graph_model_dispatch_lcore_affinity_set(const char *name, unsigned int lcore_id) +{ + struct node *node; + int ret = -EINVAL; + + if (lcore_id >= RTE_MAX_LCORE) + return ret; + + graph_spinlock_lock(); + + STAILQ_FOREACH(node, node_list_head_get(), next) { + if (strncmp(node->name, name, RTE_NODE_NAMESIZE) == 0) { + node->lcore_id = lcore_id; + ret = 0; + break; + } + } + + graph_spinlock_unlock(); + + return ret; +} + diff --git a/lib/graph/rte_graph_model_dispatch.h b/lib/graph/rte_graph_model_dispatch.h new file mode 100644 index 0000000000..179624e972 --- /dev/null +++ b/lib/graph/rte_graph_model_dispatch.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Intel Corporation + */ + +#ifndef _RTE_GRAPH_MODEL_DISPATCH_H_ +#define _RTE_GRAPH_MODEL_DISPATCH_H_ + +/** + * @file rte_graph_model_dispatch.h + * + * @warning + * @b EXPERIMENTAL: + * All functions in this file may be changed or removed without prior notice. + * + * This API allows to set core affinity with the node. + */ +#include "rte_graph_worker_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Set lcore affinity with the node. + * + * @param name + * Valid node name. In the case of the cloned node, the name will be + * "parent node name" + "-" + name. + * @param lcore_id + * The lcore ID value. + * + * @return + * 0 on success, error otherwise. + */ +__rte_experimental +int rte_graph_model_dispatch_lcore_affinity_set(const char *name, + unsigned int lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_GRAPH_MODEL_DISPATCH_H_ */ diff --git a/lib/graph/version.map b/lib/graph/version.map index eea73ec9ca..1f090be74e 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -46,5 +46,7 @@ EXPERIMENTAL { rte_graph_worker_model_set; rte_graph_worker_model_get; + rte_graph_model_dispatch_lcore_affinity_set; + local: *; }; From patchwork Fri Mar 24 02:16:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125490 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 6B85D4281E; Fri, 24 Mar 2023 04:17:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B061542D2D; Fri, 24 Mar 2023 04:16:46 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 2FE9C42C76 for ; Fri, 24 Mar 2023 04:16:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627804; x=1711163804; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KvffPVut01BMQ6onAjS4VEulxb5OrYeG76XzuTei3Fs=; b=CecHSr/1LHrAZsy0egzGBYh3BZ3jXlZUAUlXyDx0jSCE5D2DjPtkEJvB AQjna3cllKLXoKpXxLgJKURXdfuoijh+1OlsJTJOjgDTrgD8GTMzStCV2 p/0uv8cK9EZ2NAPXpTi4IUKdX6vlQP8uCT5EMYBuSWTDOou9amTVWkvtj gNjZybj5WFPY5T3STQxLzlEV9zyFYy1+3kQRHEbJrGOVnJYQbHhx1Oibb KUpnYh4nQ/Go/eM/tuNHohhGeX3ZRD3Hyvn4mRJv2tcdZWz5w9z/b5PDO zeHNKYM5GmWRT/KXhZ5lWCfKdXHKeI+A51CwX6gAjH50Ky6Mselo61CgA g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266434" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266434" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998529" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998529" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:41 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 06/15] graph: introduce graph bind unbind API Date: Fri, 24 Mar 2023 11:16:13 +0900 Message-Id: <20230324021622.1369006-7-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Add lcore_id for graph to hold affinity core id where graph would run on. Add bind/unbind API to set/unset graph affinity attribute. lcore_id will be set as MAX by default, it means not enable this attribute. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph.c | 59 +++++++++++++++++++++++++++++++++++++++ lib/graph/graph_private.h | 2 ++ lib/graph/rte_graph.h | 22 +++++++++++++++ lib/graph/version.map | 2 ++ 4 files changed, 85 insertions(+) diff --git a/lib/graph/graph.c b/lib/graph/graph.c index a839a2803b..b39a99aac6 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -254,6 +254,64 @@ graph_mem_fixup_secondary(struct rte_graph *graph) return graph_mem_fixup_node_ctx(graph); } +static __rte_always_inline bool +graph_src_node_avail(struct graph *graph) +{ + struct graph_node *graph_node; + + STAILQ_FOREACH(graph_node, &graph->node_list, next) + if ((graph_node->node->flags & RTE_NODE_SOURCE_F) && + (graph_node->node->lcore_id == RTE_MAX_LCORE || + graph->lcore_id == graph_node->node->lcore_id)) + return true; + + return false; +} + +int +rte_graph_model_dispatch_core_bind(rte_graph_t id, int lcore) +{ + struct graph *graph; + + GRAPH_ID_CHECK(id); + if (!rte_lcore_is_enabled(lcore)) + SET_ERR_JMP(ENOLINK, fail, + "lcore %d not enabled\n", + lcore); + + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == id) + break; + + graph->lcore_id = lcore; + graph->socket = rte_lcore_to_socket_id(lcore); + + /* check the availability of source node */ + if (!graph_src_node_avail(graph)) + graph->graph->head = 0; + + return 0; + +fail: + return -rte_errno; +} + +void +rte_graph_model_dispatch_core_unbind(rte_graph_t id) +{ + struct graph *graph; + + GRAPH_ID_CHECK(id); + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == id) + break; + + graph->lcore_id = RTE_MAX_LCORE; + +fail: + return; +} + struct rte_graph * rte_graph_lookup(const char *name) { @@ -340,6 +398,7 @@ rte_graph_create(const char *name, struct rte_graph_param *prm) graph->src_node_count = src_node_count; graph->node_count = graph_nodes_count(graph); graph->id = graph_id; + graph->lcore_id = RTE_MAX_LCORE; graph->num_pkt_to_capture = prm->num_pkt_to_capture; if (prm->pcap_filename) rte_strscpy(graph->pcap_filename, prm->pcap_filename, RTE_GRAPH_PCAP_FILE_SZ); diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index 409eed3284..ad1d058945 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -98,6 +98,8 @@ struct graph { /**< Circular buffer mask for wrap around. */ rte_graph_t id; /**< Graph identifier. */ + unsigned int lcore_id; + /**< Lcore identifier where the graph prefer to run on. */ size_t mem_sz; /**< Memory size of the graph. */ int socket; diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index c9a77297fc..c523809d1f 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -285,6 +285,28 @@ char *rte_graph_id_to_name(rte_graph_t id); __rte_experimental int rte_graph_export(const char *name, FILE *f); +/** + * Bind graph with specific lcore + * + * @param id + * Graph id to get the pointer of graph object + * @param lcore + * The lcore where the graph will run on + * @return + * 0 on success, error otherwise. + */ +__rte_experimental +int rte_graph_model_dispatch_core_bind(rte_graph_t id, int lcore); + +/** + * Unbind graph with lcore + * + * @param id + * Graph id to get the pointer of graph object + */ +__rte_experimental +void rte_graph_model_dispatch_core_unbind(rte_graph_t id); + /** * Get graph object from its name. * diff --git a/lib/graph/version.map b/lib/graph/version.map index 1f090be74e..7de6f08f59 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -18,6 +18,8 @@ EXPERIMENTAL { rte_graph_node_get_by_name; rte_graph_obj_dump; rte_graph_walk; + rte_graph_model_dispatch_core_bind; + rte_graph_model_dispatch_core_unbind; rte_graph_cluster_stats_create; rte_graph_cluster_stats_destroy; From patchwork Fri Mar 24 02:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125491 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 A26AB4281E; Fri, 24 Mar 2023 04:17:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0E0542D0D; Fri, 24 Mar 2023 04:16:47 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 2C73442D17 for ; Fri, 24 Mar 2023 04:16:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627806; x=1711163806; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zTJpYeQM6U0NN7ViwmTuVa7KdfrvCst8+3FJ3am20IA=; b=nTn3+1tro0NhpJlRiDKiXjUih3XJJhOxnG5Oh/Ir915/zqA6EEnqDTI0 ZoZrR89ugKEdzahT/JKImXg3BsvYA/tJGG9OmOjzvgcnjhtvaaPdgKc5D 6VnFpbcLwgUB9aw36fm6T1COTlx/SJD0OArNi2mMf+i5RPpjaFQVfYRZN ePSXir3y5sXoTkL7AOLcXqig75/837dH+jfFDxAOIQj9aihObzp6Id1YC i6tbhiK1Gk2gFORd8WybcQGCL+tk16Q7LE3xUWoGRAMmUXfSNfvFJnDmm 3X/UlGKweF5ZAKztxIaGELY3g7i9SAvgHxvuW5J5Lywgag3m15K4VTqgX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266438" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266438" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998535" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998535" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:43 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 07/15] graph: introduce graph clone API for other worker core Date: Fri, 24 Mar 2023 11:16:14 +0900 Message-Id: <20230324021622.1369006-8-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 This patch adds graph API for supporting to clone the graph object for a specified worker core. The new graph will also clone all nodes. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph.c | 110 ++++++++++++++++++++++++++++++++++++++ lib/graph/graph_private.h | 2 + lib/graph/rte_graph.h | 20 +++++++ lib/graph/version.map | 1 + 4 files changed, 133 insertions(+) diff --git a/lib/graph/graph.c b/lib/graph/graph.c index b39a99aac6..90eaad0378 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -398,6 +398,7 @@ rte_graph_create(const char *name, struct rte_graph_param *prm) graph->src_node_count = src_node_count; graph->node_count = graph_nodes_count(graph); graph->id = graph_id; + graph->parent_id = RTE_GRAPH_ID_INVALID; graph->lcore_id = RTE_MAX_LCORE; graph->num_pkt_to_capture = prm->num_pkt_to_capture; if (prm->pcap_filename) @@ -462,6 +463,115 @@ rte_graph_destroy(rte_graph_t id) return rc; } +static int +clone_name(struct graph *graph, struct graph *parent_graph, const char *name) +{ + ssize_t sz, rc; + +#define SZ RTE_GRAPH_NAMESIZE + rc = rte_strscpy(graph->name, parent_graph->name, SZ); + if (rc < 0) + goto fail; + sz = rc; + rc = rte_strscpy(graph->name + sz, "-", RTE_MAX((int16_t)(SZ - sz), 0)); + if (rc < 0) + goto fail; + sz += rc; + sz = rte_strscpy(graph->name + sz, name, RTE_MAX((int16_t)(SZ - sz), 0)); + if (sz < 0) + goto fail; + + return 0; +fail: + rte_errno = E2BIG; + return -rte_errno; +} + +static rte_graph_t +graph_clone(struct graph *parent_graph, const char *name) +{ + struct graph_node *graph_node; + struct graph *graph; + + graph_spinlock_lock(); + + /* Don't allow to clone a node from a cloned graph */ + if (parent_graph->parent_id != RTE_GRAPH_ID_INVALID) + SET_ERR_JMP(EEXIST, fail, "A cloned graph is not allowed to be cloned"); + + /* Create graph object */ + graph = calloc(1, sizeof(*graph)); + if (graph == NULL) + SET_ERR_JMP(ENOMEM, fail, "Failed to calloc cloned graph object"); + + /* Naming ceremony of the new graph. name is node->name + "-" + name */ + if (clone_name(graph, parent_graph, name)) + goto free; + + /* Check for existence of duplicate graph */ + if (rte_graph_from_name(graph->name) != RTE_GRAPH_ID_INVALID) + SET_ERR_JMP(EEXIST, free, "Found duplicate graph %s", + graph->name); + + /* Clone nodes from parent graph firstly */ + STAILQ_INIT(&graph->node_list); + STAILQ_FOREACH(graph_node, &parent_graph->node_list, next) { + if (graph_node_add(graph, graph_node->node)) + goto graph_cleanup; + } + + /* Just update adjacency list of all nodes in the graph */ + if (graph_adjacency_list_update(graph)) + goto graph_cleanup; + + /* Initialize the graph object */ + graph->src_node_count = parent_graph->src_node_count; + graph->node_count = parent_graph->node_count; + graph->parent_id = parent_graph->id; + graph->lcore_id = parent_graph->lcore_id; + graph->socket = parent_graph->socket; + graph->id = graph_id; + + /* Allocate the Graph fast path memory and populate the data */ + if (graph_fp_mem_create(graph)) + goto graph_cleanup; + + /* Call init() of the all the nodes in the graph */ + if (graph_node_init(graph)) + goto graph_mem_destroy; + + /* All good, Lets add the graph to the list */ + graph_id++; + STAILQ_INSERT_TAIL(&graph_list, graph, next); + + graph_spinlock_unlock(); + return graph->id; + +graph_mem_destroy: + graph_fp_mem_destroy(graph); +graph_cleanup: + graph_cleanup(graph); +free: + free(graph); +fail: + graph_spinlock_unlock(); + return RTE_GRAPH_ID_INVALID; +} + +rte_graph_t +rte_graph_clone(rte_graph_t id, const char *name) +{ + struct graph *graph; + + GRAPH_ID_CHECK(id); + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == id) + return graph_clone(graph, name); + +fail: + return RTE_GRAPH_ID_INVALID; +} + rte_graph_t rte_graph_from_name(const char *name) { diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index ad1d058945..d28a5af93e 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -98,6 +98,8 @@ struct graph { /**< Circular buffer mask for wrap around. */ rte_graph_t id; /**< Graph identifier. */ + rte_graph_t parent_id; + /**< Parent graph identifier. */ unsigned int lcore_id; /**< Lcore identifier where the graph prefer to run on. */ size_t mem_sz; diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index c523809d1f..2f86c17de7 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -247,6 +247,26 @@ rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm); __rte_experimental int rte_graph_destroy(rte_graph_t id); +/** + * Clone Graph. + * + * Clone a graph from static graph (graph created from rte_graph_create). And + * all cloned graphs attached to the parent graph MUST be destroyed together + * for fast schedule design limitation (stop ALL graph walk firstly). + * + * @param id + * Static graph id to clone from. + * @param name + * Name of the new graph. The library prepends the parent graph name to the + * user-specified name. The final graph name will be, + * "parent graph name" + "-" + name. + * + * @return + * Valid graph id on success, RTE_GRAPH_ID_INVALID otherwise. + */ +__rte_experimental +rte_graph_t rte_graph_clone(rte_graph_t id, const char *name); + /** * Get graph id from graph name. * diff --git a/lib/graph/version.map b/lib/graph/version.map index 7de6f08f59..aaa86f66ed 100644 --- a/lib/graph/version.map +++ b/lib/graph/version.map @@ -7,6 +7,7 @@ EXPERIMENTAL { rte_graph_create; rte_graph_destroy; + rte_graph_clone; rte_graph_dump; rte_graph_export; rte_graph_from_name; From patchwork Fri Mar 24 02:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125492 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 1D2244281E; Fri, 24 Mar 2023 04:17:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE81442D31; Fri, 24 Mar 2023 04:16:50 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 552C442D33 for ; Fri, 24 Mar 2023 04:16:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627808; x=1711163808; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u83eQdhAAwpt6fQUio06EZD7Rf0G1j7njWoHixcvVGQ=; b=Uhn/FKh8BsJlKiXCUhPNPO+lJNw5269F4cfveelbAquj/ottPDcQXDsD FXOvMqW9yMa6HnOsUG/osKQZM1ILzfEKi6DkHaw3Uu163VM86HE9u9+Jc cNR9rnbLGl2kWLlprg1+VjxNn2K/+y0UQSJMjZDwCOY5TuYraXDtY4RZs TQItw6c/T4FQiPckj1rblhAyn0cyOCy2CzarRqbqULYGEs0H7kLBkygsl xIZd+ijf9LoDsMS5M0RhqbXVwrY/1JiVTwi/QyOicZGDwyXzx1tbQH3I6 CuEahkmvx8Fdlu/SrxYVSerKZPecFmTu9e1efH2r275RKi3CygS3gWRTj w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266453" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266453" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998553" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998553" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:45 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 08/15] graph: add struct for stream moving between cores Date: Fri, 24 Mar 2023 11:16:15 +0900 Message-Id: <20230324021622.1369006-9-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Add graph_sched_wq_node to hold graph scheduling workqueue node. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph.c | 1 + lib/graph/graph_populate.c | 1 + lib/graph/graph_private.h | 12 ++++++++++++ lib/graph/rte_graph_worker_common.h | 21 +++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/lib/graph/graph.c b/lib/graph/graph.c index 90eaad0378..dd3d69dbf7 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -284,6 +284,7 @@ rte_graph_model_dispatch_core_bind(rte_graph_t id, int lcore) break; graph->lcore_id = lcore; + graph->graph->lcore_id = graph->lcore_id; graph->socket = rte_lcore_to_socket_id(lcore); /* check the availability of source node */ diff --git a/lib/graph/graph_populate.c b/lib/graph/graph_populate.c index 2c0844ce92..7dcf1420c1 100644 --- a/lib/graph/graph_populate.c +++ b/lib/graph/graph_populate.c @@ -89,6 +89,7 @@ graph_nodes_populate(struct graph *_graph) } node->id = graph_node->node->id; node->parent_id = pid; + node->lcore_id = graph_node->node->lcore_id; nb_edges = graph_node->node->nb_edges; node->nb_edges = nb_edges; off += sizeof(struct rte_node); diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index d28a5af93e..b66b18ebbc 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -60,6 +60,18 @@ struct node { char next_nodes[][RTE_NODE_NAMESIZE]; /**< Names of next nodes. */ }; +/** + * @internal + * + * Structure that holds the graph scheduling workqueue node stream. + * Used for mcore dispatch model. + */ +struct graph_sched_wq_node { + rte_graph_off_t node_off; + uint16_t nb_objs; + void *objs[RTE_GRAPH_BURST_SIZE]; +} __rte_cache_aligned; + /** * @internal * diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 64d777bd5f..70cfde7015 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -29,6 +29,13 @@ extern "C" { #endif +/** + * @internal + * + * Singly-linked list head for graph schedule run-queue. + */ +SLIST_HEAD(rte_graph_rq_head, rte_graph); + /** * @internal * @@ -40,6 +47,15 @@ struct rte_graph { uint32_t cir_mask; /**< Circular buffer wrap around mask. */ rte_node_t nb_nodes; /**< Number of nodes in the graph. */ rte_graph_off_t *cir_start; /**< Pointer to circular buffer. */ + /* Graph schedule */ + struct rte_graph_rq_head *rq __rte_cache_aligned; /* The run-queue */ + struct rte_graph_rq_head rq_head; /* The head for run-queue list */ + + SLIST_ENTRY(rte_graph) rq_next; /* The next for run-queue list */ + unsigned int lcore_id; /**< The graph running Lcore. */ + struct rte_ring *wq; /**< The work-queue for pending streams. */ + struct rte_mempool *mp; /**< The mempool for scheduling streams. */ + /* Graph schedule area */ rte_graph_off_t nodes_start; /**< Offset at which node memory starts. */ rte_graph_t id; /**< Graph identifier. */ int socket; /**< Socket ID where memory is allocated. */ @@ -73,6 +89,11 @@ struct rte_node { /** Original process function when pcap is enabled. */ rte_node_process_t original_process; + RTE_STD_C11 + union { + /* Fast schedule area for mcore dispatch model */ + unsigned int lcore_id; /**< Node running lcore. */ + }; /* Fast path area */ #define RTE_NODE_CTX_SZ 16 uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */ From patchwork Fri Mar 24 02:16:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125493 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 36ADA4281E; Fri, 24 Mar 2023 04:17:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2046B42D3A; Fri, 24 Mar 2023 04:16:53 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 5373842B7E for ; Fri, 24 Mar 2023 04:16:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627810; x=1711163810; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DI1FtHJtzNilg/DkhVbgOktkZCnYy21ewLN5KHLmOcI=; b=M5ua8t+6+VMS3z7RQYMbeOtaxsfEi4Jr6hqcBLFubCCUBHAN1vG2EynF oUCtdGQ6hblO1UvVpN1UefEsYQEjFuPReamO7BML6WYHo1j0dub4Z+4Z+ 4uYy/+QXen8afUe38CvREgq5gFNt8mr6WFDJwTYStr7JmURtVOlxXAMao 4oDOfV2j0mml0y8kNB/LO3VmS2sGgnMoQ3s23aoomJHe/Zk77EynNo4og ZcQa8v/1UEFcRM935cAdwffemrljdHqTrnsojkJwsnZQcXMUUFMnqAtK7 7VoptqjBdF0aVrNzbdASkY2fnI3w3rnDnSAb/Ws0dCSJULGvEd/xGvd7w g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266464" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266464" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998564" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998564" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:47 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 09/15] graph: introduce stream moving cross cores Date: Fri, 24 Mar 2023 11:16:16 +0900 Message-Id: <20230324021622.1369006-10-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 This patch introduces key functions to allow a worker thread to enable enqueue and move streams of objects to the next nodes over different cores. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph_private.h | 27 +++++ lib/graph/meson.build | 2 +- lib/graph/rte_graph_model_dispatch.c | 145 +++++++++++++++++++++++++++ lib/graph/rte_graph_model_dispatch.h | 35 +++++++ 4 files changed, 208 insertions(+), 1 deletion(-) diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index b66b18ebbc..e1a2a4bfd8 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -366,4 +366,31 @@ void graph_dump(FILE *f, struct graph *g); */ void node_dump(FILE *f, struct node *n); +/** + * @internal + * + * Create the graph schedule work queue. And all cloned graphs attached to the + * parent graph MUST be destroyed together for fast schedule design limitation. + * + * @param _graph + * The graph object + * @param _parent_graph + * The parent graph object which holds the run-queue head. + * + * @return + * - 0: Success. + * - <0: Graph schedule work queue related error. + */ +int graph_sched_wq_create(struct graph *_graph, struct graph *_parent_graph); + +/** + * @internal + * + * Destroy the graph schedule work queue. + * + * @param _graph + * The graph object + */ +void graph_sched_wq_destroy(struct graph *_graph); + #endif /* _RTE_GRAPH_PRIVATE_H_ */ diff --git a/lib/graph/meson.build b/lib/graph/meson.build index c729d984b6..e21affa280 100644 --- a/lib/graph/meson.build +++ b/lib/graph/meson.build @@ -20,4 +20,4 @@ sources = files( ) headers = files('rte_graph.h', 'rte_graph_worker.h') -deps += ['eal', 'pcapng'] +deps += ['eal', 'pcapng', 'mempool', 'ring'] diff --git a/lib/graph/rte_graph_model_dispatch.c b/lib/graph/rte_graph_model_dispatch.c index 4a2f99496d..b46dd156ac 100644 --- a/lib/graph/rte_graph_model_dispatch.c +++ b/lib/graph/rte_graph_model_dispatch.c @@ -5,6 +5,151 @@ #include "graph_private.h" #include "rte_graph_model_dispatch.h" +int +graph_sched_wq_create(struct graph *_graph, struct graph *_parent_graph) +{ + struct rte_graph *parent_graph = _parent_graph->graph; + struct rte_graph *graph = _graph->graph; + unsigned int wq_size; + + wq_size = GRAPH_SCHED_WQ_SIZE(graph->nb_nodes); + wq_size = rte_align32pow2(wq_size + 1); + + graph->wq = rte_ring_create(graph->name, wq_size, graph->socket, + RING_F_SC_DEQ); + if (graph->wq == NULL) + SET_ERR_JMP(EIO, fail, "Failed to allocate graph WQ"); + + graph->mp = rte_mempool_create(graph->name, wq_size, + sizeof(struct graph_sched_wq_node), + 0, 0, NULL, NULL, NULL, NULL, + graph->socket, MEMPOOL_F_SP_PUT); + if (graph->mp == NULL) + SET_ERR_JMP(EIO, fail_mp, + "Failed to allocate graph WQ schedule entry"); + + graph->lcore_id = _graph->lcore_id; + + if (parent_graph->rq == NULL) { + parent_graph->rq = &parent_graph->rq_head; + SLIST_INIT(parent_graph->rq); + } + + graph->rq = parent_graph->rq; + SLIST_INSERT_HEAD(graph->rq, graph, rq_next); + + return 0; + +fail_mp: + rte_ring_free(graph->wq); + graph->wq = NULL; +fail: + return -rte_errno; +} + +void +graph_sched_wq_destroy(struct graph *_graph) +{ + struct rte_graph *graph = _graph->graph; + + if (graph == NULL) + return; + + rte_ring_free(graph->wq); + graph->wq = NULL; + + rte_mempool_free(graph->mp); + graph->mp = NULL; +} + +static __rte_always_inline bool +__graph_sched_node_enqueue(struct rte_node *node, struct rte_graph *graph) +{ + struct graph_sched_wq_node *wq_node; + uint16_t off = 0; + uint16_t size; + +submit_again: + if (rte_mempool_get(graph->mp, (void **)&wq_node) < 0) + goto fallback; + + size = RTE_MIN(node->idx, RTE_DIM(wq_node->objs)); + wq_node->node_off = node->off; + wq_node->nb_objs = size; + rte_memcpy(wq_node->objs, &node->objs[off], size * sizeof(void *)); + + while (rte_ring_mp_enqueue_bulk_elem(graph->wq, (void *)&wq_node, + sizeof(wq_node), 1, NULL) == 0) + rte_pause(); + + off += size; + node->idx -= size; + if (node->idx > 0) + goto submit_again; + + return true; + +fallback: + if (off != 0) + memmove(&node->objs[0], &node->objs[off], + node->idx * sizeof(void *)); + + return false; +} + +bool __rte_noinline +__rte_graph_sched_node_enqueue(struct rte_node *node, + struct rte_graph_rq_head *rq) +{ + const unsigned int lcore_id = node->lcore_id; + struct rte_graph *graph; + + SLIST_FOREACH(graph, rq, rq_next) + if (graph->lcore_id == lcore_id) + break; + + return graph != NULL ? __graph_sched_node_enqueue(node, graph) : false; +} + +void __rte_noinline +__rte_graph_sched_wq_process(struct rte_graph *graph) +{ + struct graph_sched_wq_node *wq_node; + struct rte_mempool *mp = graph->mp; + struct rte_ring *wq = graph->wq; + uint16_t idx, free_space; + struct rte_node *node; + unsigned int i, n; + struct graph_sched_wq_node *wq_nodes[32]; + + n = rte_ring_sc_dequeue_burst_elem(wq, wq_nodes, sizeof(wq_nodes[0]), + RTE_DIM(wq_nodes), NULL); + if (n == 0) + return; + + for (i = 0; i < n; i++) { + wq_node = wq_nodes[i]; + node = RTE_PTR_ADD(graph, wq_node->node_off); + RTE_ASSERT(node->fence == RTE_GRAPH_FENCE); + idx = node->idx; + free_space = node->size - idx; + + if (unlikely(free_space < wq_node->nb_objs)) + __rte_node_stream_alloc_size(graph, node, node->size + wq_node->nb_objs); + + memmove(&node->objs[idx], wq_node->objs, wq_node->nb_objs * sizeof(void *)); + memset(wq_node->objs, 0, wq_node->nb_objs * sizeof(void *)); + node->idx = idx + wq_node->nb_objs; + + __rte_node_process(graph, node); + + wq_node->nb_objs = 0; + node->idx = 0; + } + + rte_mempool_put_bulk(mp, (void **)wq_nodes, n); +} + int rte_graph_model_dispatch_lcore_affinity_set(const char *name, unsigned int lcore_id) { diff --git a/lib/graph/rte_graph_model_dispatch.h b/lib/graph/rte_graph_model_dispatch.h index 179624e972..7cbdf2fdcf 100644 --- a/lib/graph/rte_graph_model_dispatch.h +++ b/lib/graph/rte_graph_model_dispatch.h @@ -14,12 +14,47 @@ * * This API allows to set core affinity with the node. */ +#include +#include +#include +#include + #include "rte_graph_worker_common.h" #ifdef __cplusplus extern "C" { #endif +#define GRAPH_SCHED_WQ_SIZE_MULTIPLIER 8 +#define GRAPH_SCHED_WQ_SIZE(nb_nodes) \ + ((typeof(nb_nodes))((nb_nodes) * GRAPH_SCHED_WQ_SIZE_MULTIPLIER)) + +/** + * @internal + * + * Schedule the node to the right graph's work queue. + * + * @param node + * Pointer to the scheduled node object. + * @param rq + * Pointer to the scheduled run-queue for all graphs. + * + * @return + * True on success, false otherwise. + */ +bool __rte_graph_sched_node_enqueue(struct rte_node *node, + struct rte_graph_rq_head *rq); + +/** + * @internal + * + * Process all nodes (streams) in the graph's work queue. + * + * @param graph + * Pointer to the graph object. + */ +void __rte_noinline __rte_graph_sched_wq_process(struct rte_graph *graph); + /** * Set lcore affinity with the node. * From patchwork Fri Mar 24 02:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125494 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 411754281E; Fri, 24 Mar 2023 04:17:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5C5C42D35; Fri, 24 Mar 2023 04:16:54 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 1998342D39 for ; Fri, 24 Mar 2023 04:16:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627812; x=1711163812; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0LebO7SGoi0DYaksMvOP4ILIt7ts9I6sVp4INv89Ees=; b=c+YmIY3hSJ3RL+107KugnvCXN+5DS55KqDrF+MQyKIcOKdKT/iEEdqv6 /RcTScOrH2exxEFVjpy2EImhaXyjJzRcBE5omjzVceLadcPaVkojtaq0X sDNmiyaaSRQTCgSHgg1d4ilRSl2R1z+CgyQ86DCe/ngFkwTLPY8HIfTcN VVcr11FGfrYDdpUB+R1bgDy9iVCFGttnZXAn8eUwtgKhfihEmsWv1TQvE yy5FaSAVOdBvOxHY7RjfBi7zZqKFUvLihYWMoGfHXJAXw2c1anzv4LtAm GMRRD9zggJzafzdPztOJOhnufKmEXbSS1qTPMrvW507cQb+3uNS8MJKCN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266468" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266468" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998567" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998567" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:49 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 10/15] graph: enable create and destroy graph scheduling workqueue Date: Fri, 24 Mar 2023 11:16:17 +0900 Message-Id: <20230324021622.1369006-11-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 This patch enables to create and destroy scheduling workqueue into common graph operations. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/graph/graph.c b/lib/graph/graph.c index dd3d69dbf7..1f1ee9b622 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -443,6 +443,10 @@ rte_graph_destroy(rte_graph_t id) while (graph != NULL) { tmp = STAILQ_NEXT(graph, next); if (graph->id == id) { + /* Destroy the schedule work queue if has */ + if (rte_graph_worker_model_get() == RTE_GRAPH_MODEL_MCORE_DISPATCH) + graph_sched_wq_destroy(graph); + /* Call fini() of the all the nodes in the graph */ graph_node_fini(graph); /* Destroy graph fast path memory */ @@ -537,6 +541,11 @@ graph_clone(struct graph *parent_graph, const char *name) if (graph_fp_mem_create(graph)) goto graph_cleanup; + /* Create the graph schedule work queue */ + if (rte_graph_worker_model_get() == RTE_GRAPH_MODEL_MCORE_DISPATCH && + graph_sched_wq_create(graph, parent_graph)) + goto graph_mem_destroy; + /* Call init() of the all the nodes in the graph */ if (graph_node_init(graph)) goto graph_mem_destroy; From patchwork Fri Mar 24 02:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125495 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 D1C3D4281E; Fri, 24 Mar 2023 04:17:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD94D42D3B; Fri, 24 Mar 2023 04:16:56 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 231DE42D35 for ; Fri, 24 Mar 2023 04:16:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627814; x=1711163814; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LAQ4+NhVCor84gMJvrQAQ1UH6F80izzw0qM21Lb08B8=; b=EPstcU6E+33Pnvnk7+jVtWUa/S0a5r9ImZT8nitnOWFCIm3s+xFlHkyQ yb/qk3P6+jeEtjJ3LhxGzw9Gm+ZDzqme59gvGqQ9FL5+d3q0wABvmjMth oDkVEUhyroWV9ybdnn3fraPlhSK8/RVKd3q5BZPSmqNa/dhnAx9LsIyQR OsbXU95MDtDbG8abO371zqC5PkZ8WxiszuKPEg6Kg1y5fzC+uKj77uDOY juTvBX1fDZNjMfK2ULPUtRCcN2woQDd8+60HoQ780/jDpx2S2IFxJwdjh uYSJMRYpApfON2VtlGK/oPx0vweOA/4f3qIeY3SZChUtQxkgbbIAzf2wI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266471" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266471" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998571" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998571" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:51 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 11/15] graph: introduce graph walk by cross-core dispatch Date: Fri, 24 Mar 2023 11:16:18 +0900 Message-Id: <20230324021622.1369006-12-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 This patch introduces the task scheduler mechanism to enable dispatching tasks to another worker cores. Currently, there is only a local work queue for one graph to walk. We introduce a scheduler worker queue in each worker core for dispatching tasks. It will perform the walk on scheduler work queue first, then handle the local work queue. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/rte_graph_model_dispatch.h | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/graph/rte_graph_model_dispatch.h b/lib/graph/rte_graph_model_dispatch.h index 7cbdf2fdcf..764c4ecfd0 100644 --- a/lib/graph/rte_graph_model_dispatch.h +++ b/lib/graph/rte_graph_model_dispatch.h @@ -71,6 +71,48 @@ __rte_experimental int rte_graph_model_dispatch_lcore_affinity_set(const char *name, unsigned int lcore_id); +/** + * Perform graph walk on the circular buffer and invoke the process function + * of the nodes and collect the stats. + * + * @param graph + * Graph pointer returned from rte_graph_lookup function. + * + * @see rte_graph_lookup() + */ +__rte_experimental +static inline void +rte_graph_walk_mcore_dispatch(struct rte_graph *graph) +{ + const rte_graph_off_t *cir_start = graph->cir_start; + const rte_node_t mask = graph->cir_mask; + uint32_t head = graph->head; + struct rte_node *node; + + if (graph->wq != NULL) + __rte_graph_sched_wq_process(graph); + + while (likely(head != graph->tail)) { + node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]); + + /* skip the src nodes which not bind with current worker */ + if ((int32_t)head < 0 && node->lcore_id != graph->lcore_id) + continue; + + /* Schedule the node until all task/objs are done */ + if (node->lcore_id != RTE_MAX_LCORE && + graph->lcore_id != node->lcore_id && graph->rq != NULL && + __rte_graph_sched_node_enqueue(node, graph->rq)) + continue; + + __rte_node_process(graph, node); + + head = likely((int32_t)head > 0) ? head & mask : head; + } + + graph->tail = 0; +} + #ifdef __cplusplus } #endif From patchwork Fri Mar 24 02:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125496 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 74F394281E; Fri, 24 Mar 2023 04:17:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 168F442D47; Fri, 24 Mar 2023 04:16:58 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id CB98342D46 for ; Fri, 24 Mar 2023 04:16:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627816; x=1711163816; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uEYD7AaT6JY85ASk8lTux/2iq3TH/nB6Z++lQS3gzjs=; b=EzlU0ONcE9GmRZvLcDx+Ura9fA+4jN3Z0R7psRiN0RpwGCHJHWlO8rSt t9CyoRV4olvyUGWTs2KYhE75I5Ur42iakjqYsdpZD0oChSxSsmWrYjIoC Vb45MBCnlRo6X2R/Bdhb5j8A9fO0Qex8DfOBsLqrqq3mrYNidTyfrmT78 gvS/6m/L302UsBAHe7I0g09OrnBuWncaUUaJubEEkLGql41QxVT/gwGOj 8i/H4GoSeLg5mTUVWdGcXzN/D3X1vfIPZipHSLkJ0wkA/rcPFSWgHtNZP khYAdff+k4C7vSs+w+R3cAU35WoiPRUHmmckM86tSEC8JNFmBY/QLkku8 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266473" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266473" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998576" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998576" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:53 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 12/15] graph: enable graph multicore dispatch scheduler model Date: Fri, 24 Mar 2023 11:16:19 +0900 Message-Id: <20230324021622.1369006-13-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 This patch enables to chose new scheduler model. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/rte_graph_worker.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h index 7ea18ba80a..d608c7513e 100644 --- a/lib/graph/rte_graph_worker.h +++ b/lib/graph/rte_graph_worker.h @@ -10,6 +10,7 @@ extern "C" { #endif #include "rte_graph_model_rtc.h" +#include "rte_graph_model_dispatch.h" /** * Perform graph walk on the circular buffer and invoke the process function @@ -24,7 +25,13 @@ __rte_experimental static inline void rte_graph_walk(struct rte_graph *graph) { - rte_graph_walk_rtc(graph); + int model = rte_graph_worker_model_get(); + + if (model == RTE_GRAPH_MODEL_DEFAULT || + model == RTE_GRAPH_MODEL_RTC) + rte_graph_walk_rtc(graph); + else if (model == RTE_GRAPH_MODEL_MCORE_DISPATCH) + rte_graph_walk_mcore_dispatch(graph); } #ifdef __cplusplus From patchwork Fri Mar 24 02:16:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125497 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 6BAD94281E; Fri, 24 Mar 2023 04:17:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B5F742D4B; Fri, 24 Mar 2023 04:16:59 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 32DFE42D49 for ; Fri, 24 Mar 2023 04:16:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627818; x=1711163818; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NuEeAUD+JLi9xqHCFNINzTY2iM75dNJU4zeKvN705Q0=; b=QVrL5iqbr0FjWQnGi+XvnKcizi5RRtpR8gn/jL3TeeKP51cMfXZ3/0il xMFsT5TG3YwmTWcEMDgcsq1hIfnRCvJsFGPKIivrNEexz6rsYGkmaL0Yo YN+hxQ3voV14O2X7RAKowoDHT4+Vr+wUhcjgqVEJ7btnd2RoRQylIX11h HzPTAPX20OBV2hL0jcUPDpvg874O6bRZMIJAnhQd0co6vRpk6qFoHvrfc tWPLEaTGULmfxTEB/rp5S+m3r6FJph84XIjcrY4uxdA1hEh4Isd0//kMC ZSflqlOfbyxmJuNclx8dRqESE6EaQFK2UtGMFsDX5ANDrsVg5kKiE/Aiu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266480" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266480" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:16:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998585" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998585" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:55 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 13/15] graph: add stats for corss-core dispatching Date: Fri, 24 Mar 2023 11:16:20 +0900 Message-Id: <20230324021622.1369006-14-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Add stats for cross-core dispatching scheduler if stats collection is enabled. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- lib/graph/graph_debug.c | 6 +++ lib/graph/graph_stats.c | 74 +++++++++++++++++++++++++--- lib/graph/rte_graph.h | 2 + lib/graph/rte_graph_model_dispatch.c | 3 ++ lib/graph/rte_graph_worker_common.h | 2 + 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lib/graph/graph_debug.c b/lib/graph/graph_debug.c index b84412f5dd..7dcf07b080 100644 --- a/lib/graph/graph_debug.c +++ b/lib/graph/graph_debug.c @@ -74,6 +74,12 @@ rte_graph_obj_dump(FILE *f, struct rte_graph *g, bool all) fprintf(f, " size=%d\n", n->size); fprintf(f, " idx=%d\n", n->idx); fprintf(f, " total_objs=%" PRId64 "\n", n->total_objs); + if (rte_graph_worker_model_get() == RTE_GRAPH_MODEL_MCORE_DISPATCH) { + fprintf(f, " total_sched_objs=%" PRId64 "\n", + n->total_sched_objs); + fprintf(f, " total_sched_fail=%" PRId64 "\n", + n->total_sched_fail); + } fprintf(f, " total_calls=%" PRId64 "\n", n->total_calls); for (i = 0; i < n->nb_edges; i++) fprintf(f, " edge[%d] <%s>\n", i, diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index c0140ba922..aa22cc403c 100644 --- a/lib/graph/graph_stats.c +++ b/lib/graph/graph_stats.c @@ -40,13 +40,19 @@ struct rte_graph_cluster_stats { struct cluster_node clusters[]; } __rte_cache_aligned; +#define boarder_model_dispatch() \ + fprintf(f, "+-------------------------------+---------------+--------" \ + "-------+---------------+---------------+---------------+" \ + "---------------+---------------+-" \ + "----------+\n") + #define boarder() \ fprintf(f, "+-------------------------------+---------------+--------" \ "-------+---------------+---------------+---------------+-" \ "----------+\n") static inline void -print_banner(FILE *f) +print_banner_default(FILE *f) { boarder(); fprintf(f, "%-32s%-16s%-16s%-16s%-16s%-16s%-16s\n", "|Node", "|calls", @@ -55,6 +61,27 @@ print_banner(FILE *f) boarder(); } +static inline void +print_banner_dispatch(FILE *f) +{ + boarder_model_dispatch(); + fprintf(f, "%-32s%-16s%-16s%-16s%-16s%-16s%-16s%-16s%-16s\n", + "|Node", "|calls", + "|objs", "|sched objs", "|sched fail", + "|realloc_count", "|objs/call", "|objs/sec(10E6)", + "|cycles/call|"); + boarder_model_dispatch(); +} + +static inline void +print_banner(FILE *f) +{ + if (rte_graph_worker_model_get() == RTE_GRAPH_MODEL_MCORE_DISPATCH) + print_banner_dispatch(f); + else + print_banner_default(f); +} + static inline void print_node(FILE *f, const struct rte_graph_cluster_node_stats *stat) { @@ -76,11 +103,21 @@ print_node(FILE *f, const struct rte_graph_cluster_node_stats *stat) objs_per_sec = ts_per_hz ? (objs - prev_objs) / ts_per_hz : 0; objs_per_sec /= 1000000; - fprintf(f, - "|%-31s|%-15" PRIu64 "|%-15" PRIu64 "|%-15" PRIu64 - "|%-15.3f|%-15.6f|%-11.4f|\n", - stat->name, calls, objs, stat->realloc_count, objs_per_call, - objs_per_sec, cycles_per_call); + if (rte_graph_worker_model_get() == RTE_GRAPH_MODEL_MCORE_DISPATCH) { + fprintf(f, + "|%-31s|%-15" PRIu64 "|%-15" PRIu64 "|%-15" PRIu64 + "|%-15" PRIu64 "|%-15" PRIu64 + "|%-15.3f|%-15.6f|%-11.4f|\n", + stat->name, calls, objs, stat->sched_objs, + stat->sched_fail, stat->realloc_count, objs_per_call, + objs_per_sec, cycles_per_call); + } else { + fprintf(f, + "|%-31s|%-15" PRIu64 "|%-15" PRIu64 "|%-15" PRIu64 + "|%-15.3f|%-15.6f|%-11.4f|\n", + stat->name, calls, objs, stat->realloc_count, objs_per_call, + objs_per_sec, cycles_per_call); + } } static int @@ -88,13 +125,20 @@ graph_cluster_stats_cb(bool is_first, bool is_last, void *cookie, const struct rte_graph_cluster_node_stats *stat) { FILE *f = cookie; + int model; + + model = rte_graph_worker_model_get(); if (unlikely(is_first)) print_banner(f); if (stat->objs) print_node(f, stat); - if (unlikely(is_last)) - boarder(); + if (unlikely(is_last)) { + if (model == RTE_GRAPH_MODEL_MCORE_DISPATCH) + boarder_model_dispatch(); + else + boarder(); + } return 0; }; @@ -332,13 +376,21 @@ static inline void cluster_node_arregate_stats(struct cluster_node *cluster) { uint64_t calls = 0, cycles = 0, objs = 0, realloc_count = 0; + uint64_t sched_objs = 0, sched_fail = 0; struct rte_graph_cluster_node_stats *stat = &cluster->stat; struct rte_node *node; rte_node_t count; + int model; + model = rte_graph_worker_model_get(); for (count = 0; count < cluster->nb_nodes; count++) { node = cluster->nodes[count]; + if (model == RTE_GRAPH_MODEL_MCORE_DISPATCH) { + sched_objs += node->total_sched_objs; + sched_fail += node->total_sched_fail; + } + calls += node->total_calls; objs += node->total_objs; cycles += node->total_cycles; @@ -348,6 +400,12 @@ cluster_node_arregate_stats(struct cluster_node *cluster) stat->calls = calls; stat->objs = objs; stat->cycles = cycles; + + if (model == RTE_GRAPH_MODEL_MCORE_DISPATCH) { + stat->sched_objs = sched_objs; + stat->sched_fail = sched_fail; + } + stat->ts = rte_get_timer_cycles(); stat->realloc_count = realloc_count; } diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index 2f86c17de7..7d77a790ac 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -208,6 +208,8 @@ struct rte_graph_cluster_node_stats { uint64_t prev_calls; /**< Previous number of calls. */ uint64_t prev_objs; /**< Previous number of processed objs. */ uint64_t prev_cycles; /**< Previous number of cycles. */ + uint64_t sched_objs; /**< Previous number of scheduled objs. */ + uint64_t sched_fail; /**< Previous number of failed schedule objs. */ uint64_t realloc_count; /**< Realloc count. */ diff --git a/lib/graph/rte_graph_model_dispatch.c b/lib/graph/rte_graph_model_dispatch.c index b46dd156ac..4cf00160ea 100644 --- a/lib/graph/rte_graph_model_dispatch.c +++ b/lib/graph/rte_graph_model_dispatch.c @@ -83,6 +83,7 @@ __graph_sched_node_enqueue(struct rte_node *node, struct rte_graph *graph) rte_pause(); off += size; + node->total_sched_objs += size; node->idx -= size; if (node->idx > 0) goto submit_again; @@ -94,6 +95,8 @@ __graph_sched_node_enqueue(struct rte_node *node, struct rte_graph *graph) memmove(&node->objs[0], &node->objs[off], node->idx * sizeof(void *)); + node->total_sched_fail += node->idx; + return false; } diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 70cfde7015..be8508cd83 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -94,6 +94,8 @@ struct rte_node { /* Fast schedule area for mcore dispatch model */ unsigned int lcore_id; /**< Node running lcore. */ }; + uint64_t total_sched_objs; /**< Number of objects scheduled. */ + uint64_t total_sched_fail; /**< Number of scheduled failure. */ /* Fast path area */ #define RTE_NODE_CTX_SZ 16 uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */ From patchwork Fri Mar 24 02:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125498 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 9FAD54281E; Fri, 24 Mar 2023 04:17:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75D8B42D4F; Fri, 24 Mar 2023 04:17:02 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 87DA342D52 for ; Fri, 24 Mar 2023 04:17:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627820; x=1711163820; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eHLXI4NTC2tnJ48tUvIBBjy5etf2ju7CP7f28DoE7vk=; b=G8DG8+ioKKXHipPmxDnI5RqvHBgVB4BwuzvdBtNTSoaXyeX+n/07yumT Gko1fX/IJIa9aP91uE4ZnJyOk/SslaKsjvaoXb2/ziF+n6yHOvwJ7xG+v UaFwa/0t8Hk4S8Pg1iYEWeH0pj0Tgmbkaw3uhyEbmP+qFOxoP8WBQFWRW iRdf7UyaAykJvmx8iHtlmj/s/6Qfoyxs0eqY+C7yX89JNDTaR9ChcN79X oRtToukLenSAltBT74SZoqGbrItCkfkSw3GM8HeFQANBW2xrDfkF78DbZ WoF0oUO1VpAhMeqqJ63/ejyYQNCc8IXhHEV7bQCZmUXLABjDKPVRAbNTm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266491" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266491" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:17:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998596" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998596" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:16:57 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 14/15] examples/l3fwd-graph: introduce multicore dispatch worker model Date: Fri, 24 Mar 2023 11:16:21 +0900 Message-Id: <20230324021622.1369006-15-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Add new parameter "model" to choose dispatch or rtc worker model. And in dispatch model, the node will affinity to worker core successively. Note: only support one RX node for remote model in current implementation. ./dpdk-l3fwd-graph -l 8,9,10,11 -n 4 -- -p 0x1 --config="(0,0,9)" -P --model="dispatch" Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- examples/l3fwd-graph/main.c | 237 +++++++++++++++++++++++++++++------- 1 file changed, 195 insertions(+), 42 deletions(-) diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c index 5feeab4f0f..cfa78003f4 100644 --- a/examples/l3fwd-graph/main.c +++ b/examples/l3fwd-graph/main.c @@ -55,6 +55,9 @@ #define NB_SOCKETS 8 +/* Graph module */ +#define WORKER_MODEL_RTC "rtc" +#define WORKER_MODEL_MCORE_DISPATCH "dispatch" /* Static global variables used within this file. */ static uint16_t nb_rxd = RX_DESC_DEFAULT; static uint16_t nb_txd = TX_DESC_DEFAULT; @@ -88,6 +91,10 @@ struct lcore_rx_queue { char node_name[RTE_NODE_NAMESIZE]; }; +struct model_conf { + enum rte_graph_worker_model model; +}; + /* Lcore conf */ struct lcore_conf { uint16_t n_rx_queue; @@ -153,6 +160,19 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { {RTE_IPV4(198, 18, 6, 0), 24, 6}, {RTE_IPV4(198, 18, 7, 0), 24, 7}, }; +static int +check_worker_model_params(void) +{ + if (rte_graph_worker_model_get() == RTE_GRAPH_MODEL_MCORE_DISPATCH && + nb_lcore_params > 1) { + printf("Exceeded max number of lcore params for remote model: %hu\n", + nb_lcore_params); + return -1; + } + + return 0; +} + static int check_lcore_params(void) { @@ -276,6 +296,7 @@ print_usage(const char *prgname) " --eth-dest=X,MM:MM:MM:MM:MM:MM: Ethernet destination for " "port X\n" " --max-pkt-len PKTLEN: maximum packet length in decimal (64-9600)\n" + " --model NAME: walking model name, dispatch or rtc(by default)\n" " --no-numa: Disable numa awareness\n" " --per-port-pool: Use separate buffer pool per port\n" " --pcap-enable: Enables pcap capture\n" @@ -318,6 +339,20 @@ parse_max_pkt_len(const char *pktlen) return len; } +static int +parse_worker_model(const char *model) +{ + if (strcmp(model, WORKER_MODEL_MCORE_DISPATCH) == 0) { + rte_graph_worker_model_set(RTE_GRAPH_MODEL_MCORE_DISPATCH); + return RTE_GRAPH_MODEL_MCORE_DISPATCH; + } else if (strcmp(model, WORKER_MODEL_RTC) == 0) + return RTE_GRAPH_MODEL_RTC; + + rte_exit(EXIT_FAILURE, "Invalid worker model: %s", model); + + return RTE_GRAPH_MODEL_LIST_END; +} + static int parse_portmask(const char *portmask) { @@ -434,6 +469,8 @@ static const char short_options[] = "p:" /* portmask */ #define CMD_LINE_OPT_PCAP_ENABLE "pcap-enable" #define CMD_LINE_OPT_NUM_PKT_CAP "pcap-num-cap" #define CMD_LINE_OPT_PCAP_FILENAME "pcap-file-name" +#define CMD_LINE_OPT_WORKER_MODEL "model" + enum { /* Long options mapped to a short option */ @@ -449,6 +486,7 @@ enum { CMD_LINE_OPT_PARSE_PCAP_ENABLE, CMD_LINE_OPT_PARSE_NUM_PKT_CAP, CMD_LINE_OPT_PCAP_FILENAME_CAP, + CMD_LINE_OPT_WORKER_MODEL_TYPE, }; static const struct option lgopts[] = { @@ -460,6 +498,7 @@ static const struct option lgopts[] = { {CMD_LINE_OPT_PCAP_ENABLE, 0, 0, CMD_LINE_OPT_PARSE_PCAP_ENABLE}, {CMD_LINE_OPT_NUM_PKT_CAP, 1, 0, CMD_LINE_OPT_PARSE_NUM_PKT_CAP}, {CMD_LINE_OPT_PCAP_FILENAME, 1, 0, CMD_LINE_OPT_PCAP_FILENAME_CAP}, + {CMD_LINE_OPT_WORKER_MODEL, 1, 0, CMD_LINE_OPT_WORKER_MODEL_TYPE}, {NULL, 0, 0, 0}, }; @@ -551,6 +590,11 @@ parse_args(int argc, char **argv) printf("Pcap file name: %s\n", pcap_filename); break; + case CMD_LINE_OPT_WORKER_MODEL_TYPE: + printf("Use new worker model: %s\n", optarg); + parse_worker_model(optarg); + break; + default: print_usage(prgname); return -1; @@ -726,15 +770,15 @@ print_stats(void) static int graph_main_loop(void *conf) { + struct model_conf *mconf = conf; struct lcore_conf *qconf; struct rte_graph *graph; uint32_t lcore_id; - RTE_SET_USED(conf); - lcore_id = rte_lcore_id(); qconf = &lcore_conf[lcore_id]; graph = qconf->graph; + rte_graph_worker_model_set(mconf->model); if (!graph) { RTE_LOG(INFO, L3FWD_GRAPH, "Lcore %u has nothing to do\n", @@ -788,6 +832,141 @@ config_port_max_pkt_len(struct rte_eth_conf *conf, return 0; } +static void +graph_config_mcore_dispatch(struct rte_graph_param graph_conf) +{ + uint16_t nb_patterns = graph_conf.nb_node_patterns; + int worker_count = rte_lcore_count() - 1; + int main_lcore_id = rte_get_main_lcore(); + int worker_lcore = main_lcore_id; + rte_graph_t main_graph_id = 0; + struct rte_node *node_tmp; + struct lcore_conf *qconf; + struct rte_graph *graph; + rte_graph_t graph_id; + rte_graph_off_t off; + int n_rx_node = 0; + rte_node_t count; + int i, j; + int ret; + + for (j = 0; j < nb_lcore_params; j++) { + qconf = &lcore_conf[lcore_params[j].lcore_id]; + /* Add rx node patterns of all lcore */ + for (i = 0; i < qconf->n_rx_queue; i++) { + char *node_name = qconf->rx_queue_list[i].node_name; + + graph_conf.node_patterns[nb_patterns + n_rx_node + i] = node_name; + n_rx_node++; + ret = rte_graph_model_dispatch_lcore_affinity_set(node_name, + lcore_params[j].lcore_id); + if (ret == 0) + printf("Set node %s affinity to lcore %u\n", node_name, + lcore_params[j].lcore_id); + } + } + + graph_conf.nb_node_patterns = nb_patterns + n_rx_node; + graph_conf.socket_id = rte_lcore_to_socket_id(main_lcore_id); + + qconf = &lcore_conf[main_lcore_id]; + snprintf(qconf->name, sizeof(qconf->name), "worker_%u", + main_lcore_id); + + /* create main graph */ + main_graph_id = rte_graph_create(qconf->name, &graph_conf); + if (main_graph_id == RTE_GRAPH_ID_INVALID) + rte_exit(EXIT_FAILURE, + "rte_graph_create(): main_graph_id invalid for lcore %u\n", + main_lcore_id); + + qconf->graph_id = main_graph_id; + qconf->graph = rte_graph_lookup(qconf->name); + /* >8 End of graph initialization. */ + if (!qconf->graph) + rte_exit(EXIT_FAILURE, + "rte_graph_lookup(): graph %s not found\n", + qconf->name); + + graph = qconf->graph; + rte_graph_foreach_node(count, off, graph, node_tmp) { + worker_lcore = rte_get_next_lcore(worker_lcore, true, 1); + + /* Need to set the node Lcore affinity before clone graph for each lcore */ + if (node_tmp->lcore_id == RTE_MAX_LCORE) { + ret = rte_graph_model_dispatch_lcore_affinity_set(node_tmp->name, + worker_lcore); + if (ret == 0) + printf("Set node %s affinity to lcore %u\n", + node_tmp->name, worker_lcore); + } + } + + worker_lcore = main_lcore_id; + for (i = 0; i < worker_count; i++) { + worker_lcore = rte_get_next_lcore(worker_lcore, true, 1); + + qconf = &lcore_conf[worker_lcore]; + snprintf(qconf->name, sizeof(qconf->name), "cloned-%u", worker_lcore); + graph_id = rte_graph_clone(main_graph_id, qconf->name); + ret = rte_graph_model_dispatch_core_bind(graph_id, worker_lcore); + if (ret == 0) + printf("bind graph %d to lcore %u\n", graph_id, worker_lcore); + + /* full cloned graph name */ + snprintf(qconf->name, sizeof(qconf->name), "%s", + rte_graph_id_to_name(graph_id)); + qconf->graph_id = graph_id; + qconf->graph = rte_graph_lookup(qconf->name); + if (!qconf->graph) + rte_exit(EXIT_FAILURE, + "Failed to lookup graph %s\n", + qconf->name); + continue; + } +} + +static void +graph_config_rtc(struct rte_graph_param graph_conf) +{ + uint16_t nb_patterns = graph_conf.nb_node_patterns; + struct lcore_conf *qconf; + rte_graph_t graph_id; + uint32_t lcore_id; + rte_edge_t i; + + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { + if (rte_lcore_is_enabled(lcore_id) == 0) + continue; + + qconf = &lcore_conf[lcore_id]; + /* Skip graph creation if no source exists */ + if (!qconf->n_rx_queue) + continue; + /* Add rx node patterns of this lcore */ + for (i = 0; i < qconf->n_rx_queue; i++) { + graph_conf.node_patterns[nb_patterns + i] = + qconf->rx_queue_list[i].node_name; + } + graph_conf.nb_node_patterns = nb_patterns + i; + graph_conf.socket_id = rte_lcore_to_socket_id(lcore_id); + snprintf(qconf->name, sizeof(qconf->name), "worker_%u", + lcore_id); + graph_id = rte_graph_create(qconf->name, &graph_conf); + if (graph_id == RTE_GRAPH_ID_INVALID) + rte_exit(EXIT_FAILURE, + "rte_graph_create(): graph_id invalid for lcore %u\n", + lcore_id); + qconf->graph_id = graph_id; + qconf->graph = rte_graph_lookup(qconf->name); + /* >8 End of graph initialization. */ + if (!qconf->graph) + rte_exit(EXIT_FAILURE, + "rte_graph_lookup(): graph %s not found\n", + qconf->name); + } +} + int main(int argc, char **argv) { @@ -808,10 +987,12 @@ main(int argc, char **argv) uint16_t queueid, portid, i; const char **node_patterns; struct lcore_conf *qconf; + struct model_conf mconf; uint16_t nb_graphs = 0; uint16_t nb_patterns; uint8_t rewrite_len; uint32_t lcore_id; + uint16_t model; int ret; /* Init EAL */ @@ -840,6 +1021,9 @@ main(int argc, char **argv) if (check_lcore_params() < 0) rte_exit(EXIT_FAILURE, "check_lcore_params() failed\n"); + if (check_worker_model_params() < 0) + rte_exit(EXIT_FAILURE, "check_worker_model_params() failed\n"); + ret = init_lcore_rx_queues(); if (ret < 0) rte_exit(EXIT_FAILURE, "init_lcore_rx_queues() failed\n"); @@ -1079,51 +1263,18 @@ main(int argc, char **argv) memset(&graph_conf, 0, sizeof(graph_conf)); graph_conf.node_patterns = node_patterns; + graph_conf.nb_node_patterns = nb_patterns; /* Pcap config */ graph_conf.pcap_enable = pcap_trace_enable; graph_conf.num_pkt_to_capture = packet_to_capture; graph_conf.pcap_filename = pcap_filename; - for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { - rte_graph_t graph_id; - rte_edge_t i; - - if (rte_lcore_is_enabled(lcore_id) == 0) - continue; - - qconf = &lcore_conf[lcore_id]; - - /* Skip graph creation if no source exists */ - if (!qconf->n_rx_queue) - continue; - - /* Add rx node patterns of this lcore */ - for (i = 0; i < qconf->n_rx_queue; i++) { - graph_conf.node_patterns[nb_patterns + i] = - qconf->rx_queue_list[i].node_name; - } - - graph_conf.nb_node_patterns = nb_patterns + i; - graph_conf.socket_id = rte_lcore_to_socket_id(lcore_id); - - snprintf(qconf->name, sizeof(qconf->name), "worker_%u", - lcore_id); - - graph_id = rte_graph_create(qconf->name, &graph_conf); - if (graph_id == RTE_GRAPH_ID_INVALID) - rte_exit(EXIT_FAILURE, - "rte_graph_create(): graph_id invalid" - " for lcore %u\n", lcore_id); - - qconf->graph_id = graph_id; - qconf->graph = rte_graph_lookup(qconf->name); - /* >8 End of graph initialization. */ - if (!qconf->graph) - rte_exit(EXIT_FAILURE, - "rte_graph_lookup(): graph %s not found\n", - qconf->name); - } + model = rte_graph_worker_model_get(); + if (model == RTE_GRAPH_MODEL_MCORE_DISPATCH) + graph_config_mcore_dispatch(graph_conf); + else + graph_config_rtc(graph_conf); memset(&rewrite_data, 0, sizeof(rewrite_data)); rewrite_len = sizeof(rewrite_data); @@ -1174,8 +1325,10 @@ main(int argc, char **argv) } /* >8 End of adding route to ip4 graph infa. */ + mconf.model = model; /* Launch per-lcore init on every worker lcore */ - rte_eal_mp_remote_launch(graph_main_loop, NULL, SKIP_MAIN); + rte_eal_mp_remote_launch(graph_main_loop, &mconf, + SKIP_MAIN); /* Accumulate and print stats on main until exit */ if (rte_graph_has_stats_feature()) From patchwork Fri Mar 24 02:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 125499 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 1D18F4281E; Fri, 24 Mar 2023 04:18:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DECD042D63; Fri, 24 Mar 2023 04:17:04 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id ECE2942D51 for ; Fri, 24 Mar 2023 04:17:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679627823; x=1711163823; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i+emlEp3ifo13uyg8O/EbDX5JIJB9ZkepIFS1heXcIs=; b=C679JML9zRsZGl012Wj0fPVPfkwL4GZ4V+lA3C6Rh/cQEU/hDUxiv3eb JxX18jIv8lYjOMcAnPVwujFmtjLxQc1kfr8rXh9pftlW5nprE7pt2JGqs 0GP51YwZG9vhxzaMiqYg9IhPZwTqLNWrW60iyQbhXZtg+v1aKGnN42PNu V8jjVLI3UEBVsuypY1DcXioHlW6A3TQ9VaLM2C7MMgq1q8P2ZCGw66qAX TLQB/tkaCPdQvzWg4FnxtXvhFtKjskhm7Yyd5JAtM7BnZyN89uzE4C5gY fprJ4fX+8klGDxlFxGf40qEpEy8EdL3lHSlAyzb0M3tAdXtJ/xaZaro1h g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402266500" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="402266500" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 20:17:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="684998599" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="684998599" Received: from dpdk-zhirun-lmm.sh.intel.com ([10.67.119.68]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2023 20:17:00 -0700 From: Zhirun Yan To: dev@dpdk.org, jerinj@marvell.com, kirankumark@marvell.com, ndabilpuram@marvell.com Cc: cunming.liang@intel.com, haiyue.wang@intel.com, Zhirun Yan Subject: [PATCH v2 15/15] doc: update multicore dispatch model in graph guides Date: Fri, 24 Mar 2023 11:16:22 +0900 Message-Id: <20230324021622.1369006-16-zhirun.yan@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324021622.1369006-1-zhirun.yan@intel.com> References: <20221117050926.136974-1-zhirun.yan@intel.com> <20230324021622.1369006-1-zhirun.yan@intel.com> MIME-Version: 1.0 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 Update graph documentation to introduce new multicore dispatch model. Signed-off-by: Haiyue Wang Signed-off-by: Cunming Liang Signed-off-by: Zhirun Yan --- doc/guides/prog_guide/graph_lib.rst | 59 +++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/doc/guides/prog_guide/graph_lib.rst b/doc/guides/prog_guide/graph_lib.rst index 1cfdc86433..e3c0d652e4 100644 --- a/doc/guides/prog_guide/graph_lib.rst +++ b/doc/guides/prog_guide/graph_lib.rst @@ -189,14 +189,65 @@ In the above example, A graph object will be created with ethdev Rx node of port 0 and queue 0, all ipv4* nodes in the system, and ethdev tx node of all ports. -Multicore graph processing -~~~~~~~~~~~~~~~~~~~~~~~~~~ -In the current graph library implementation, specifically, -``rte_graph_walk()`` and ``rte_node_enqueue*`` fast path API functions +graph model chossing +~~~~~~~~~~~~~~~~~~~~ +Currently, there are 2 different walking model. Use +``rte_graph_worker_model_set()`` to set the walk model. + +RTC (Run-To-Completion) +^^^^^^^^^^^^^^^^^^^^^^^ +This is the default graph walking model. specifically, +``rte_graph_walk_rtc()`` and ``rte_node_enqueue*`` fast path API functions are designed to work on single-core to have better performance. The fast path API works on graph object, So the multi-core graph processing strategy would be to create graph object PER WORKER. +Example: + +Graph: node-0 -> node-1 -> node-2 @Core0. + +.. code-block:: diff + + + - - - - - - - - - - - - - - - - - - - - - + + ' Core #0 ' + ' ' + ' +--------+ +---------+ +--------+ ' + ' | Node-0 | --> | Node-1 | --> | Node-2 | ' + ' +--------+ +---------+ +--------+ ' + ' ' + + - - - - - - - - - - - - - - - - - - - - - + + +Dispatch model +^^^^^^^^^^^^^^ +The dispatch model enables a cross-core dispatching mechanism which employs +a scheduling work-queue to dispatch streams to other worker cores which +being associated with the destination node. + +Use ``rte_graph_model_dispatch_lcore_affinity_set()`` to set lcore affinity +with the node. +Each worker core will have a graph repetition. Use ``rte_graph_clone()`` to +clone graph for each worker and use``rte_graph_model_dispatch_core_bind()`` +to bind graph with the worker core. + +Example: + +Graph topo: node-0 -> Core1; node-1 -> node-2; node-2 -> node-3. +Config graph: node-0 @Core0; node-1/3 @Core1; node-2 @Core2. + +.. code-block:: diff + + + - - - - - -+ +- - - - - - - - - - - - - + + - - - - - -+ + ' Core #0 ' ' Core #1 ' ' Core #2 ' + ' ' ' ' ' ' + ' +--------+ ' ' +--------+ +--------+ ' ' +--------+ ' + ' | Node-0 | - - - ->| Node-1 | | Node-3 |<- - - - | Node-2 | ' + ' +--------+ ' ' +--------+ +--------+ ' ' +--------+ ' + ' ' ' | ' ' ^ ' + + - - - - - -+ +- - -|- - - - - - - - - - + + - - -|- - -+ + | | + + - - - - - - - - - - - - - - - - + + + In fast path ~~~~~~~~~~~~ Typical fast-path code looks like below, where the application