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 EC18B45D0B; Fri, 15 Nov 2024 06:32:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F57E42EF2; Fri, 15 Nov 2024 06:32:35 +0100 (CET) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by mails.dpdk.org (Postfix) with ESMTP id 8563142E52 for ; Fri, 15 Nov 2024 06:32:34 +0100 (CET) Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7181a8af549so809384a34.2 for ; Thu, 14 Nov 2024 21:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731648753; x=1732253553; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ZRcdSTo0NIIvp1vn7ZrecpQvz+EUMRGhTeLymtV9WCo=; b=mddhWrydA87AVoQmPIXR8r10hJYIBe4C1WBML5Ezm+tErRV0cDulMrBBPgyFYcUGDM PtEK5VjMcN3MFBpHDqrIH4Bgt524Tz1PEa4ehESySW1BBy5u2Vgos9Oi2pCpAS/Yc+jC g5aw2NKqa4Gl1wAhvXdG/+3cLyHXMUAG5ot6iuIsp5YImkgaFOslzB4hv06nez4iauOl 5S//LTj+sbLLExRFmM6Texlh8b+4E+qzZWGZ2sCsWp4bHJJW+iNPWB7lH2QglYwPYyqa Ggm3SPCO3IgtmV1N5SAZQyPWrq2VoNfM71Fs4wW6tTcsoADHr1Iu7Z2ujv2NCxUL/hFa 9LRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731648753; x=1732253553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZRcdSTo0NIIvp1vn7ZrecpQvz+EUMRGhTeLymtV9WCo=; b=RZ/Ep9G6LbNshqhzO1XHswrfAfS5lzDZMQ29yLvmSdccTQriurVGGQMC5GNfOnDEql 8GmNFrTxvgjPQf2MbQyZimWUEDJf4vtliiVMQT+8CFpfc6uGXEew2PAEidv6Gx9qViPp 2Bj97VSL197E2D2VBMf7yhF6TJmstRn64q5BDyP2QnLb4NTej038ioQ9kxtM9qy0PtSU W+QQYzZuHCfJ7MFKALZ21T8OMlSRtbm5VEq+VWFFdNCIuf0zAFNkl0NFUh9xuVI1DwHx kp5LfEJ513rMThQNlTS5fofKDYsGN9jtrqHPl5CNRKuHdmH54E1sBHut7pYDJ+SJcVeV iTBQ== X-Gm-Message-State: AOJu0YwI7WrF2Nzbfw/bHfcKWHYLsx3k9jpFMHzhyjJfM2WkYj3ysnLc 5JANDRhWkLfGql6WtSlpxBI2dDnVyZ3Q180FBb8mrELH1wXqGzV5vrwoEN5wzOA= X-Google-Smtp-Source: AGHT+IFC7nfEpmBmuss3yoMDbmzQ8aF1qW7/OiD224at0RAF9kkUwrwtXXa5sAmSBMv82huPnOB+PQ== X-Received: by 2002:a05:6830:6003:b0:717:f666:9559 with SMTP id 46e09a7af769-71a7793172bmr1665834a34.9.1731648753323; Thu, 14 Nov 2024 21:32:33 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7f8c1c31b93sm522128a12.22.2024.11.14.21.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 21:32:32 -0800 (PST) Date: Thu, 14 Nov 2024 21:32:31 -0800 From: Stephen Hemminger To: Zhou congjie Cc: dev , "anatoly.burakov" Subject: Re: [PATCH] eal/linux: redefine the name for rte_fbarray_init() Message-ID: <20241114213231.45f89096@hermes.local> In-Reply-To: References: <20241114082459.10a991aa@hermes.local> <20241114090627.65265a75@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Fri, 15 Nov 2024 10:26:00 +0800 Zhou congjie wrote: > On Thu, 14 Nov 2024, Stephen Hemminger wrote: > > > Date: Fri, 15 Nov 2024 01:06:27 > > From: Stephen Hemminger > > To: zcjie0802 > > Cc: dev , anatoly.burakov > > Subject: Re: [PATCH] eal/linux: redefine the name for rte_fbarray_init() > > > > What about using thread id instead? > > > > From d1687ffbf865ba0b2d64c35acd602ca43329691e Mon Sep 17 00:00:00 2001 > > From: Stephen Hemminger > > Date: Thu, 14 Nov 2024 08:48:54 -0800 > > Subject: [PATCH] eal: fix fbarray name with multiple secondary processes > > > > When multiple secondary processes run in different containers, names > > identified by PIDs are not unique due to the pid namespace. > > Add current thread id to the name to be unique. > > > > Fixes: 046aa5c4477b ("mem: add memalloc init stage") > > Cc: anatoly.burakov@intel.com > > > > Reported-by: Congjie Zhou > > Signed-off-by: Stephen Hemminger > > --- > > lib/eal/linux/eal_memalloc.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c > > index e354efc95d..776260e14f 100644 > > --- a/lib/eal/linux/eal_memalloc.c > > +++ b/lib/eal/linux/eal_memalloc.c > > @@ -1447,8 +1447,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_%i", > > + primary_msl->memseg_arr.name, getpid(), rte_sys_gettid()); > > > > ret = rte_fbarray_init(&local_msl->memseg_arr, name, > > primary_msl->memseg_arr.len, > > > > As far as know, the tid is pid independent, so programs in different PID > namespaces may have the same pid and tid. > > For the solution that uses a global counter, I feel it can only be > implemented by adding variables into rte_config or rte_mem_config, which > involves modifying multiple files. Adding the current time would be more > simple. This code is excuted only once when the secondary process is created, so > it will not cause performance issues. The combination of thread id and process id will be unique but there might be issues with some container implementations which will have overlapping pid's (see Docker --pid flag). The TSC is available in all of DPDK via rte_get_tsc_cycles() or use rte_get_timer_cycles(). But you could still have collisions from two containers using hidden pid doing function at same exact time. Not ever likely, but it is possible.