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 A343145D01; Thu, 14 Nov 2024 09:10:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 781CB42D76; Thu, 14 Nov 2024 09:10:53 +0100 (CET) Received: from out162-62-57-87.mail.qq.com (out162-62-57-87.mail.qq.com [162.62.57.87]) by mails.dpdk.org (Postfix) with UTF8SMTP id 2311B42D6A for ; Thu, 14 Nov 2024 09:10:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1731571843; bh=wDVwWhf8x0ecMPqUoGDUknQpf+Q1mNqCcJ9rd7cabSU=; h=From:To:Cc:Subject:Date; b=bn+1eBeKBe/YnCEOaBSVsA84P8yfZPetMKEuo+otGm3Ex7+IPMlcAHrNdB1ayQ0yy r97DKDOa71u7Aq+TkM9mkshjxG0P59atn6JqlhqIZCMDI6rw38seL1rt6OthvWbieL tVCpaQHHKubStZURv5hHBCmlR4kYNdvzE2vanpZs= Received: from ubuntu.localdomain ([36.129.28.219]) by newxmesmtplogicsvrszb16-1.qq.com (NewEsmtp) with SMTP id 2AA36E9D; Thu, 14 Nov 2024 16:10:42 +0800 X-QQ-mid: xmsmtpt1731571842tb76yh7a5 Message-ID: X-QQ-XMAILINFO: OOWntbL6xj16BUOhVjbuxOi08pf8lKj/0s4HOf5ZPHo3AW9VobqOfiq+FCAeBt OogG197Mlt2Op35r3LWc8c8GKEWnnTseUJg4agqJcbbToFQ5PnRe+bkUO9i9qHG1LTJVb/iS+mLM W8BfXK875CyoDGM22EX0RohrKRSh+87qBbvfM40/ipfVcwTiFh2Q9kmJ6bHRE2EkK7h9meqvOYiQ 9qKv2YbPrUGAjhKpIWF09EFyeskBgKX3iOxokOBmdF2HrD3Sy9BgJPSCR3hBewD74osQ4ETVEY/L 5Greut4iPoajC8db0lBvsbTjsKZ40D5D3R7it2TWqjU2dOQPmjr1gu2+jEr8zNcajbpKkfm+OY4H kLWTFRtRS/YrlJaUN36n3pHMD7S2+0oRJ8GaZKyj/XqKYUDEFnVKL34E4PkYAe5CT6x0LVVnQKmM g3mWslpYedYzliRc6MdH8sJdAgXO3PSjsWpMwGoN1rM4Dbk4qSLi1hdZU+oLnxDaDilAx/u5j7SA 6Q1WRZoAM4LnmlVeI/bUvpdrqk/YLooIKtfuZOQzlIQuxlKfP9YubuWx7SFqJm+D9TJpN5OVPin4 0SQWPk8yC51Y+YUwtxz3WQi1BKCCPIhj0xdvX8m6utn6Yfw+VlG6NfL8Duz+n9VgbqGljx0D/aEL /fgqctxX0WNi0hHdkHOG6/3cRPNuJCnv9GEfJGrWJlaLkWFL66V9v4ub9z8i62jEIk4G7JNvWK8Z aN9tRMKcPbVM/EqPJTAYPz8sWLWaEw5YmCEPqWAd9FaaBD5tBVvgc6Ox3wnJUt77RFwedlSKSRzU x51ZuT7udF0m48rvzUuHZ7nNB9tY5oqjXNmqXw9JCGC3IHcnSD2+UbBOQF7ec0VYhaKOk/wwL2GY jfMgJwyYnnNfUdY3xodI1X/4Zv9SWMHxcF8RTG5VYh+Kp4rco5ga6u8TPSgtD9uT5RS7FcZLXH9H m9jrU2bf+Tmvq4gvJKzbdY752T6K5x1MusNn2YcoQ= X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= 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:10:39 +0800 X-OQ-MSGID: <20241114081039.817808-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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index e354efc..017bf67 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,17 @@ 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 +1459,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