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 BD7EE43067; Tue, 15 Aug 2023 03:39:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4091643266; Tue, 15 Aug 2023 03:38:43 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 3DC6643000 for ; Tue, 15 Aug 2023 03:38:38 +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 A954361D91; Tue, 15 Aug 2023 01:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAF0EC433C7; Tue, 15 Aug 2023 01:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692063517; bh=gbBQqNrbQOFc+JCFg5nzBx+zAskBFfjxfUgKIPyyn/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F953AbGzx6EE2wuvMiY/SPXfTu3y6rpqEpq7a6pmWA53AEZC9I2n74vyVhgEpZ1SI 9S7aDjTUH8lk/6Ao8xZoWUJic1mO/qGGXYa1/pBIVB30dIqTOdbmk4UM2ijwyD4vsi IRciIWxG6c5JYRsSIYLZbw+1wMlta2Cg4B67z2FEjwMDPTHjVJo3iu8MyLpsuk5LmY o529mq456wqtLJ9UDBgWvpAGD4oD3Kl4d5BxeqgxlTTWEnzz9JfCk/HQZB4/waxgPd tAfhKqz2Hu9f02poicO8m1TIz4cn7WWqWfjpKua52qQ4Wfi/QY2JVt3WdIjrCJGJGn M5OB1dOshvP4w== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v1 4/7] memseg: init once Date: Mon, 14 Aug 2023 21:38:23 -0400 Message-Id: <20230815013826.1288972-5-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 Initialize memory segments just once and bail out if called multiple times. Signed-off-by: Sinan Kaya --- lib/eal/linux/eal_memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 60fc8cc6ca..c7bf879d15 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -1902,6 +1902,11 @@ rte_eal_memseg_init(void) { /* increase rlimit to maximum */ struct rlimit lim; + static bool memseg_initialized = 0; + int ret; + + if (memseg_initialized) + return 0; #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES const struct internal_config *internal_conf = @@ -1930,11 +1935,15 @@ 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(); + + memseg_initialized = true; + + return ret; } -- 2.25.1