From patchwork Tue Aug 15 14:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130353 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 3730443073; Tue, 15 Aug 2023 16:50:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8AC643251; Tue, 15 Aug 2023 16:50:34 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id BBED641611 for ; Tue, 15 Aug 2023 16:50:32 +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 3B69561CC0; Tue, 15 Aug 2023 14:50:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1FE5C433C8; Tue, 15 Aug 2023 14:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111031; bh=n8tuOsyAXkyfrtIi2nseJZqsKbt9XPCd1HswxhX/EvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=knMiFk1XXNu/fPY+FAqgz8x1duG95Csyv3vqMO8kfRgSbvzRMM+kXfX4qhG00l9iY iChO8Ql5F61WXsiq8O5/HFIjdhb2xnKKOlpcdCa70FVYkz0G6hfxPgNh12he2rEzbm 6FLQoUTd7+STrzd8+VLWLIH3TeZe/9mvziS+F+7kPj8zXmXrl/pA5BhWFz+MNUGQ8C bZpF9LPvsF0Mgdx+eE/WQqxR61Xrpsn1dUYTUGaJZ44SYBPErQhdotaIfM9X4oeCXl M5Un6p/9CYn/Iv5V53Jf+IEM30lCdhZGxkNGZO4G4Tz4Pqx3K2rn0ujt8QgtEgnaJ2 egjF6cnzL1kDg== From: okaya@kernel.org To: Cc: dev@dpdk.org, Stephen Hemminger , Sinan Kaya Subject: [PATCH v4 1/8] eal: cleanup plugins data Date: Tue, 15 Aug 2023 10:50:16 -0400 Message-Id: <20230815145023.1386003-2-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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: Stephen Hemminger When rte_eal_cleanup is called walk through the list of shared objects loaded, and close them and free the data structure. Signed-off-by: Stephen Hemminger Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_options.c | 12 ++++++++++++ lib/eal/common/eal_options.h | 1 + lib/eal/linux/eal.c | 2 ++ 3 files changed, 15 insertions(+) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 062f1d8d9c..209b6edd76 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -244,6 +244,18 @@ eal_save_args(int argc, char **argv) } #endif +void +eal_plugins_cleanup(void) +{ + struct shared_driver *solib, *tmp; + + RTE_TAILQ_FOREACH_SAFE(solib, &solib_list, next, tmp) { + if (solib->lib_handle) + dlclose(solib->lib_handle); + free(solib); + } +} + static int eal_option_device_add(enum rte_devtype type, const char *optarg) { diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h index 3cc9cb6412..ddbaafc4f1 100644 --- a/lib/eal/common/eal_options.h +++ b/lib/eal/common/eal_options.h @@ -105,6 +105,7 @@ int eal_check_common_options(struct internal_config *internal_cfg); void eal_common_usage(void); enum rte_proc_type_t eal_proc_type_detect(void); int eal_plugins_init(void); +void eal_plugins_cleanup(void); int eal_save_args(int argc, char **argv); int handle_eal_info_request(const char *cmd, const char *params __rte_unused, struct rte_tel_data *d); diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index c6efd92014..dee649bab3 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1398,6 +1398,8 @@ rte_eal_cleanup(void) eal_trace_fini(); eal_mp_dev_hotplug_cleanup(); rte_eal_alarm_cleanup(); + eal_plugins_cleanup(); + /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); rte_eal_malloc_heap_cleanup(); From patchwork Tue Aug 15 14:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130354 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 A2C0F43073; Tue, 15 Aug 2023 16:50:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E04EE4325E; Tue, 15 Aug 2023 16:50:35 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 5565E43000 for ; Tue, 15 Aug 2023 16:50:33 +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 D8CFB61693; Tue, 15 Aug 2023 14:50:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6948C433CA; Tue, 15 Aug 2023 14:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111032; bh=1NMAd+IiYHZ0dTvhI2PO7nYtF02pb5JQJk+0oBeNspY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yz8xBVU83o39MGF/iqvPwCzZKszwe1g0Lsu8xGO91O8svV+05nglAe+1qvhtc1K39 Q8YkT2cVsc8B29Rj1NWHTXPLp0HUBMBRoxuaDXa58EyZDUsW8GUYUDcUOpo/u4kMsA o2Fjowrwykr/7dkMp9ddxfyBWueCfRfbV5dD+MtkfY+iJ5UoMHAE6QVku4vJbuR0TQ shSBasUes27K017KbqHSU8+/1FO6e/j+WBJzhj2ECUTaq3K57NpsLKL8DTA96vWyxr /OJ4jcgj1IHYQAMz9nOZbLgwDmB+nMqO+P+IiGf3KUbPRKAhBkcUC4S54IL5aU2RYK in4wIbrdh5jiA== From: okaya@kernel.org To: Cc: dev@dpdk.org, Graham Whyte , Sinan Kaya Subject: [PATCH v4 2/8] eal: fixes for re-initialization issues Date: Tue, 15 Aug 2023 10:50:17 -0400 Message-Id: <20230815145023.1386003-3-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 | 8 ++++++++ lib/eal/linux/eal.c | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 209b6edd76..6042de009d 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -127,6 +127,7 @@ TAILQ_HEAD_INITIALIZER(solib_list); static const char *default_solib_dir = RTE_EAL_PMD_PATH; #endif + /* * Stringified version of solib path used by dpdk-pmdinfo.py * Note: PLEASE DO NOT ALTER THIS without making a corresponding @@ -254,6 +255,13 @@ eal_plugins_cleanup(void) dlclose(solib->lib_handle); free(solib); } + + /* Reinitialize solib_list */ + TAILQ_INIT(&solib_list); + + main_lcore_parsed = 0; + mem_parsed = 0; + core_parsed = 0; } static int diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index dee649bab3..584c78e640 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 14:50:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130355 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 A2C5D43073; Tue, 15 Aug 2023 16:50:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DE8143264; Tue, 15 Aug 2023 16:50:37 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 3F22943036 for ; Tue, 15 Aug 2023 16:50:34 +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 C271961F16 for ; Tue, 15 Aug 2023 14:50:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E5FCC433C9; Tue, 15 Aug 2023 14:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111033; bh=P2glLqiw0cUHcsK6See6IMrndxeGT2hiA71Vv1o5lZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QD/zSi64mSiKYNE6n927vM6UagmwJzWojtPdEukHSHBYdbg+kexZNQ7CQ+BmUF+y7 XNiTPPdyYqlsg2SYmMRO3BttpYgfJsdg41n9BTvucRwtztu6edQuLSwdrA4LgKrvvk XeMac91rk4fN+La6KnPXtK94oi2C7GwxW19qsOB/xDX7+RLH5YzRKP5PWIdA+mq+UF pawhVyv7yG7XXpR2R/XBj+91DR+4CEWMErj6dkTKfB2rjeL4kHp4JbjRWj/txVsUwk jAYWc3la30QzHDTtG9M65Zs6ZuZWtGJo79fKDVA9/n9r1XSKwSbzCrAciumvVHQ7+I n7h9xmr+ClHUg== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 3/8] tailq: skip init if already initialized Date: Tue, 15 Aug 2023 10:50:18 -0400 Message-Id: <20230815145023.1386003-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 14:50:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130356 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 E896443073; Tue, 15 Aug 2023 16:50:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CC1343268; Tue, 15 Aug 2023 16:50:38 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 6F4ED4325B for ; Tue, 15 Aug 2023 16:50:35 +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 001AD61CC0; Tue, 15 Aug 2023 14:50:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0454C433CA; Tue, 15 Aug 2023 14:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111034; bh=joa54IhMnxETGrrAfoMJz218LI2OKvqtobhOYXCZW5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nA5VOWudCihAeirtZ5VIfkWfY2HZUApIJzVmJAl8nY2JFHZDSzflvi6as3h5QI7Ah As11gUo268j01y12vPp/e8sCbgdJ1zrQtYYarV7WvQZ9CneftcP3JyN4uSVsHDUhb4 /2tRZZb5odyhWv+tFlt4+o6xeZ4iqyPDLoEjozbvjfV2sQ2Zcyq4Ck96K681ypaYo+ zqP16qrFPsrqCwHanVbOgxLUhQ8jsEQY9YViry9u7sJEyEyYooMPVx5IEgL2UrlzUI 8LyM4t5GtKVZ7B/DMRmd48F98zZgCpXQoEIfqs7qVyM79z4dCgTv6vOFkCKVi6IEN2 0xT22KJeMsYzQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 4/8] eal_memzone: bail out on initialized Date: Tue, 15 Aug 2023 10:50:19 -0400 Message-Id: <20230815145023.1386003-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 14:50: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: 130357 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 5B1E443073; Tue, 15 Aug 2023 16:51:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CA324326D; Tue, 15 Aug 2023 16:50: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 1CA2243260 for ; Tue, 15 Aug 2023 16:50: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 9B6C36247A; Tue, 15 Aug 2023 14:50:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD147C433C8; Tue, 15 Aug 2023 14:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111035; bh=BT/wIrnsPmQsnhCQmad4ZeSSA7/RGqJvb34EJiS3obo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5IuYutZLVnlHSToLj5+N5KxEInhSExyD1AlHT3wCymCfEztCaZ9q4kPAszohOyci AAVc/M7ddk953c5SCl3HB5zp9QU9wv8/dLdw++rdGsLoLZ21qp48HRDQhoq7yO3XV5 TjgrXjnVxtRRu63L2WtErIHLFHshMsRaLEmy6cXB0iQNj0zPzNbRqypbwNuIl5dJCe PxPrujhZBUpOOIT2c/3HX7KwQTcAdB3yEedtZ45fLgDk4nLnr3lZnwRC/uOQqs726q qF3CgxQGL3wSeVCPM7NmFpR7B4MYd1wijyt153hNnGUg+BxlB8PG7sSQOiIxLSjmQ/ EaBeT+DBTml9Q== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 5/8] memseg: init once Date: Tue, 15 Aug 2023 10:50:20 -0400 Message-Id: <20230815145023.1386003-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 14:50: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: 130358 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 7446543073; Tue, 15 Aug 2023 16:51:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 355B143273; Tue, 15 Aug 2023 16:50:40 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id D1DDD43260 for ; Tue, 15 Aug 2023 16:50: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 616A663286; Tue, 15 Aug 2023 14:50:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6973CC433CA; Tue, 15 Aug 2023 14:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111035; bh=8KfylMDNAAMf/4PTvAvXfM+LCTHBDpSbwxGnQ2N4shA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=udDMdlnqo9y+IQkYkrskPWv0L60GFuW4xHo74+jXsKVmt5MKRpEmlvZ3fJ6MR+0yr +PXchKRof3HVbOJwvTvNzZh+vKFMqRYU82J85AVIWDIxeGr3qzccmzBOSfudc+6Ylo 4MECYXjWohvX98Dj4gLURzto4gQe3qFq4On1dACoUV44mgNqztPD9EF6ysfb3u77Ys kOu1KvQ9IxTEFsv3Q98mKfGcMtWmfao81enHgNd1fjn/xh9tipnVdkbfVgNb13i/wK 1Z2FpFTA8oFtnepHu1QWvUgP/6YcxLgIUjHSPjbDxJKldi6dRXCg9ndmp64sijcgqR AnEiPDMwAYOUA== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 6/8] eal_memory: skip initialization Date: Tue, 15 Aug 2023 10:50:21 -0400 Message-Id: <20230815145023.1386003-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 14:50: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: 130359 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 00A4743073; Tue, 15 Aug 2023 16:51:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42C3C43278; Tue, 15 Aug 2023 16:50: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 7C7E143260 for ; Tue, 15 Aug 2023 16:50: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 0BB9161F16; Tue, 15 Aug 2023 14:50:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1367DC433C8; Tue, 15 Aug 2023 14:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111036; bh=IrVYOfiG9DbtfdWC88+Xh5SLmYrqkmLt9PPWkrhFzaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/h+UlrNRKLwY1GI1zlKnkxMYtnI8EHFgl6pcXh8n6+4MfMXiMdFgo67PgzH9Agxw Gbccbv+NtTM+4Cy0wBpVJu6TUP4m+xzloAaryhqJn1zBywxABgKQ7uzk7Qi+37bSbt 2abKMESNQCy4pMR+N6zOeFUlKMmb1qGBTG37+vb9EfVAd6/4/MOpa1dnBI/a7guDOg OxSzQMuBehYYQvbxXa6Q6XiM04uuod3zn/a+yM9xK0uFVB2nJZGvNblhhmyhMx/qoe +q6bePI/AOht/WLOeMLEJY+/B8ka89LTHtOiLvUeu4WeW0Cu8xbYyminsy2vjE16ZN WipS/Vzl4kOYg== From: okaya@kernel.org To: Harman Kalra Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 7/8] eal_interrupts: don't reinitialize threads Date: Tue, 15 Aug 2023 10:50:22 -0400 Message-Id: <20230815145023.1386003-8-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 14:50: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: 130360 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 8C57043073; Tue, 15 Aug 2023 16:51:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A9324327A; Tue, 15 Aug 2023 16:50: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 107B843269 for ; Tue, 15 Aug 2023 16:50: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 9277561CC0 for ; Tue, 15 Aug 2023 14:50:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B31A7C433CA; Tue, 15 Aug 2023 14:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692111037; bh=GzdZY5BWZC5AIM3DNvKug6teVg99pRVvPOQuNBaih7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxrDLXt/3m9ej50m7GR3oXnTMtTQ7CBZi9hNFpQ3mA9nf1YChnKRQjCH9eACRkSj6 /mQqDw4u6U3gz0oKEoRk6DwMcaFufXJeFynV2GUKetU4HRJh0DB91le18UK6a22+4o oQgsybqEIKNqnPAQ1jCa2xFzQ52+AyMuHQKaUU9lWAx4CMcsWiNZHDNO8vpZoJmF5j hl8vjR63jF0zEEDVD7ylRa9daZl0taRFvsKiyG8c75jQQgqpjdLK1YU0rwN1BaOoD/ ti0MEOLfLaqavVerH/lWkRuvocCk4TfQbSqFtgiXNzLj9UtJF0hl3kYnKnt9v5pawR R3WSqKE+R8+rA== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v4 8/8] eal: initialize worker threads once Date: Tue, 15 Aug 2023 10:50:23 -0400 Message-Id: <20230815145023.1386003-9-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815145023.1386003-1-okaya@kernel.org> References: <20230815145023.1386003-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 584c78e640..1305e1df54 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) {