From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2EE5BA04A2 for ; Mon, 4 Nov 2019 11:20:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 173D349DF; Mon, 4 Nov 2019 11:20:46 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 6A111378B; Mon, 4 Nov 2019 11:20:42 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Nov 2019 02:20:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,266,1569308400"; d="scan'208";a="402932653" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.92]) ([10.237.220.92]) by fmsmga006.fm.intel.com with ESMTP; 04 Nov 2019 02:20:39 -0800 To: yasufum.o@gmail.com, david.marchand@redhat.com, konstantin.ananyev@intel.com Cc: dev@dpdk.org, stable@dpdk.org, Yasufumi Ogawa References: <20190724082031.45546-1-yasufum.o@gmail.com> <20191101090413.17997-1-yasufum.o@gmail.com> <20191101090413.17997-2-yasufum.o@gmail.com> From: "Burakov, Anatoly" Message-ID: <05605cac-693e-042a-a3cb-6506b1ec653e@intel.com> Date: Mon, 4 Nov 2019 10:20:38 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191101090413.17997-2-yasufum.o@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [PATCH v6 1/1] fbarray: fix duplicated fbarray file in secondary X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On 01-Nov-19 9:04 AM, yasufum.o@gmail.com wrote: > From: Yasufumi Ogawa > > 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: stable@dpdk.org > > Signed-off-by: Yasufumi Ogawa > --- > lib/librte_eal/common/include/rte_fbarray.h | 2 +- > lib/librte_eal/linux/eal/eal_memalloc.c | 11 ++++++++--- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_eal/common/include/rte_fbarray.h b/lib/librte_eal/common/include/rte_fbarray.h > index 6dccdbec9..5c2815093 100644 > --- a/lib/librte_eal/common/include/rte_fbarray.h > +++ b/lib/librte_eal/common/include/rte_fbarray.h > @@ -39,7 +39,7 @@ extern "C" { > #include > #include > > -#define RTE_FBARRAY_NAME_LEN 64 > +#define RTE_FBARRAY_NAME_LEN NAME_MAX > > struct rte_fbarray { > char name[RTE_FBARRAY_NAME_LEN]; /**< name associated with an array */ > diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c > index af6d0d023..24f0275c9 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 hostname[HOST_NAME_MAX] = { 0 }; > > if (msl->external) > return 0; > @@ -1373,9 +1374,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, HOST_NAME_MAX); > + snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s_%d", > + primary_msl->memseg_arr.name, hostname, (int)getpid()); > > ret = rte_fbarray_init(&local_msl->memseg_arr, name, > primary_msl->memseg_arr.len, > I think the order should be reversed. Both containers and non-containers can have their hostname set, and RTE_FBARRAY_NAME_LEN is of fairly limited length, so if the hostname is long enough, the PID never gets into the name string, resulting in duplicates. It is better have pid first. Once that's fixed, Acked-by: Anatoly Burakov -- Thanks, Anatoly