> -----Original Message-----
> From: dev <dev-boun...@dpdk.org> On Behalf Of yasufu...@gmail.com
> Sent: Monday, October 28, 2019 8:08 AM
> To: Burakov, Anatoly <anatoly.bura...@intel.com>; david.march...@redhat.com
> Cc: dev@dpdk.org; sta...@dpdk.org; yasufu...@gmail.com; Yasufumi Ogawa 
> <ogawa.yasuf...@lab.ntt.co.jp>
> Subject: [dpdk-dev] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in 
> secondary
> 
> From: Yasufumi Ogawa <ogawa.yasuf...@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: sta...@dpdk.org
> 
> Signed-off-by: Yasufumi Ogawa <yasufu...@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?
 
> +      * 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

Reply via email to