From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit 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) { -- 2.25.1