[dpdk-stable] [dpdk-dev] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in secondary

Ananyev, Konstantin konstantin.ananyev at intel.com
Thu Oct 31 11:32:50 CET 2019


> >> -----Original Message-----
> >> From: Yasufumi Ogawa <yasufum.o at gmail.com>
> >> Sent: Wednesday, October 30, 2019 1:42 PM
> >> To: Ananyev, Konstantin <konstantin.ananyev at intel.com>; Burakov, Anatoly <anatoly.burakov at intel.com>;
> david.marchand at redhat.com
> >> Cc: dev at dpdk.org; stable at dpdk.org; Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
> >> Subject: Re: [dpdk-dev] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in secondary
> >>
> >> On 2019/10/29 21:03, Ananyev, Konstantin wrote:
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: dev <dev-bounces at dpdk.org> On Behalf Of yasufum.o at gmail.com
> >>>> Sent: Monday, October 28, 2019 8:08 AM
> >>>> To: Burakov, Anatoly <anatoly.burakov at intel.com>; david.marchand at redhat.com
> >>>> Cc: dev at dpdk.org; stable at dpdk.org; yasufum.o at gmail.com; Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
> >>>> Subject: [dpdk-dev] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in secondary
> >>>>
> >>>> From: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
> >>>>
> >>>> In secondary_msl_create_walk(), it creates a file for fbarrays with its
> >>>> PID for reserving unique name among secondary processes. However, it
> >>>> does not work if several secondaries run as app containers because each
> >>>> of containerized secondary has PID 1, and failed to reserve unique name
> >>>> other than first one. To reserve unique name in each of containers, use
> >>>> hostname instead of PID only if PID is 1.
> >>>>
> >>>> Cc: stable at dpdk.org
> >>>>
> >>>> Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
> >>>> ---
> >>>>    lib/librte_eal/linux/eal/eal_memalloc.c | 15 +++++++++++++--
> >>>>    1 file changed, 13 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
> >>>> index af6d0d023..699079791 100644
> >>>> --- a/lib/librte_eal/linux/eal/eal_memalloc.c
> >>>> +++ b/lib/librte_eal/linux/eal/eal_memalloc.c
> >>>> @@ -1365,6 +1365,7 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl,
> >>>>    	struct rte_memseg_list *primary_msl, *local_msl;
> >>>>    	char name[PATH_MAX];
> >>>>    	int msl_idx, ret;
> >>>> +	char proc_id[HOST_NAME_MAX] = { 0 };
> >>>>
> >>>>    	if (msl->external)
> >>>>    		return 0;
> >>>> @@ -1374,8 +1375,18 @@ 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());
> >>>> +	/* If run secondary in a container, the name of fbarray file should
> >>>> +	 * not be decided with pid because getpid() always returns 1.
> >>>
> >>>
> >>> I wonder why is that?
> >>> What will prevent user to do something like:
> >>> docker run -it --cpuset-cpus=7-8 -v /local/kananye1:/local/kananye1 ubuntu-dpdk-local:latest /bin/bash
> >>> And then start dpdk app manually within the container?
> >> Hi Konstantin,
> >>
> >> Thank you for your comment.
> >>
> >> My concern is running secondary as app container. In current
> >> implementation, the name of fbarray file is decided by using PID and it
> >> must be overlapped with other process because assigning PID is started
> >> from 1 in each of app container. This patch is to fix the issue.
> >>
> >> I think it is doable running app from bash for testing, but not
> >> acceptable for a realistic usecase in which user manages several app
> >> containers.
> >
> > User can have a bash script to start inside container first, that
> > would do some preparation work (setup env variables, etc.)....
> > Or some different scenario when user needs/wants to
> > spawn several processes within container.
> I don't know how to avoid to overlap PID from bash script because I
> think PIDs on host cannot see from inside of a container. So, I'm not
> sure it is possible.
> 
> > Inside the lib you can't assume that your usage scenario is the
> > only possible one.
> I don't want to modify it for a specific usecase, but just to avoid to
> overlap filenames. I think it is better this filename is decided by lib
> itself without any of user configuration because user don't need to care
> about the file which is used by DPDK internally.
> 
> > I think solution needs to be generic enough to cover all such cases.
> 
> > BTW, why we can't always use hostname in fbarray format?
> Sorry, I don't know. But I wonder using PID is more assured to get
> unique name, but does not work only for secondary app container
> accidentally.


My thought was - probably we always can use the same format:
snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s_%u",
	primary_msl->memseg_arr.name,  gethostname(), getpid());
to fix that problem?

Konstantin


> 
> Yasufumi
> >
> >>
> >> Regards,
> >> Yasufumi
> >>
> >>>
> >>>> +	 * In docker, hostname is assigned as a short form of full container
> >>>> +	 * ID. So use hostname as unique ID among containers instead.
> >>>> +	 */
> >>>> +	if (getpid() == 1)
> >>>> +		gethostname(proc_id, HOST_NAME_MAX);
> >>>> +	else
> >>>> +		sprintf(proc_id, "%d", (int)getpid());
> >>>> +
> >>>> +	snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s",
> >>>> +			primary_msl->memseg_arr.name, proc_id);
> >>>>
> >>>>    	ret = rte_fbarray_init(&local_msl->memseg_arr, name,
> >>>>    		primary_msl->memseg_arr.len,
> >>>> --
> >>>> 2.17.1
> >>>


More information about the stable mailing list