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 4295D45D01; Thu, 14 Nov 2024 09:37:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DB9D42D76; Thu, 14 Nov 2024 09:37:27 +0100 (CET) Received: from out203-205-221-236.mail.qq.com (out203-205-221-236.mail.qq.com [203.205.221.236]) by mails.dpdk.org (Postfix) with UTF8SMTP id 8992742D6A for ; Thu, 14 Nov 2024 09:37:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1731573435; bh=FUvYCsCNojjNUIrVj2dlIFTt4pdTQ3huiA06bvhBzXM=; h=From:To:Cc:Subject:Date; b=hhuPIWtjMQYsQsSowmGAz529Ggibd1XmxOs6V8rQvCpCn5ZhBc3/nlwPcSwMAgoVc F6B+zhzNpzfTdjYfS1ARH0aG7+BtCcgar34h9BCMi/hoY1OXnasp/E3YLmdPd/rQE3 7DtuSwW3fQLW/suYBnR8/pRUYZGdTpM0gDJf3TFY= Received: from ubuntu.localdomain ([36.129.28.219]) by newxmesmtplogicsvrsza29-0.qq.com (NewEsmtp) with SMTP id 94D93C9D; Thu, 14 Nov 2024 16:37:13 +0800 X-QQ-mid: xmsmtpt1731573433t5lu7zc3p Message-ID: X-QQ-XMAILINFO: NnA3IMNPwBd+h5LdWZBzAaV/hAZgPvJ8glXhMWy+jh9Y1oUk0Y6ixLmppRD7dE kzIJr+dFFIckgsG89j15PsVNdLJp783Mxq/VRVPaWTugBuXrniUx4MUx94s54CnjOHWLy3lIUAwu KPloMnQ9M0ndsM+hUVHwYRdhv6App1uy32FpzL04YMv/2RtN/ou0XcfEQIEHZIxIBd+kft8xqLzb uvx78LRMgDsWHHPRSGh8ColQPvlPAFBXxXiHnplrvcZya0D7W2nIpWFgLPpLWHHQh1Cc1Ppty6+g pW7W+L178o1oxvWlh6cbrgZGoQJV5kTCmT/u0tqNjDx7vSKCDJ9fQWXAmAWm6muRvycMo+jEyqDB ZDctjWFBKuht3h6Ifeg+DpG+5Wo50w2N2lguE+eBM8Mw2Dbks+ehEwKfxToiF8R65V1uA5OuXM6L FuGwcIsSQMv/wA7LpK6NzLODq0Qec1BMFyWSnGH970FmXZin8gkBrt7K6zaSEYQG85BmvaZBFLnl FjzD6C14HLDQxLncOT4fHB4JowdX8DhsJB2ZKTQjz29ukt3LVNKmGRrkPMCUH/sBv1ZDUJ0Xj1JU vJfY04a78yRYsf/m1rC73dGrlOj2YTyfZsv0Ga7Y6fZ8CxPG0x6G3YWgdZiJzex4BlGI0cj5OOWc NPGuACCHW9dF61B3hoB3FHCSonXuftsmvDsILZPaFTGZuv9PpZnqu79fjo40j0IxwAaJYFY+LpMG 6Rg2KRHk9Pag4jzZ/hyz96hqBuGuXXWinvUg6oyQ/mqyvlSDleCzp71c+BUPkVdf36kYpeYgvlmp 1D/pUcL4r2zz/gUNOsVsIV7l7Brpnh4QlOqvp6K7qknH+NG2Hz8iaKW2QD1R/6isUXfMznfQ7lrS dFCyTexvQnihgp0oy8Ewlswh3M4WBsSV4PrnAzTmFrtkcUdsenV8G8A+cI3TMdl/QnSyMqSWDDDE WKAhJo06T9nB9iygA7yx99n9dNeK2oSEvY0944oPH7GzlBI2E4wugg6u7OtvRu9k7YeBDWoKki+K 7Ka3YzjMpMC0ZhywS4 X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: Congjie Zhou To: dev@dpdk.org Cc: anatoly.burakov@intel.com, Congjie Zhou Subject: [PATCH] eal/linux: redefine the name for rte_fbarray_init() Date: Thu, 14 Nov 2024 16:37:10 +0800 X-OQ-MSGID: <20241114083710.820109-1-zcjie0802@qq.com> X-Mailer: git-send-email 2.34.1 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 add the current time into the name Signed-off-by: Congjie Zhou --- When multiple secondary processes run in different containers, names identified by PIDs are not unique due to the pid namespace. Add current time to redefine a unique name. lib/eal/linux/eal_memalloc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index e354efc..3fae534 100644 --- a/lib/eal/linux/eal_memalloc.c +++ b/lib/eal/linux/eal_memalloc.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef F_ADD_SEALS /* if file sealing is supported, so is memfd */ #include #define MEMFD_SUPPORTED @@ -1430,6 +1431,18 @@ eal_memalloc_sync_with_primary(void) return 0; } +static uint64_t +current_time(void) +{ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == -1) { + EAL_LOG(ERR, "Fail to get current time"); + return -1ULL; + } + uint64_t time_ns = (uint64_t)ts.tv_sec * 1000000000ULL + ts.tv_nsec; + return time_ns; +} + static int secondary_msl_create_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) @@ -1447,8 +1460,8 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl, local_msl = &local_memsegs[msl_idx]; /* create distinct fbarrays for each secondary */ - snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%i", - primary_msl->memseg_arr.name, getpid()); + snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%i_%"PRIx64, + primary_msl->memseg_arr.name, getpid(), current_time()); ret = rte_fbarray_init(&local_msl->memseg_arr, name, primary_msl->memseg_arr.len, -- 2.34.1