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