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

Yasufumi Ogawa yasufum.o at gmail.com
Wed Oct 30 14:42:16 CET 2019


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.

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 dev mailing list