From patchwork Tue Aug 15 03:13:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130314 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 D846F43069; Tue, 15 Aug 2023 05:13:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 803F94325A; Tue, 15 Aug 2023 05:13:14 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 1CE1441104 for ; Tue, 15 Aug 2023 05:13:13 +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 9E8C361320; Tue, 15 Aug 2023 03:13:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B80FCC433C9; Tue, 15 Aug 2023 03:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069192; bh=uz1jG397Ct0CEKGWm8LpRXN6vrsJYn1QUHAv7JsqZIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V71hn285zxxnEnaGQZtHgccf34gkQPqP6iQyFhunT2/VHVYS2EBeeLfHgkPRAtwk8 6q5sWyWLMJkP525767/hI7aYO8sMl5g/EojcGULW+gBmHpJcXQXdUvriJoFDEoHSQT UsGvUS9/fvSSbKPsQ/lWFiZ3nn+GoQ0gJ/9dXGZhvu1i3AEJZdtjhBEnNFxb+/fr8L IR4+oVb+/Lk/i5om6OQClp9FMxWuzghe0MzzKcSos3o0kB+fMalrEB41EZB7dwTZEc AaCLcGTn9Qb4lKplB+tR8BF3T/ag79t7EZxYAR3Mm1nygCrPuKOSwKNKR68fNxNYVD ZwAH/W0mZa9zA== From: okaya@kernel.org To: Cc: dev@dpdk.org, Graham Whyte , Sinan Kaya Subject: [PATCH v2 1/7] eal: fixes for re-initialization issues Date: Mon, 14 Aug 2023 23:13:01 -0400 Message-Id: <20230815031307.1299726-2-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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..e15e8ced5d 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); + + 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 8c118d0d9f..385a3427d4 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; + 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 03:13:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130315 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 667F943069; Tue, 15 Aug 2023 05:13:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDE3E4325D; Tue, 15 Aug 2023 05:13:15 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 9A25341104 for ; Tue, 15 Aug 2023 05:13:13 +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 2756362BC1 for ; Tue, 15 Aug 2023 03:13:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 516D9C433CB; Tue, 15 Aug 2023 03:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069192; bh=P2glLqiw0cUHcsK6See6IMrndxeGT2hiA71Vv1o5lZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nC3vPokuRvKUYMblMbL5d3sxUQnUQohCwREFgJ8zvQLiSw4fTn7c2Dv7UYtIpbkFh edNXEuU9NW5VbLn3s5SIJleCv8QCIBOzx3KllPBIKnti7vmfbNd3VNVvTWV556T2IZ CkPgzibbM9dVmQQfMCqgYX7g3OYjByoALHxFtzB/qUfVocDJsDDBvF1wTRpwYarlW2 ETH3ruG21ggnm9JP7eLuqD8TCHtKm/KoxmJryho95o6D/tu/B4xnaRScezysQk8gLi eKD+v7DgPlQbfZBtRJI7dP6qsGRAk8RMve5nj3Bxfo6A9J0dimw3dZls4xW5DM2neS 3Tw0W1l3fuvVw== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 2/7] tailq: skip init if already initialized Date: Mon, 14 Aug 2023 23:13:02 -0400 Message-Id: <20230815031307.1299726-3-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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:13:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130316 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 08F0743069; Tue, 15 Aug 2023 05:13:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39E304326B; Tue, 15 Aug 2023 05:13:17 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 4D0C441104 for ; Tue, 15 Aug 2023 05:13:14 +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 BB7AF618CD; Tue, 15 Aug 2023 03:13:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0655C433CA; Tue, 15 Aug 2023 03:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069193; bh=lUVb8U2/URRR99Mo1M8wdnr91IxFL31LQZyYe+CgHj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kvc++zjzixFAmL4otGX7FzwkQsDkXcqow+30CTjs+MdZopWd/99jeEJF9ulBZIhBF k+r99tbNoyekrknrCuPzRSSZHOgbx6+FBHC+cIskz5aPD+Czzqv6SAoKB8h2pYJm6u 1Ig8I7/swC+UiM2m8sIZvFKY05yV1dnHw9jvM756VNgOuIVjCAmrFGDJfNmpVAsFqy esrIEnW4wxwsLYcPnYtpMrK90wI/N0BQViqY5hMONouVsoxFTkkMg4vLn3lKkZ0Cu1 tBVtUxdYoHUVXiqU+lmQQKkFoGtnbAW/QiHWhe7qxFIywbHebpDj+E/avdMUpmf1Eg /mrMBfoMbZ7Mg== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 3/7] eal_memzone: bail out on initialized Date: Mon, 14 Aug 2023 23:13:03 -0400 Message-Id: <20230815031307.1299726-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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 930fee5fdc..3a10aa02dd 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; + static inline const struct rte_memzone * memzone_lookup_thread_unsafe(const char *name) { @@ -397,6 +399,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; @@ -415,6 +420,8 @@ rte_eal_memzone_init(void) rte_rwlock_write_unlock(&mcfg->mlock); + memzone_initialized = true; + return ret; } From patchwork Tue Aug 15 03:13:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130317 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 436AD43069; Tue, 15 Aug 2023 05:13:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C90F4326F; Tue, 15 Aug 2023 05:13:18 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id F06134325D for ; Tue, 15 Aug 2023 05:13:14 +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 7F64A62BC1; Tue, 15 Aug 2023 03:13:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93BDDC433C8; Tue, 15 Aug 2023 03:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069193; bh=ZdC2Q3HXCeijxpFXFzJ1TeGigpvZML+ZcEtkNdCQ+aY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F8BNGwm/3/BIuYQRU2NhXIJeUbqnwL9Quk0ivU/UEzda53T2tON1BTp3ILFIcnMD1 gXlljXRB9NOgOMfdwWPk4Wi07d5cdl9vcwph9enKJEdECscg8eTp4gIErxKo0HmqtI Icl58ucP1GCvlg+Ad037CnxG1FdnHVTWLOFAZhnrpxa9PzUvFjCe23b3CzVeRqZVnN WOga3TrvtRccBVaBnErxhZ5izcfjB2Q+8mJ53ZBh3jUoKZgxWcVCcvBPRfJ9YMi8Ym rAsx9kFoZjJpDgXisKZZWGtHopNDzq5Ud/6ODkxSNUoyjtU2swR1Nya6LnN2jssGcW 2UNR6uZQhV6sQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 4/7] memseg: init once Date: Mon, 14 Aug 2023 23:13:04 -0400 Message-Id: <20230815031307.1299726-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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 60fc8cc6ca..b998b366d2 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" @@ -1902,6 +1903,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 = @@ -1930,11 +1935,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:13:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130318 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 499A743069; Tue, 15 Aug 2023 05:13:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CEB5A43273; Tue, 15 Aug 2023 05:13:19 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id D6BD343260 for ; Tue, 15 Aug 2023 05:13:15 +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 3F2F562FA4; Tue, 15 Aug 2023 03:13:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E3C1C433C9; Tue, 15 Aug 2023 03:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069194; bh=LbXbA/fAi7x5JwHXeQ1RzO/syYieIVZwl7zLLfuk3WU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j5WNriBHV9hhN+cTkqzC4isdo+vDXwKMIMVQD7QJ6fp+MSeFwbmNTXDJMl2imOd3F x35qE8udBBdmQgJk4wMIv/tBd8fu/Kdo6v5jHKt6S1eo1FmLohnpJ5PvOrojrINofv xpzDK/lFc/lvFLsZYGNSefOvOCgigdMJQmSXFL7792zusZ7eJ5E/c9zWF4Z2HMoY7n hP/gj+k0IAVWUza7HtLt2xxPjvazAXLl9tUYw31amEPGXO4+YRVWMWuYAZK/FoUf8d Jo4Z+etRea/lKXauITOVPA+2SDiELyAh+ihi8/P0ishY9cOhnxQzdp9b7RQzuGd6IW 9NOr/GneZwzFQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 5/7] eal_memory: skip initialization Date: Mon, 14 Aug 2023 23:13:05 -0400 Message-Id: <20230815031307.1299726-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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 688dc615d7..b6fcc293be 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -39,6 +39,7 @@ static void *next_baseaddr; static uint64_t system_page_sz; +static bool memory_initialized; #define MAX_MMAP_WITH_DEFINED_ADDR_TRIES 5 void * @@ -1088,6 +1089,9 @@ rte_eal_memory_init(void) if (!mcfg) return -1; + if (memory_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; + memory_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..facc16a802 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) { @@ -1406,6 +1408,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"); @@ -1443,6 +1448,8 @@ rte_eal_malloc_heap_init(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:13:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130319 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 713E643069; Tue, 15 Aug 2023 05:13:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB00F43263; Tue, 15 Aug 2023 05:13:20 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 776B743261 for ; Tue, 15 Aug 2023 05:13:16 +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 E3DDF61320; Tue, 15 Aug 2023 03:13:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1DE1C433CA; Tue, 15 Aug 2023 03:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069195; bh=GNIPh54KXGxsfa5ki8tVQulezifKMxoDrO5/n63RvGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nI7KP+3RDcAzPePDYU17l1ckfY+LBnYm8qWFaxKaMS2Nd+xCFvNOXeummKd51dd5v A/k8MxV+WlqGkRpRcZgH+msL/MAtfC85H0ssj6d9bsbRtHz3CeD4VpecIGwfiZ3pJR 1Kr5V5G+SA0d7bThjdOkWKAugKrpPsiy1Mnh0LmWHVEU6ZowNHNxm253WJdlLdTXDf Z3es2vdBB1aoDqrAk4wIqdPT3H8m9QcUV8njo26GjT/Y4HIUlgd4sYs16QCWe+2QVE U3+S+u8jaR6lrwON+h/jA5fDWDzz6Ph3scthtyj4i8Us3LtHEPSlSMQdi+2n9ZJVdJ 0/2zoUXNBpr1Q== From: okaya@kernel.org To: Harman Kalra Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 6/7] eal_interrupts: don't reinitialize threads Date: Mon, 14 Aug 2023 23:13:06 -0400 Message-Id: <20230815031307.1299726-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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 d52ec8eb4c..f141711f12 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:13:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 130320 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 905F243069; Tue, 15 Aug 2023 05:13:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E08843279; Tue, 15 Aug 2023 05:13:22 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 2851043268 for ; Tue, 15 Aug 2023 05:13:17 +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 A9775618CD for ; Tue, 15 Aug 2023 03:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC636C433C7; Tue, 15 Aug 2023 03:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692069196; bh=rga/mfWK9txfZleEC0PNVXGxa2wYApaIHcY7uIUrOT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HJycr2yBvY91ujAFEPJRTdcscSUX57gmFF+Aa+H9ONc6bx9ClRZNTcFqvNhLSnFiy ZA70a6iNuf2guccAdGcAAKGlr10YAYz9KfJxQDXrYfLZUMFSdal/IIIY7KX4awsmrY TEgI7xti3e4hGIK4Kzm6vromL711G44bV3hbWvkBVCnZGdjsA95kICH8YqF62ovNrx WzOewMh1eJWhUZd5PC20pnz+Rb10uGmKSe6QpJtn+EAXSwcrqgxc9eatC+9t7PjHWb xDm7+7ZxJkzR87igsxop5bhT2+4F6poRXOODY4HqvUkMTF4b4FPybObrVdqf5FFzoB ID+WQcHER43KA== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v2 7/7] eal: initialize worker threads once Date: Mon, 14 Aug 2023 23:13:07 -0400 Message-Id: <20230815031307.1299726-8-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815031307.1299726-1-okaya@kernel.org> References: <20230815031307.1299726-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 | 68 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 385a3427d4..d12b438d2b 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -79,6 +79,7 @@ int rte_cycles_vmware_tsc_map; static uint32_t run_once; +static bool worker_initialized; int eal_clean_runtime_dir(void) @@ -1236,46 +1237,49 @@ 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); - 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 = 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) {