From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id E75A025D9 for ; Wed, 23 Jan 2019 21:37:44 +0100 (CET) Received: by mail-pg1-f193.google.com with SMTP id d72so1586650pga.9 for ; Wed, 23 Jan 2019 12:37:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RB7SgYjaETrbC+RIHz9F6ChgyWImR+hX5l0XcLmxJrM=; b=z1JuLya3mIm5W9oNBXGq9z9TThJwILBjQ9/WvLuiGn/mYFpbDSeKBzRBiDqt0Pne4C DJKtvtJyYBMEaosFa5jKYhwpK/gOgi617I7umWCgYAKw+OcFtEbSFFryxfkxVuUPohTM 4jcFGPAxK6K1Jo2h/owiUwcx1eBKWYKD2Xl0Ea6p9z5GHUDQOCq07cCY4vWpHjy8UbCG 0xUtK1tLJohK/wFiTWRfO/4bwKbTpoiDEdgLMihkzNQ54EejY8dIpLeU8xj06oysOWPS dkRGbC+GqlDGo3IMFbIY2H8N8TnESJNNczbvkgaoZ5TG6DL1f/HPOwkTZlgJPkNEAbgp i57g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RB7SgYjaETrbC+RIHz9F6ChgyWImR+hX5l0XcLmxJrM=; b=BOT4A4h3HuglCzXj5hz8OqLmGbxFiR4XtWpDSRfururVsMC/l4iii57hAABCgt6pqF xpeEDL720ROzm4zH1SXHkqn0oFFhBzoH7bVzawsdn0LVfiGdboKmDcnDgqgGSLIWAcG7 xIA0O1SBfI/vjeEnD4JooktdU4hOm+lkLFI6oslcIgeswHfIzqK6DSaTNEBysPb20wKx ByvTPDqP/kCuQjd/FqkiZkD3QORpzvWozJt0XU19qrIhON/fMaBs6xqK2ndcvQ1lVr4X oB7rXYxL7KzANlIDooC+GN9t30pBRuh1+Q1laL91uLVf+7FWPhmuY96abCDV7x6S+bwK +KiA== X-Gm-Message-State: AJcUukeuKxEmGRvsVLLGQDVQy+Ii46U9EYVAdOZCBSqWT1vId3etS7Fx j7uA6hgMPUcrEHR9HQy2Ztv7IQ== X-Google-Smtp-Source: ALg8bN5TtCZqhmNgHkQWX8wjeeht2TJ0YHeIMgdpzYoaHU+vkSd4y/BYtu+qushJ8BP4nULZX9uEOA== X-Received: by 2002:a63:5207:: with SMTP id g7mr3414269pgb.253.1548275863822; Wed, 23 Jan 2019 12:37:43 -0800 (PST) Received: from shemminger-XPS-13-9360 ([202.36.179.100]) by smtp.gmail.com with ESMTPSA id t90sm27854202pfj.23.2019.01.23.12.37.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 12:37:43 -0800 (PST) Date: Thu, 24 Jan 2019 09:37:34 +1300 From: Stephen Hemminger To: Ferruh Yigit Cc: dpdk-dev , Thomas Monjalon , Anatoly Burakov Message-ID: <20190124093734.0d3312c2@shemminger-XPS-13-9360> In-Reply-To: <6f4d8c45-4215-e258-49a0-93235806d00d@intel.com> References: <20170711011242.4606-1-stephen@networkplumber.org> <3f48cbd3-1e60-5a92-3929-7ba06e3cc69c@intel.com> <6f4d8c45-4215-e258-49a0-93235806d00d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process 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: , X-List-Received-Date: Wed, 23 Jan 2019 20:37:45 -0000 On Wed, 23 Jan 2019 19:21:03 +0000 Ferruh Yigit wrote: > On 7/12/2017 9:58 AM, jianfeng.tan at intel.com (Tan, Jianfeng) wrote: > >> -----Original Message----- > >> From: Gonzalez Monroy, Sergio > >> Sent: Wednesday, July 12, 2017 3:32 PM > >> To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org > >> Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary > >> process > >> > >> On 12/07/2017 03:45, Tan, Jianfeng wrote: > >>> > >>>> -----Original Message----- > >>>> From: Gonzalez Monroy, Sergio > >>>> Sent: Tuesday, July 11, 2017 7:36 PM > >>>> To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org > >>>> Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary > >>>> process > >>>> > >>>> On 11/07/2017 02:56, Tan, Jianfeng wrote: > >>>>>> -----Original Message----- > >>>>>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen > >>>>>> Hemminger > >>>>>> Sent: Tuesday, July 11, 2017 9:13 AM > >>>>>> To: dev at dpdk.org > >>>>>> Cc: Stephen Hemminger > >>>>>> Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary > >>>>>> process > >>>>>> > >>>>>> The PCI memory resources in the secondary process should be in > >>>>>> the exact same location as the primary process. Otherwise > >>>>>> there is a risk of a stray pointer. > >>>>>> > >>>>>> Not sure if this is right, but it looks like a potential > >>>>>> problem. > >>>>>> > >>>>>> --- > >>>>>> lib/librte_eal/common/eal_common_pci_uio.c | 2 +- > >>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>>>> > >>>>>> diff --git a/lib/librte_eal/common/eal_common_pci_uio.c > >>>>>> b/lib/librte_eal/common/eal_common_pci_uio.c > >>>>>> index 367a6816dcb8..2156b1a436c4 100644 > >>>>>> --- a/lib/librte_eal/common/eal_common_pci_uio.c > >>>>>> +++ b/lib/librte_eal/common/eal_common_pci_uio.c > >>>>>> @@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device > >> *dev) > >>>>>> > >>>>>> void *mapaddr = pci_map_resource(uio_res- > >>>>>>> maps[i].addr, > >>>>>> fd, (off_t)uio_res->maps[i].offset, > >>>>>> - (size_t)uio_res->maps[i].size, 0); > >>>>>> + (size_t)uio_res->maps[i].size, > >>>>>> MAP_FIXED); > >>>>>> /* fd is not needed in slave process, close it */ > >>>>>> close(fd); > >>>>>> if (mapaddr != uio_res->maps[i].addr) { > >>>>>> -- > >>>>>> 2.11.0 > >>>>> +1 for this RFC. I also once encounter such problem, and I use the same > >>>> way to solve it. The addr parameter of mmap() syscall is only a hint instead > >> of > >>>> a must even the VMA is not occupied yet. > >>>>> Thanks, > >>>>> Jianfeng > >>>> How do you know the VMA is not occupied? > >>> I did by check /proc/self/maps. > >>> > >>>> I think the risk here is that the dynamic linker loaded some shared > >>>> library in that VMA, and forcing MAP_FIXED is not a safe solution. > >>>> What I have observed is that Linux will return a different VMA than the > >>>> one hinted when there is already a mapping in the requested/hinted > >> VMA. > >>> IMO, that's not the target of this RFC. The target is to solve the situation (in > >> current primary/secondary model) that kernel will not use the addr even > >> there's no VMA on that addr. This is my understanding, Stephen, please > >> correct me if I'm wrong. > >> > >> The point I was trying to make is, that you do not know if there is a > >> mapping or not in that address, and by using MAP_FIXED it will unmap > >> whatever was in there before. > > > > Oh, I missed that if there's conflict, the existing VMA will be unmapped. That's a bad effect. > > > >> > >> So unless you parse /proc/self/maps and check that the VMA range is not > >> being used, forcing MAP_FIXED is not safe. > >> > >>>> I reckon this is a similar issue as we have with the multi-process model > >>>> when we do not get the VMA requested for the huge-pages. > >>>> AFAIK we do not have a robust solution for this issue other than restart > >>>> the program and hope the dynamic linker does not map anything in the > >> VMA > >>>> ranges that we need to map from the primary. This is also assuming that > >>>> the application does not allocate memory and maps things before calling > >>>> eal_init as it could potentially use VMA ranges that we need in the > >>>> secondary process. > >>> This is another problem. > >> > >> It is the same problem, VMA ranges that we need to map being already used. > > > > Still two problems from my side: > > (1) A VMA already exists on that addr/len range; conflict happens. > > (2) Kernel will not allocate the VMA to DPDK even there is no VMA on that ranges; there's no conflict. > > Hi Stephen, > > Both Sergio & Jianfeng are not active anymore in DPDK, which the discussion > seems was going on with. cc'ed Anatoly. > > Is this RFC still valid? > Should we expect an update on it? > > Thanks, > ferruh > > > > > Thanks, > > Jianfeng > > > >> > >> Thanks, > >> Sergio > >> > >>>> The proposal for new secondary process model would solve these issues: > >>>> http://dpdk.org/ml/archives/dev/2017-May/066147.html > >>> And yes, this might happen to solve the targeted issue in this RFC. But > >> before the new model is out, this patch seems a workable way for the > >> original issue. > >>> > >>> Thanks, > >>> Jianfeng > >>> > >>>> Thanks, > >>>> Sergio > >> > > > > > MAP_FIXED is the wrong solution. If the secondary passes the address it wants, and gets something else that means that is overlapping. The current code returns an error which is the best response.