DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Zhou congjie <zcjie0802@qq.com>
Cc: dev <dev@dpdk.org>, "anatoly.burakov" <anatoly.burakov@intel.com>
Subject: Re: [PATCH] eal/linux: redefine the name for rte_fbarray_init()
Date: Thu, 14 Nov 2024 21:32:31 -0800	[thread overview]
Message-ID: <20241114213231.45f89096@hermes.local> (raw)
In-Reply-To: <tencent_3310EA406E96754A8E98DEEC0CA15CF44006@qq.com>

On Fri, 15 Nov 2024 10:26:00 +0800
Zhou congjie <zcjie0802@qq.com> wrote:

> On Thu, 14 Nov 2024, Stephen Hemminger wrote:
> 
> > Date: Fri, 15 Nov 2024 01:06:27
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > To: zcjie0802 <zcjie0802@qq.com>
> > Cc: dev <dev@dpdk.org>, anatoly.burakov <anatoly.burakov@intel.com>
> > 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 <stephen@networkplumber.org>
> > 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 <zcjie0802@qq.com>
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  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.



  reply	other threads:[~2024-11-15  5:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14  8:37 Congjie Zhou
2024-11-14 16:24 ` Stephen Hemminger
2024-11-14 17:06   ` Stephen Hemminger
2024-11-15  2:26     ` Zhou congjie
2024-11-15  5:32       ` Stephen Hemminger [this message]
2024-11-15  1:57   ` Zhou congjie
2024-11-15  2:00   ` Zhou congjie
2024-11-15  7:50 ` [PATCH v2] eal/linux: fix fbarray name with multiple secondary processes Congjie Zhou
  -- strict thread matches above, loose matches on Subject: below --
2024-11-14  8:10 [PATCH] eal/linux: redefine the name for rte_fbarray_init() Congjie Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241114213231.45f89096@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=zcjie0802@qq.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).