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 D4DC8A00D7; Thu, 31 Oct 2019 11:06:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6E5A1C1E7; Thu, 31 Oct 2019 11:06:04 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id A0B3A1C1CE; Thu, 31 Oct 2019 11:06:03 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id y24so2490444plr.12; Thu, 31 Oct 2019 03:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qUz0JxF9ZvQVQu4sf1oBiY+YCCb40FSdFngPl8xOzWA=; b=EG8EXk4IJCCZmsagvSQLrv7sYheDNNoKoxyy3memzZTfzdh5Ampxro8Vsu2yA+WvaP xBjTAj0RS/ZA7duA4dy9AXFoMQvSaxYMyAss56EEX0jAXvvoyGMbIso0dDLAvg88+HfD bQzLhqhNyfBIYhPzMZRD+TJROWESu/miPDXjunLNAvpjTPtXCwNHlg8/Mxcvv5KPWMQo SA5mOtlITcKTnMepPbsLnUO5OqfvN6sVXy+RycmyNNFZjUXdtyKGXZKU1bD29R850VE1 lLHXhEee/X+qo3T/hGQoRPb850owIhHdxvIFUedR4cUJW9+srA8TYT0hZOhqSVOK7pWQ A6bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qUz0JxF9ZvQVQu4sf1oBiY+YCCb40FSdFngPl8xOzWA=; b=ioa1PlEi4wOwS9KAsx1xIQqC3/EkFFfwh80p6ZCcxMyJXmgjwPFw9GDEE9P066tJQ7 VOu4S2XhldLreE9/sPghZvZqkSPmrWRZSCoVq75SIGLkk4CZcV+/fTNFrsD9RzCQ9u0O N1509mCBDUPNSqS5ANB3ZaTJBxMOPsvDGRp+tGLh+hTvPybQRSQsGEq4vCCExg1YDzhX 2Np3AaTPMBKu8ekFa7euAGHOBySzMXNPP+hpEHCea71z3DhwkADg14ZBsh1VQ6rl4PdN duUJpfpUyVKein2G3b5ZLosO+EhPrE06fUa/y7QPh7C3+BCpDzfUjSUT9CemwfNLTDf4 mE+A== X-Gm-Message-State: APjAAAXxZASdEtmpx5BGNvv+REkOq6qbLVhPpaZLJd1Y3q4N/eLahs+Z 9DKdBCXafXqh5GY3uzS7wXE= X-Google-Smtp-Source: APXvYqzfZwu/6IqOBoXkG6Du2VgmLN7ho1j2WpY5lEBjiRAJFTx93aPZeQs4NGYKJFyayxBPolHn7Q== X-Received: by 2002:a17:902:9a49:: with SMTP id x9mr5578819plv.330.1572516362658; Thu, 31 Oct 2019 03:06:02 -0700 (PDT) Received: from [172.30.202.27] ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id v17sm5099277pfc.41.2019.10.31.03.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Oct 2019 03:06:02 -0700 (PDT) To: "Ananyev, Konstantin" , "Burakov, Anatoly" , "david.marchand@redhat.com" Cc: "dev@dpdk.org" , "stable@dpdk.org" , Yasufumi Ogawa References: <20190724082031.45546-1-yasufum.o@gmail.com> <20191028080745.43425-1-yasufum.o@gmail.com> <20191028080745.43425-2-yasufum.o@gmail.com> <2601191342CEEE43887BDE71AB97725801A8C71D04@IRSMSX104.ger.corp.intel.com> <591ba077-5e0c-340d-4bd4-a45e80e90f53@gmail.com> <2601191342CEEE43887BDE71AB97725801A8C7300D@IRSMSX104.ger.corp.intel.com> From: Yasufumi Ogawa Message-ID: <5fef8e2a-c819-8dcb-2206-dff5f12a0499@gmail.com> Date: Thu, 31 Oct 2019 19:03:57 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <2601191342CEEE43887BDE71AB97725801A8C7300D@IRSMSX104.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in secondary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >> -----Original Message----- >> From: Yasufumi Ogawa >> Sent: Wednesday, October 30, 2019 1:42 PM >> To: Ananyev, Konstantin ; Burakov, Anatoly ; david.marchand@redhat.com >> Cc: dev@dpdk.org; stable@dpdk.org; Yasufumi Ogawa >> 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 On Behalf Of yasufum.o@gmail.com >>>> Sent: Monday, October 28, 2019 8:08 AM >>>> To: Burakov, Anatoly ; david.marchand@redhat.com >>>> Cc: dev@dpdk.org; stable@dpdk.org; yasufum.o@gmail.com; Yasufumi Ogawa >>>> Subject: [dpdk-dev] [PATCH v5 1/1] fbarray: fix duplicated fbarray file in secondary >>>> >>>> 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 instead of PID only if PID is 1. >>>> >>>> Cc: stable@dpdk.org >>>> >>>> Signed-off-by: Yasufumi Ogawa >>>> --- >>>> 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. 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 >>>