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 CD4BBA04F9; Fri, 10 Jan 2020 08:31:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A597E1E555; Fri, 10 Jan 2020 08:31:03 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 8BD191E553; Fri, 10 Jan 2020 08:31:01 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2020 23:31:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,415,1571727600"; d="scan'208";a="272321688" Received: from jguo15x-mobl.ccr.corp.intel.com (HELO [10.67.68.137]) ([10.67.68.137]) by FMSMGA003.fm.intel.com with ESMTP; 09 Jan 2020 23:30:57 -0800 To: Fang TongHao , thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: cunming.liang@intel.com, dev@dpdk.org, stable@dpdk.org References: <20200109122710.1362-1-fangtonghao@sangfor.com.cn> From: Jeff Guo Message-ID: Date: Fri, 10 Jan 2020 15:30:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <20200109122710.1362-1-fangtonghao@sangfor.com.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH] ethdev: fix secondary process change share memory 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" hi, tonghao On 1/9/2020 8:27 PM, Fang TongHao wrote: > Hi all,I am from Sangfor Tech.I found a bug when using DPDK in > multiprocess scenario.The secondary process enters > "rte_eth_dev_pci_copy_info" function when initializing.Then it > sets the value of struct "rte_eth_dev_data.dev_flags" to zero, > but this struct is shared by primary process and secondary > process, and the value change is unexpected by primary process. > This may cause very serious damage.I think > the secondary process should not enter "rte_eth_dev_pci_copy_info" > function or changes the value of struct "rte_eth_dev_data.dev_flags" > in shared memory. > I fixed this bug by adding an if-statement to forbid the secondary > process changing the above-mentioned value. > Thansk, All. i think the format of commit log should be refined to be more formal like as below. what do you think? ethdev: XXXXXXXXX XXXXXXXX > Signed-off-by: Fang TongHao if it is a fix, suggest to add the line as "Fixes: XXXXXXXX ("ethdev: XXXXXXX") to trace it. > --- > lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) > > diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h > index ccdbb46ec..916de8a14 100644 > --- a/lib/librte_ethdev/rte_ethdev_pci.h > +++ b/lib/librte_ethdev/rte_ethdev_pci.h > @@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, > } > > eth_dev->intr_handle = &pci_dev->intr_handle; > - > - eth_dev->data->dev_flags = 0; > - if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) > - eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; > - if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV) > - eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV; > - > - eth_dev->data->kdrv = pci_dev->kdrv; > - eth_dev->data->numa_node = pci_dev->device.numa_node; > + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > + eth_dev->data->dev_flags = 0; > + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) > + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; > + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV) > + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV; > + > + eth_dev->data->kdrv = pci_dev->kdrv; > + eth_dev->data->numa_node = pci_dev->device.numa_node; From the change log, you said that "rte_eth_dev_data.dev_flags" should not be touched by secondary process, but you don't mention about data->kdrv and data->numa_node, could you also explain them in the log if they need to process as the same. > + } > } > > static inline int