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 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 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 | 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) { -- 2.25.1