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 A499A4308A; Thu, 17 Aug 2023 06:28:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85AA84325E; Thu, 17 Aug 2023 06:28:29 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 83340410D0 for ; Thu, 17 Aug 2023 06:28:26 +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 0DBCA63598 for ; Thu, 17 Aug 2023 04:28:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31FA3C433CA; Thu, 17 Aug 2023 04:28:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692246505; bh=P2glLqiw0cUHcsK6See6IMrndxeGT2hiA71Vv1o5lZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IwIaLEQnzlw5FMhfj2go/2IPbWGyCU96BeJOXIienGneQg+BeIMpaCNhWkbrckZD9 NU4BPLYTJJPFq96aOJmc2+Lk+gWSUFtZgixtWYYmkgKuMnsA6yI76Q790F2SIW/ozr U6W/m3oOy8IdAnvgoVtzofOgoJ1ey1DMZW7qbpZn7TP701JfD4csffjdInFIDzHg6f EocD3kCvH1ttyi3Cv7/l1/4ObXeE2t4o4gkjdvcw851sXGTHja5invhrZ/5/O+FnzU IgLP7x/YouS7BIPdAkqpJSx88AicRT7foC65MBhEjw5vwieL7ZYnSCcHX5+MizrZrh jua5lYyKudYFg== From: okaya@kernel.org To: Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v5 03/10] tailq: skip init if already initialized Date: Thu, 17 Aug 2023 00:28:14 -0400 Message-Id: <20230817042820.137957-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230817042820.137957-1-okaya@kernel.org> References: <20230817042820.137957-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