> -----Original Message-----
> From: yasufu...@gmail.com <yasufu...@gmail.com>
> Sent: Wednesday, November 13, 2019 9:44 PM
> To: Burakov, Anatoly <anatoly.bura...@intel.com>; david.march...@redhat.com; 
> Ananyev, Konstantin <konstantin.anan...@intel.com>
> Cc: dev@dpdk.org; sta...@dpdk.org; yasufu...@gmail.com; Yasufumi Ogawa 
> <ogawa.yasuf...@lab.ntt.co.jp>
> Subject: [PATCH v7 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 in addition to PID.
> 
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Yasufumi Ogawa <yasufu...@gmail.com>
> ---
>  lib/librte_eal/linux/eal/eal_memalloc.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c 
> b/lib/librte_eal/linux/eal/eal_memalloc.c
> index af6d0d023..11de6d4d6 100644
> --- a/lib/librte_eal/linux/eal/eal_memalloc.c
> +++ b/lib/librte_eal/linux/eal/eal_memalloc.c
> @@ -1365,6 +1365,12 @@ 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 hostname[HOST_NAME_MAX+1] = { 0 };
> +     /* filename of secondary's fbarray is defined such as
> +      * "fbarray_memseg-1048576k-0-0_PID_HOSTNAME" and length of PID
> +      * can be 7 digits maximumly.
> +      */
> +     int fbarray_sec_name_len = 32 + 7 + 1 + HOST_NAME_MAX + 1;

Not sure, why do we need this calculation at all?
Konstantin


> 
>       if (msl->external)
>               return 0;
> @@ -1373,9 +1379,13 @@ secondary_msl_create_walk(const struct rte_memseg_list 
> *msl,
>       primary_msl = &mcfg->memsegs[msl_idx];
>       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());
> +     /* Create distinct fbarrays for each secondary by using PID and
> +      * hostname. The reason why using hostname is because PID could be
> +      * duplicated among secondaries if it is launched in a container.
> +      */
> +     gethostname(hostname, sizeof(hostname));
> +     snprintf(name, fbarray_sec_name_len, "%s_%d_%s",
> +                     primary_msl->memseg_arr.name, (int)getpid(), hostname);
> 
>       ret = rte_fbarray_init(&local_msl->memseg_arr, name,
>               primary_msl->memseg_arr.len,
> --
> 2.17.1

Reply via email to