From patchwork Thu Aug 17 04:28: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: 130453 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 1C4204308A; Thu, 17 Aug 2023 06:28:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D8FB143267; Thu, 17 Aug 2023 06:28:31 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id B506F410D0 for ; Thu, 17 Aug 2023 06:28:27 +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 448F862E32; Thu, 17 Aug 2023 04:28:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 596E6C433CA; Thu, 17 Aug 2023 04:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692246506; bh=LCgNRWw+NaeAfKr+FygHvSDIdvxdtFfV8NTcZlsfUXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y25EXjRjgDNXhnhT1U+mYkb1E5lTri+h7yq//FTJAjdqOLzURpeBTHXuMt/a3DJrC hRnpt+4ieD/R0Ddlf0eDcpoPw/oOVnba78EranH6sG69/TYxt5CuBfh9cfCQJdQ75X ll3YSAYBtRKUMR2010Ivo+GZ+QOVa8gHRpTkHTA4uYKW5alj5BuZv5adr8wmKJVZ0N Osn8kNthHxJ5xnV3DyPJfWGUWpkSOjcHCWLGpHJTwQ+bdMDBZ/JngDUHz8XyAVmt5g 9TAfe6LszsL/wE/kAhC7zMHPaIbuX9/tH3nnGlXz5c91By5pm4Ql9WU4MZnGcWL4AP ZxwbaFiZjUX3A== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v5 05/10] memseg: init once Date: Thu, 17 Aug 2023 00:28:16 -0400 Message-Id: <20230817042820.137957-6-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 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..693a56649b 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -1920,6 +1920,11 @@ rte_eal_memseg_init(void) { /* increase rlimit to maximum */ struct rlimit lim; + int ret; + static bool run_once; + + if (run_once) + 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) + run_once = true; + + return ret; }