From patchwork Tue Aug 15 01:38:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130307 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 6006E43067; Tue, 15 Aug 2023 03:38:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C58554323A; Tue, 15 Aug 2023 03:38:39 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 9107C41104 for ; Tue, 15 Aug 2023 03:38:36 +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 0BAE161D91; Tue, 15 Aug 2023 01:38:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1540DC433CA; Tue, 15 Aug 2023 01:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063515; bh=vlbQu1VIdtxePEVvbdBSw2T+KLemwDjVf7EYnEi6z8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LjEkWiHlI1+tc9gydfm5sLqwYtq/hhXe2g5oVoGu2FsrpSfYClpTjAJNGGr1LXvjP r8gc23MwTLERKtylILcZN3EotFWvFuzbpK5uvPvKRTE5FoGzkQB3FgUL0OxcBAVQs3 YHnszx3OWcKNf2mAF3DEPNKx4LOuN3aBN/JYnFmhiB4c6A4e730DcX+E2u+lRORZ5M +WmFFjUDbnro6R7myQyxYJNtDl3KoYxm1vt4IQkKr9rbdsyx4NIHD6ommSA8jqiJgC tL4uwsKYMVgl42GOhlt59gwgA5+W+sTaJKHYTRlOgBST4jLuRubSlJWOLUuHfDCzNr E7qMttvLOQmWQ== From: okaya@kernel.org To: Cc: dev@dpdk.org, Graham Whyte , Sinan Kaya Subject: [PATCH v1 1/7] eal: fixes for re-initialization issues Date: Mon, 14 Aug 2023 21:38:20 -0400 Message-Id: <20230815013826.1288972-2-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 2d6535781b..b58df1bc5f 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -1983,6 +1983,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); + + master_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 8c118d0d9f..5fd81d71cb 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -78,6 +78,8 @@ struct lcore_config lcore_config[RTE_MAX_LCORE]; int rte_cycles_vmware_tsc_map; +static uint32_t run_once = 0; + int eal_clean_runtime_dir(void) { @@ -504,6 +506,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; } @@ -960,7 +963,6 @@ int rte_eal_init(int argc, char **argv) { int i, fctret, ret; - static uint32_t run_once; uint32_t has_run = 0; const char *p; static char logid[PATH_MAX]; From patchwork Tue Aug 15 01:38:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130308 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 C293E43067; Tue, 15 Aug 2023 03:38:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 055134325B; Tue, 15 Aug 2023 03:38:41 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id F387741104 for ; Tue, 15 Aug 2023 03:38:36 +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 81C6360F8F for ; Tue, 15 Aug 2023 01:38:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A490DC433C7; Tue, 15 Aug 2023 01:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063515; bh=YH0QgHjVMcI63BYdBc4AMh/fl0OmlbvrE5kBQfaopDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W76Vh19+Fb+qT2FFFy76mO4+RYSmUC7UAqMybuDbOhVzZtLYmvpKBpOf9DyYFYpuM SjiCDqkwFFt9dmfV3+JUNyo9QDQDLz9t6kZkhQhBzT+F4l19oPf7+mhzdkYncSyK+P EaWruw8Cl3rRgVL7xBJ5M+0GvQkNxIFpzivOx/qoxNijmYZ/ZtsiNRcHuULJvN2vIX r4LvOYxRoWeLPMsiQB11OtihsdE0FakmX5BsQ8XWPLOBkABHLB5Dv5EOektpq49EEu CzaEf0yj4iDm/aXU39YEZf3EuQAr7ulGtPJXz+EnBB6mg8pXKQM97GFhRarti5MFsJ S8/u9NouWVF1w== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 2/7] tailq: skip init if already initialized Date: Mon, 14 Aug 2023 21:38:21 -0400 Message-Id: <20230815013826.1288972-3-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/eal/common/eal_common_tailqs.c b/lib/eal/common/eal_common_tailqs.c index 580fbf24bc..3995aa2717 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,10 @@ 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 +112,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 +140,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 01:38:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130309 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 6A63E43067; Tue, 15 Aug 2023 03:38:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 267A143261; Tue, 15 Aug 2023 03:38:42 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 39D71427E9 for ; Tue, 15 Aug 2023 03:38:37 +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 AC8816133D; Tue, 15 Aug 2023 01:38:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D7C4C433CA; Tue, 15 Aug 2023 01:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063516; bh=1PXlkXCH2bZmihyGtBH6XHPcsIBcFOinXg+ist8AKj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFNu7Vd5ix/3cp4OujJi770Q22OuZnyE7VXshXCuJmUTHr4kstvvG9Gb063BLY99g R64SSGZu5OJa0UMm35mSq+HvLkIH7m0psF18dOR9m3xuPvEnpWhNheV2u1mOG9t7qh BpTlcTm89KQSs4zgaeQQm35Ma40/utNxPCe7fEheOWjFYir2RBxmiGOL3SfN2M/nV9 wIAs16HZbB6VtNMoITj1LmJIXtQIWM32Z1e/QxZNMidIQsJ/mJ7iYc5mMc+RrmbC4l AMRDTUkjpbtN7V9syMRm5jhKUNFfIt/QkR2DcIabanKTugfLeddVJfl8NQabd4TLEX xFtKzjtnVsnRQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 3/7] eal_memzone: bail out on initialized Date: Mon, 14 Aug 2023 21:38:22 -0400 Message-Id: <20230815013826.1288972-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 930fee5fdc..c76f298267 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -395,8 +395,12 @@ int rte_eal_memzone_init(void) { struct rte_mem_config *mcfg; + static int initialized = 0; int ret = 0; + if (initialized) + return 0; + /* get pointer to global configuration */ mcfg = rte_eal_get_configuration()->mem_config; @@ -415,6 +419,8 @@ rte_eal_memzone_init(void) rte_rwlock_write_unlock(&mcfg->mlock); + initialized = 1; + return ret; } From patchwork Tue Aug 15 01:38:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130310 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 BD7EE43067; Tue, 15 Aug 2023 03:39:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4091643266; Tue, 15 Aug 2023 03:38:43 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 3DC6643000 for ; Tue, 15 Aug 2023 03:38:38 +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 A954361D91; Tue, 15 Aug 2023 01:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAF0EC433C7; Tue, 15 Aug 2023 01:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063517; bh=gbBQqNrbQOFc+JCFg5nzBx+zAskBFfjxfUgKIPyyn/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F953AbGzx6EE2wuvMiY/SPXfTu3y6rpqEpq7a6pmWA53AEZC9I2n74vyVhgEpZ1SI 9S7aDjTUH8lk/6Ao8xZoWUJic1mO/qGGXYa1/pBIVB30dIqTOdbmk4UM2ijwyD4vsi IRciIWxG6c5JYRsSIYLZbw+1wMlta2Cg4B67z2FEjwMDPTHjVJo3iu8MyLpsuk5LmY o529mq456wqtLJ9UDBgWvpAGD4oD3Kl4d5BxeqgxlTTWEnzz9JfCk/HQZB4/waxgPd tAfhKqz2Hu9f02poicO8m1TIz4cn7WWqWfjpKua52qQ4Wfi/QY2JVt3WdIjrCJGJGn M5OB1dOshvP4w== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 4/7] memseg: init once Date: Mon, 14 Aug 2023 21:38:23 -0400 Message-Id: <20230815013826.1288972-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 60fc8cc6ca..c7bf879d15 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -1902,6 +1902,11 @@ rte_eal_memseg_init(void) { /* increase rlimit to maximum */ struct rlimit lim; + static bool memseg_initialized = 0; + int ret; + + if (memseg_initialized) + return 0; #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES const struct internal_config *internal_conf = @@ -1930,11 +1935,15 @@ 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(); + + memseg_initialized = true; + + return ret; } From patchwork Tue Aug 15 01:38:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130311 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 74AD643067; Tue, 15 Aug 2023 03:39:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C56ED4326F; Tue, 15 Aug 2023 03:38:44 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id AD43043036 for ; Tue, 15 Aug 2023 03:38:38 +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 3AE526133D; Tue, 15 Aug 2023 01:38:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5638AC433CA; Tue, 15 Aug 2023 01:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063517; bh=D81Mme+vg6LTteTrCq5RBoyNOoHKhEG8hMgrs4+14+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5V/+sy2h8X1EaK+JFRHfzPEdC1RHzjQU/LO5CIyqq696F1jHrxPkeW89uTYXKQqd rX768KPoyoQ1Yed4HHMQG4TH8CISmtULXzgcZrB8GvqO3YPazqexpCNvLYbbNMudq3 WZMzPO6nJgmrUOCq9phuPtFZeGCf1nplHeKzOOTuBiHP6/XX8oPvBO9sv0SDMxydfa fNdC83S/F2bnWXT3nlinj+akZzsYtO60eCtO9tyKtTvsklYgX/jgCcBckjDoUqBFY+ ooyAwykQurev0dUzeuikTSkY9wFRTlpyDXYQ92ipQHOcGjTQQTp72MAiPwsSZTqIXN 0oP3Ekrtn2Klw== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 5/7] eal_memory: skip initialization Date: Mon, 14 Aug 2023 21:38:24 -0400 Message-Id: <20230815013826.1288972-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index 688dc615d7..e342eeb806 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -1084,10 +1084,14 @@ rte_eal_memory_init(void) int retval; RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n"); + static int initialized = 0; if (!mcfg) return -1; + if (initialized) + return 0; + /* lock mem hotplug here, to prevent races while we init */ rte_mcfg_mem_read_lock(); @@ -1106,6 +1110,7 @@ rte_eal_memory_init(void) if (internal_conf->no_shconf == 0 && rte_eal_memdevice_init() < 0) goto fail; + initialized = true; return 0; fail: rte_mcfg_mem_read_unlock(); diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 6eb6fcda5e..4c5f8aed0b 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -1405,6 +1405,10 @@ rte_eal_malloc_heap_init(void) unsigned int i; const struct internal_config *internal_conf = eal_get_internal_configuration(); + static int initialized = 0; + + if (initialized) + return 0; if (internal_conf->match_allocations) RTE_LOG(DEBUG, EAL, "Hugepages will be freed exactly as allocated.\n"); @@ -1443,6 +1447,8 @@ rte_eal_malloc_heap_init(void) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + initialized = true; + /* add all IOVA-contiguous areas to the heap */ return rte_memseg_contig_walk(malloc_add_seg, NULL); } From patchwork Tue Aug 15 01:38:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130312 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 D138843067; Tue, 15 Aug 2023 03:39:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F338E43274; Tue, 15 Aug 2023 03:38:45 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 5002643036 for ; Tue, 15 Aug 2023 03:38:39 +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 D400860F8F; Tue, 15 Aug 2023 01:38:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3E84C433C8; Tue, 15 Aug 2023 01:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063518; bh=9zO4GbT0DX01CrTot/ga9uo+cU4znM3HqJDI7z2lsZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aeqop0yto75tVQbe9qvySueyiSi7j63xnROV3STWVjdZgl8AoNGzrut/YubUm6ju4 czYTW5gsTVhr2RH7zIwJ1sK4x6bl9/7mTv3u96uxLUaE5afMiEkuA/w2laeEvyJrST x+rT1tHoN0Cx83FdJpYcmttXtRMDYecnlSEHeGvCyoz57ZF39CH+ChNRZS64AabdNW yIwmAWclZ6cRAB/DhTHyVqhCksxvyjTEhCFzPwW2BR72u5sPUJYa7eEKSN4EZ1ClIU VTSWi50C4TiXKLUZ6OMJhmbwf0cvrQB7fteeaLzQQ//Ec6J6/nmZLjCyxvfXGVLpHO cjX3vy2Gzynfw== From: okaya@kernel.org To: Harman Kalra Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 6/7] eal_interrupts: don't reinitialize threads Date: Mon, 14 Aug 2023 21:38:25 -0400 Message-Id: <20230815013826.1288972-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 Signed-off-by: Sinan Kaya --- lib/eal/linux/eal_interrupts.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index d52ec8eb4c..aa296f153b 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -1174,6 +1174,10 @@ int rte_eal_intr_init(void) { int ret = 0; + static int initialized = 0; + + if (initialized) + return 0; /* init the global interrupt source head */ TAILQ_INIT(&intr_sources); @@ -1196,6 +1200,7 @@ rte_eal_intr_init(void) "Failed to create thread for interrupt handling\n"); } + initialized = true; return ret; } From patchwork Tue Aug 15 01:38:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130313 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 5099A43067; Tue, 15 Aug 2023 03:39:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F0E8F43279; Tue, 15 Aug 2023 03:38:46 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id CDD9843251 for ; Tue, 15 Aug 2023 03:38:39 +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 5D86C6133D for ; Tue, 15 Aug 2023 01:38:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D94C433CA; Tue, 15 Aug 2023 01:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063518; bh=UbZct1QFrYwLo+HTrCgJoL0nQvWSvUSISHA9M4IuOLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+3/9OWuMfd8PDXZFPGhCgzT1DM2iJobiYhOXKm+uwmg50Ym4QpPp/wq4Eml4QHbk AI3vsOAsLjM9ZDp9PLGgDQ5hxaPF4qSUH4CgyVxspjin24BvITcb6r6XQPk0/bozky WNd81qR1WM6L6umnW7BpHo9i6zfVWdZkKHOhYUDfPmCcIfBuauOqKe/Ayyrl8xpMIg ki/751OHX3qfavPs5gp1ug7luZRkSqPFsLJWs+Twa7CVOGzdYv/CZ/xqSnSuJMShCh QYCpZivx3qtSuK5HNdg44vXgobQWnw29qOs7+ZDNaxM+e7ZrS6GaU0d9wx/HkzxJ12 f5+FiIkfZSo0w== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 7/7] eal: initialize worker threads once Date: Mon, 14 Aug 2023 21:38:26 -0400 Message-Id: <20230815013826.1288972-8-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815013826.1288972-1-okaya@kernel.org> References: <20230815013826.1288972-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 Signed-off-by: Sinan Kaya --- lib/eal/linux/eal.c | 68 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 5fd81d71cb..63190a4e70 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1236,46 +1236,50 @@ rte_eal_init(int argc, char **argv) config->main_lcore, (uintptr_t)pthread_self(), cpuset, ret == 0 ? "" : "..."); - RTE_LCORE_FOREACH_WORKER(i) { + static int worker_initialized = 0; + if (worker_initialized == 0) { + 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); - ret = rte_thread_setname(lcore_config[i].thread_id, - thread_name); - if (ret != 0) - RTE_LOG(DEBUG, EAL, - "Cannot set name for lcore thread\n"); + 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); + ret = rte_thread_setname(lcore_config[i].thread_id, + thread_name); + if (ret != 0) + RTE_LOG(DEBUG, EAL, + "Cannot set name for lcore thread\n"); + + ret = pthread_setaffinity_np(lcore_config[i].thread_id, + sizeof(rte_cpuset_t), &lcore_config[i].cpuset); + if (ret != 0) + rte_panic("Cannot set affinity\n"); + } - ret = pthread_setaffinity_np(lcore_config[i].thread_id, - sizeof(rte_cpuset_t), &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 = 1; } - /* - * 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) {