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 E5B40A0544; Mon, 20 Jul 2020 13:46:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 188361DBB; Mon, 20 Jul 2020 13:46:11 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F30C91AFB; Mon, 20 Jul 2020 13:46:08 +0200 (CEST) IronPort-SDR: p2GSk1O6I3SyLG+WoylzurnYyUJ2JVKmF9HDRmop922+bANjwHfGWDDj0vzgXyh80FRZt3aWMx IBbDPcF/wsgg== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="147845076" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="147845076" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:46:03 -0700 IronPort-SDR: 6szVQEVXexhzvDdDWvHY/dJ1u5737SdHUR9jbqKZQJ/CpZKLm7iRIbPYWb5IrIeUw3Hyb8vHC1 CTTrpBPw0Weg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="319501000" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.194.218]) ([10.213.194.218]) by fmsmga002.fm.intel.com with ESMTP; 20 Jul 2020 04:46:01 -0700 To: wangyunjian , "dev@dpdk.org" , "david.marchand@redhat.com" Cc: "Lilijun (Jerry)" , xudingke , "stable@dpdk.org" References: <70169443-f475-a632-c1f8-6e993bea726c@intel.com> <34EFBCA9F01B0748BEB6B629CE643AE60D0D8765@DGGEMM533-MBX.china.huawei.com> From: "Burakov, Anatoly" Message-ID: <332ede30-4dae-1fde-b288-25f29469f3e7@intel.com> Date: Mon, 20 Jul 2020 12:46:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <34EFBCA9F01B0748BEB6B629CE643AE60D0D8765@DGGEMM533-MBX.china.huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 1/1] eal/linux: do not create user mem map repeatedly when it exists 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" On 20-Jul-20 3:00 AM, wangyunjian wrote: >> -----Original Message----- >> From: Burakov, Anatoly [mailto:anatoly.burakov@intel.com] >> Sent: Friday, July 17, 2020 10:24 PM >> To: wangyunjian ; dev@dpdk.org; >> david.marchand@redhat.com >> Cc: Lilijun (Jerry) ; xudingke >> ; stable@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH 1/1] eal/linux: do not create user mem map >> repeatedly when it exists >> >> On 17-Jul-20 3:19 PM, Burakov, Anatoly wrote: >>> On 16-Jul-20 2:38 PM, wangyunjian wrote: >>>> From: Yunjian Wang >>>> >>>> Currently, we will create new user mem map entry for the same memory >>>> segment, but in fact it has already been added to the user mem maps. >>>> It's not necessary to create it twice. >>>> >>>> Fixes: 0cbce3a167f1 ("vfio: skip DMA map failure if already mapped") >>>> Cc: stable@dpdk.org >>>> >>>> Signed-off-by: Yunjian Wang >>>> --- >>>>   lib/librte_eal/linux/eal_vfio.c | 7 +++++++ >>>>   1 file changed, 7 insertions(+) >>>> >>>> diff --git a/lib/librte_eal/linux/eal_vfio.c >>>> b/lib/librte_eal/linux/eal_vfio.c index abb12a354..d8a8c39ab 100644 >>>> --- a/lib/librte_eal/linux/eal_vfio.c >>>> +++ b/lib/librte_eal/linux/eal_vfio.c >>>> @@ -1828,6 +1828,13 @@ container_dma_map(struct vfio_config >>>> *vfio_cfg, uint64_t vaddr, uint64_t iova, >>>>           ret = -1; >>>>           goto out; >>>>       } >>>> + >>>> +    /* we don't need create new user mem map entry >>>> +     * for the same memory segment. >>>> +     */ >>>> +    if (errno == EBUSY || errno == EEXIST) >>>> +        goto out; >>>> + >>> >>> I'm not sure i understand this patch. If we get errno, the call has >>> failed, which means we're doing "goto out" from a few lines above. Am >>> i missing something here? >>> >>>>       /* create new user mem map entry */ >>>>       new_map = >> &user_mem_maps->maps[user_mem_maps->n_maps++]; >>>>       new_map->addr = vaddr; >>>> >>> >>> >> >> Oh, i see, the actual functions will set errno and return 0. >> >> I don't think it's an actual issue as compacting will presumably remove the >> extra user mem map anyway. What exactly is being fixed here? Does >> compacting user mem maps not remove the extra entry? > > I read the codes about compacting user mem maps. Currently, the function > only merges adjacent user mem maps and does not remove the same entry. > > How about removing the same entry in the fuction? I would've expected "the same" to be within the definition of "adjacent". Can you confirm that this actually doesn't happen? If so, then yes, probably compacting should do that, instead of relying on an artifact of implementation. > > Thanks > Yunjian > >> >> -- >> Thanks, >> Anatoly -- Thanks, Anatoly