From patchwork Tue Aug 15 03:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130321 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 BC3A143069; Tue, 15 Aug 2023 05:52:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3BDD43251; Tue, 15 Aug 2023 05:52:50 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 0772941104 for ; Tue, 15 Aug 2023 05:52:49 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7DDF2623E6; Tue, 15 Aug 2023 03:52:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CDFFC433C9; Tue, 15 Aug 2023 03:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071567; bh=xgwsGenNQ2/EuQJWt3NtG2gxSZFtRwfO3KI2h8UGChA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TBiw0JSNapQiGKFpsm+C3MlfEKeQgQn+dSV/3iksJDOO2iGnD9+JPDeTikV6NnV2w bPlQjyuVj/FZVZI7VhZRobus1k7EnOigY4usJGIzY7hI8Wnn+5edXoqk8nF/BaFDKK AEzoZtCWUGIwwkAQIcAgBW9+Qrn2Ob2UYrN4t1PQAonw4OTnShCjdV3mYrChpWRJb0 Vg8ue1dkF38ANkwLRkI7mg7OucKSFpKN+YxJIEnJXNGhLd4vR+3oLOWuhTtqSfSWoi gMfp5WWwmPEbMOw0TiAfWt7yDlhHEKkZHg/0h5w+KcJkBqQRdBnfBZ77iAsgm8uVE3 H6x29JNwzg36w== From: okaya@kernel.org To: Cc: dev@dpdk.org, Graham Whyte , Sinan Kaya Subject: [PATCH v3 1/7] eal: fixes for re-initialization issues Date: Mon, 14 Aug 2023 23:52:33 -0400 Message-Id: <20230815035239.1365591-2-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Graham Whyte reinitialize the solib link list and clean the globals holding state for parsing. Signed-off-by: Sinan Kaya Signed-off-by: Graham Whyte --- lib/eal/common/eal_common_options.c | 7 +++++++ lib/eal/linux/eal.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 062f1d8d9c..7043b6e2fd 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -1981,6 +1981,13 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg) memcpy(cpuset, &lcore_config[rte_get_main_lcore()].cpuset, sizeof(*cpuset)); } + + /* Reinitialize solib_list */ + TAILQ_INIT(&solib_list); + + main_lcore_parsed = 0; + mem_parsed = 0; + core_parsed = 0; } int diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index c6efd92014..650fb5f5a9 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -79,6 +79,8 @@ struct lcore_config lcore_config[RTE_MAX_LCORE]; int rte_cycles_vmware_tsc_map; +static uint32_t run_once; + int eal_clean_runtime_dir(void) { @@ -505,6 +507,7 @@ eal_parse_socket_arg(char *strval, volatile uint64_t *socket_arg) socket_arg[i] = val; } + __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED); return 0; } @@ -967,7 +970,6 @@ int rte_eal_init(int argc, char **argv) { int i, fctret, ret; - static uint32_t run_once; uint32_t has_run = 0; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; char thread_name[RTE_MAX_THREAD_NAME_LEN]; From patchwork Tue Aug 15 03:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130322 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 A1BA743069; Tue, 15 Aug 2023 05:53:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E32094325D; Tue, 15 Aug 2023 05:52:51 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id CFE7A427E9 for ; Tue, 15 Aug 2023 05:52:49 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 536BF62638 for ; Tue, 15 Aug 2023 03:52:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22E68C433C7; Tue, 15 Aug 2023 03:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071568; bh=P2glLqiw0cUHcsK6See6IMrndxeGT2hiA71Vv1o5lZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=By4TaDXxG9b02xeobtCwJPCza8TCKm988ehcuOtdlR/LLL4M8ltP+UPsYx8HZCrT1 TqruaO31dMOpa8KR67nlIRxsYnOwCSr39xEZXF3Q12psD0bT/PdQs6k6CR+pOzHJ0o H/LVFX4egYscfeVbYOdVo0ceNHWqfshyPTSA/EhU7WXbLZ/MAFFd2ayPn3vVYSNoqQ Q7kL9pgyI890zSNorBTf1WNYLLpEQWglXXo+FIZVjahDTXubB9cXIOnxq0H9FbW5DE DrwvcopQJbPfDYQKg09tQf+x/CkpGAn9srLG0yv0p67ThxQReH1ZvdkXL+R/wbb+NV A57YwV9pokbmQ== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 2/7] tailq: skip init if already initialized Date: Mon, 14 Aug 2023 23:52:34 -0400 Message-Id: <20230815035239.1365591-3-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Allows tailq to be reinitialied multiple times by looking up previously registered tailqs Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_tailqs.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/eal/common/eal_common_tailqs.c b/lib/eal/common/eal_common_tailqs.c index 580fbf24bc..75c0235438 100644 --- a/lib/eal/common/eal_common_tailqs.c +++ b/lib/eal/common/eal_common_tailqs.c @@ -73,9 +73,10 @@ rte_eal_tailq_create(const char *name) strlcpy(head->name, name, sizeof(head->name) - 1); TAILQ_INIT(&head->tailq_head); rte_tailqs_count++; + return head; } - return head; + return rte_eal_tailq_lookup(name); } /* local register, used to store "early" tailqs before rte_eal_init() and to @@ -99,7 +100,9 @@ rte_eal_tailq_update(struct rte_tailq_elem *t) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) { /* primary process is the only one that creates */ - t->head = rte_eal_tailq_create(t->name); + t->head = rte_eal_tailq_lookup(t->name); + if (t->head == NULL) + t->head = rte_eal_tailq_create(t->name); } else { t->head = rte_eal_tailq_lookup(t->name); } @@ -108,15 +111,13 @@ rte_eal_tailq_update(struct rte_tailq_elem *t) int rte_eal_tailq_register(struct rte_tailq_elem *t) { - if (rte_eal_tailq_local_register(t) < 0) { - RTE_LOG(ERR, EAL, - "%s tailq is already registered\n", t->name); - goto error; - } + rte_eal_tailq_local_register(t); /* if a register happens after rte_eal_tailqs_init(), then we can update * tailq head */ if (rte_tailqs_count >= 0) { + RTE_LOG(INFO, EAL, + "%s tailq is registered\n", t->name); rte_eal_tailq_update(t); if (t->head == NULL) { RTE_LOG(ERR, EAL, @@ -138,6 +139,11 @@ rte_eal_tailqs_init(void) { struct rte_tailq_elem *t; + if (rte_tailqs_count > 0) { + RTE_LOG(INFO, EAL, "tailq already initialized\n"); + return 0; + } + rte_tailqs_count = 0; TAILQ_FOREACH(t, &rte_tailq_elem_head, next) { From patchwork Tue Aug 15 03:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130323 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 4784C43069; Tue, 15 Aug 2023 05:53:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFA864325E; Tue, 15 Aug 2023 05:52:52 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 95D2543000 for ; Tue, 15 Aug 2023 05:52:50 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2164C62638; Tue, 15 Aug 2023 03:52:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C686BC433C9; Tue, 15 Aug 2023 03:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071569; bh=joa54IhMnxETGrrAfoMJz218LI2OKvqtobhOYXCZW5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qp/UXDTAXUjLMejIzobNSQrVvfRrP61E8MNlAMQMFX+O/db8tKD0Thsju3lVSwxn7 psNhDrrffomxL7mjgEcpXNFGZxlKzGiJW6eWHQQ7EgVzRMXvku9Qw/Kxb9dz0fTRB6 fdKcyVILPo6nqpGx2AdSCqjNjG+yvIUO1e+GEbCGWs8Ds4mRX0IWNs5Z3rHHA4+snD mgOFo/iqeygJGSGZDRhvqBXsbfvTCGOhxv4W4bfduOy5Vyy6L94nNVozk3lGz2frJu pgaL5pJ/CKPdLtDCrFOD3EQvpVeTnwAvHTTjkKJND5PvxBtUgrAtAukaOVfAo04LRB 7EboHuB8yQ1pQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 3/7] eal_memzone: bail out on initialized Date: Mon, 14 Aug 2023 23:52:35 -0400 Message-Id: <20230815035239.1365591-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Initialize memzone once and bail out if someone calls init multiple times. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memzone.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 1f3e701499..6645ccfe83 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -22,6 +22,8 @@ #include "eal_private.h" #include "eal_memcfg.h" +static bool memzone_initialized; + /* Default count used until rte_memzone_max_set() is called */ #define DEFAULT_MAX_MEMZONE_COUNT 2560 @@ -426,6 +428,9 @@ rte_eal_memzone_init(void) struct rte_mem_config *mcfg; int ret = 0; + if (memzone_initialized) + return 0; + /* get pointer to global configuration */ mcfg = rte_eal_get_configuration()->mem_config; @@ -444,6 +449,8 @@ rte_eal_memzone_init(void) rte_rwlock_write_unlock(&mcfg->mlock); + memzone_initialized = true; + return ret; } From patchwork Tue Aug 15 03:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130324 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 0D07C43069; Tue, 15 Aug 2023 05:53:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02B4741104; Tue, 15 Aug 2023 05:52:54 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 9A29143259 for ; Tue, 15 Aug 2023 05:52:51 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 242EF618F1; Tue, 15 Aug 2023 03:52:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB104C433C8; Tue, 15 Aug 2023 03:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071570; bh=BT/wIrnsPmQsnhCQmad4ZeSSA7/RGqJvb34EJiS3obo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rcNHHEeg37TinCRdqiGMIAeFaBCi6E77K5dXcFe9gVwaASJxsX7i2jOQxZ9tl/56O x9HfJgizxPl9LEIjhMJ4AVkBamIMv8YuAlnAczCfy6rHmHEu/k1dNoTcxsspB5RdxB 41xwh2HsnU7XFWnx1w0Te5H5M0fjIcbn6U1PSX9jTsTZ+Qdn/n5b3f1NVSlCaGmCJI eVVwBKjbt9OOQ0zN2XiCKngyLg/GAYqIcjrIlcL2vmqPyqHqubkUmJ1OYO90FsAXln O1NwH3LIDzPTX1TNGGPYtrquwUGLVk7IFh+c8ppjMNPtEFiQqG71RGH7AzFDIFtv3L WYiHjrRAn+3rg== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 4/7] memseg: init once Date: Mon, 14 Aug 2023 23:52:36 -0400 Message-Id: <20230815035239.1365591-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Initialize memory segments just once and bail out if called multiple times. Signed-off-by: Sinan Kaya --- lib/eal/linux/eal_memory.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 9b6f08fba8..df0aa9ccc7 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -57,6 +57,7 @@ */ static int phys_addrs_available = -1; +static bool memseg_initialized; #define RANDOMIZE_VA_SPACE_FILE "/proc/sys/kernel/randomize_va_space" @@ -1920,6 +1921,10 @@ rte_eal_memseg_init(void) { /* increase rlimit to maximum */ struct rlimit lim; + int ret; + + if (memseg_initialized) + return 0; #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES const struct internal_config *internal_conf = @@ -1948,11 +1953,16 @@ rte_eal_memseg_init(void) } #endif - return rte_eal_process_type() == RTE_PROC_PRIMARY ? + ret = rte_eal_process_type() == RTE_PROC_PRIMARY ? #ifndef RTE_ARCH_64 memseg_primary_init_32() : #else memseg_primary_init() : #endif memseg_secondary_init(); + + if (!ret) + memseg_initialized = true; + + return ret; } From patchwork Tue Aug 15 03:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130325 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 87A5543069; Tue, 15 Aug 2023 05:53:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5ED954326F; Tue, 15 Aug 2023 05:52:55 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 8971E4325E for ; Tue, 15 Aug 2023 05:52:52 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1418B623E6; Tue, 15 Aug 2023 03:52:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3315C433CA; Tue, 15 Aug 2023 03:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071571; bh=8KfylMDNAAMf/4PTvAvXfM+LCTHBDpSbwxGnQ2N4shA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCDKX18aCFPR0XTjRIGOxoDX2wUMvW8oYIzX/LhbH+yP8ZuzNcABL0KvSE5gB9Xh+ LZ7ylXewJ436jex6+iKxPOBcEw49TocJoE/hd+9bYT3U8Q1kMb0XrQF/BOAstGlLSd w2UOtGqS1748ba4ZK3SP1uArSxNFG0EYNydLjIfBHJF/p8WAjDKqsS3B7ZsXNmtn50 nW0J1W5Hh7bijSxjpJYrLXqfQt7z/hDFhUfbIWmQPElhea2rfOpJ48kJRaelMJBUXV iyx9SHV3fIOELrc8JiBotNaQhs0HA/qOr5yhjjArsrhDdoVhZf84Ivhh6Ig9D3HfeH Vm1lFAKF8gM7Q== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 5/7] eal_memory: skip initialization Date: Mon, 14 Aug 2023 23:52:37 -0400 Message-Id: <20230815035239.1365591-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Initialize heap area just once. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memory.c | 5 +++++ lib/eal/common/malloc_heap.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index d9433db623..4c68de1054 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -41,6 +41,7 @@ static void *next_baseaddr; static uint64_t system_page_sz; +static bool memory_initialized; #define MAX_MMAP_WITH_DEFINED_ADDR_TRIES 5 void * @@ -1084,6 +1085,9 @@ rte_eal_memory_init(void) eal_get_internal_configuration(); int retval; + if (memory_initialized) + return 0; + RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n"); if (rte_eal_memseg_init() < 0) @@ -1101,6 +1105,7 @@ rte_eal_memory_init(void) if (internal_conf->no_shconf == 0 && rte_eal_memdevice_init() < 0) goto fail; + memory_initialized = true; return 0; fail: return -1; diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 6b6cf9174c..8d05a2ab2e 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -31,6 +31,8 @@ #define CONST_MAX(a, b) (a > b ? a : b) /* RTE_MAX is not a constant */ #define EXTERNAL_HEAP_MIN_SOCKET_ID (CONST_MAX((1 << 8), RTE_MAX_NUMA_NODES)) +static bool heap_initialized; + static unsigned check_hugepage_sz(unsigned flags, uint64_t hugepage_sz) { @@ -1410,6 +1412,9 @@ rte_eal_malloc_heap_init(void) const struct internal_config *internal_conf = eal_get_internal_configuration(); + if (heap_initialized) + return 0; + if (internal_conf->match_allocations) RTE_LOG(DEBUG, EAL, "Hugepages will be freed exactly as allocated.\n"); @@ -1449,6 +1454,8 @@ int rte_eal_malloc_heap_populate(void) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + heap_initialized = true; + /* add all IOVA-contiguous areas to the heap */ return rte_memseg_contig_walk(malloc_add_seg, NULL); } From patchwork Tue Aug 15 03:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130326 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 EFC8E43069; Tue, 15 Aug 2023 05:53:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7618C43275; Tue, 15 Aug 2023 05:52:56 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 6167943262 for ; Tue, 15 Aug 2023 05:52:53 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E2753618F1; Tue, 15 Aug 2023 03:52:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF68AC433C8; Tue, 15 Aug 2023 03:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071572; bh=IrVYOfiG9DbtfdWC88+Xh5SLmYrqkmLt9PPWkrhFzaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcUKiRoC9G5r47vfVE0Z6+SoCijiV34tshxN/V+MBl2WMXVqMCbyObyHjjAzNXNvL EIE3NfRWqvLYfnKWJqMxcg/CWTAhw05ZFDDi5ICshAJGRrAQHYe3TEZurx93B3ducf a5ks2bfvTMGI0cZReWrZNzivDh1UN8StxyDBFTrO7HvMLnCdOrEfQ0zbkhisEHfvCw IriXaYkpLb/NQ0P5mft+ndBXpwxQiVBgzwhDHtaqB7AVNVVMnmtz0eCeN5etNrBVAl fyzgiliDO/R+Tyt8lN1r0wTraNWgrZot3xvUTOpvudZxiTYL6Ng0VpEg9hzfEqwQLw OGFYfHe5frq3w== From: okaya@kernel.org To: Harman Kalra Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 6/7] eal_interrupts: don't reinitialize threads Date: Mon, 14 Aug 2023 23:52:38 -0400 Message-Id: <20230815035239.1365591-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Initialize interrupt thread once and keep a flag for further init. Signed-off-by: Sinan Kaya --- lib/eal/linux/eal_interrupts.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index c9881143be..6a35b4aebd 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -91,6 +91,9 @@ static struct rte_intr_source_list intr_sources; /* interrupt handling thread */ static pthread_t intr_thread; +/* flag for initialization */ +static bool intr_initialized; + /* VFIO interrupts */ #ifdef VFIO_PRESENT @@ -1175,6 +1178,9 @@ rte_eal_intr_init(void) { int ret = 0; + if (intr_initialized) + return 0; + /* init the global interrupt source head */ TAILQ_INIT(&intr_sources); @@ -1196,6 +1202,7 @@ rte_eal_intr_init(void) "Failed to create thread for interrupt handling\n"); } + intr_initialized = true; return ret; } From patchwork Tue Aug 15 03:52:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130327 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 9F71C43069; Tue, 15 Aug 2023 05:53:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DFD743279; Tue, 15 Aug 2023 05:52:57 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 4745143265 for ; Tue, 15 Aug 2023 05:52:54 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C29B262638 for ; Tue, 15 Aug 2023 03:52:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94234C433CA; Tue, 15 Aug 2023 03:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692071573; bh=Gj69J2v8knaxb6SDuw8xLtIOMRPkJbl5ignUYlZRqwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vF3Uze94A5KjMs1RdJI+k7KL1sWQ3hj7/auUV3/Fn4AoouxtUgbPNSk3RK7K9huzE sphZ8eBCwC2xQF3KaKfRLQ3+hy5g8EExUMwPsAc5GfZaK08y2Obz7GBAVvDsOHU0Ai qnfPdZuQvhVv0EhIenB3cqLXBJMBpbhaliPiUMEWNG5J5Yth2An4pDPBsxFHPa9CAv g/zP4LMq9n3W7aGf86bspGXipDemiwISglOnLF5OgnIxzGHB0yO2qF2hatQwuMv9RF 7HNmGed5B5t5i2L7VxNdHAiCoVVQ7dWs18I8m0oSuWQwEkT/KFWgsVERtFLRz4CHJq nBxFKSXQLnk8A== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 7/7] eal: initialize worker threads once Date: Mon, 14 Aug 2023 23:52:39 -0400 Message-Id: <20230815035239.1365591-8-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815035239.1365591-1-okaya@kernel.org> References: <20230815035239.1365591-1-okaya@kernel.org> 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 From: Sinan Kaya Initialize worker threads once and keep a flag for other init calls. Signed-off-by: Sinan Kaya --- lib/eal/linux/eal.c | 60 ++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 650fb5f5a9..9a41bc66cf 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -80,6 +80,7 @@ int rte_cycles_vmware_tsc_map; static uint32_t run_once; +static bool worker_initialized; int eal_clean_runtime_dir(void) @@ -1254,42 +1255,45 @@ rte_eal_init(int argc, char **argv) config->main_lcore, (uintptr_t)pthread_self(), cpuset, ret == 0 ? "" : "..."); - RTE_LCORE_FOREACH_WORKER(i) { + if (worker_initialized == false) { + RTE_LCORE_FOREACH_WORKER(i) { /* * create communication pipes between main thread * and children */ - if (pipe(lcore_config[i].pipe_main2worker) < 0) - rte_panic("Cannot create pipe\n"); - if (pipe(lcore_config[i].pipe_worker2main) < 0) - rte_panic("Cannot create pipe\n"); - - lcore_config[i].state = WAIT; - - /* create a thread for each lcore */ - ret = eal_worker_thread_create(i); - if (ret != 0) - rte_panic("Cannot create thread\n"); - - /* Set thread_name for aid in debugging. */ - snprintf(thread_name, sizeof(thread_name), - "rte-worker-%d", i); - rte_thread_set_name(lcore_config[i].thread_id, thread_name); + if (pipe(lcore_config[i].pipe_main2worker) < 0) + rte_panic("Cannot create pipe\n"); + if (pipe(lcore_config[i].pipe_worker2main) < 0) + rte_panic("Cannot create pipe\n"); + + lcore_config[i].state = WAIT; + + /* create a thread for each lcore */ + ret = eal_worker_thread_create(i); + if (ret != 0) + rte_panic("Cannot create thread\n"); + + /* Set thread_name for aid in debugging. */ + snprintf(thread_name, sizeof(thread_name), + "rte-worker-%d", i); + rte_thread_set_name(lcore_config[i].thread_id, thread_name); + + ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id, + &lcore_config[i].cpuset); + if (ret != 0) + rte_panic("Cannot set affinity\n"); + } - ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id, - &lcore_config[i].cpuset); - if (ret != 0) - rte_panic("Cannot set affinity\n"); + /* + * Launch a dummy function on all worker lcores, so that main lcore + * knows they are all ready when this function returns. + */ + rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MAIN); + rte_eal_mp_wait_lcore(); + worker_initialized = true; } - /* - * Launch a dummy function on all worker lcores, so that main lcore - * knows they are all ready when this function returns. - */ - rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MAIN); - rte_eal_mp_wait_lcore(); - /* initialize services so vdevs register service during bus_probe. */ ret = rte_service_init(); if (ret) {