DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Gavin Hu (Arm Technology China)" <Gavin.Hu@arm.com>
To: "Wangyu (Eric)" <seven.wangyu@huawei.com>,
	"Burakov, Anatoly" <anatoly.burakov@intel.com>,
	David Marchand <david.marchand@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"ferruh.yigit@intel.com" <ferruh.yigit@intel.com>,
	Linuxarm <linuxarm@huawei.com>, "humin (Q)" <humin29@huawei.com>,
	"Liyuan (Larry)" <Larry.T@huawei.com>,
	dengxiaofeng <dengxiaofeng@huawei.com>, nd <nd@arm.com>
Subject: Re: [dpdk-dev] 答复: 答复:  [PATCH v2] bus/pci: resolve multiple NICs address conflicts
Date: Tue, 12 Nov 2019 06:37:41 +0000	[thread overview]
Message-ID: <VI1PR08MB53765F807333EA2CBC0DD81B8F770@VI1PR08MB5376.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <78A93308629D474AA53B84C5879E84D24B107AE2@DGGEMM533-MBX.china.huawei.com>

Hi Eric,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Wangyu (Eric)
> Sent: Monday, November 11, 2019 5:38 PM
> To: Burakov, Anatoly <anatoly.burakov@intel.com>; David Marchand
> <david.marchand@redhat.com>
> Cc: dev@dpdk.org; ferruh.yigit@intel.com; Linuxarm
> <linuxarm@huawei.com>; humin (Q) <humin29@huawei.com>; Liyuan
> (Larry) <Larry.T@huawei.com>; dengxiaofeng <dengxiaofeng@huawei.com>
> Subject: [dpdk-dev] 答复: 答复: [PATCH v2] bus/pci: resolve multiple NICs
> address conflicts
> 
> 
> Sorry, I didn't explain it clearly, and I will explain this problem step by step.
> 
> Precondition, we have a 64K page size system and two 82599 NICs. The
> memory required for each NIC is as follows:
> Map0 : size = 0x0000000000400000
> Map1 : size = 0x0000000000004000
> 
> 1. Primary process start, process mmap() first NIC map0, mmap()'s input
> address is 0x8202000000, and output address is 0x8202000000, size is
> 0x0000000000400000, next_addr is 0x8202400000, mmap() executed
> correctly.
> 
> 2. Primary mmap() first NIC map1, mmap()'s input address is 0x8202400000,
> and output address is 0x8202400000, size is 0x0000000000004000,
> next_addr is 0x8202404000, now mmap() applied from 0x8202400000 to
> 0x8202410000 actually(because page size is 64K), and next_addr is
> 0x8202404000, but mmap() executed correctly.
So the problem begins to happen here, next_addr should be equal to: 0x8202400000 + 64K(other than 16K) = 0x8202410000, taking account of the real mapping size(page size).  
> 
> 3. Primary mmap() second NIC map0, mmap()'s input address is
> 0x8202404000, but it's conflict, so output address is 0xffffbcdc0000(system
> assigned), size is 0x0000000000400000, next_addr is 0xffffbd1c0000, now
> the address is abnormal, and mmap() executed correctly.
If the step 2) is correct with the next_addr, this step should go on correctly with addresses.
> 
> 4. Primary mmap() second NIC map1, mmap()'s input address is
> 0xffffbd1c0000, and output address is 0xffffbcdb0000 (system assigned),
> size is 0x0000000000004000, now the address is abnormal, and mmap()
> executed correctly.
> 
> 5. Secondary process start, process mmap() first NIC map0, it's normal.
> 
> 6. Secondary process mmap() first NIC map1, it's normal.
> 
> 7. Secondary process mmap() second NIC map0, mmap()'s input address is
> 0xffffbcdc0000, but it's conflict on secondary process, so we get another
> address, but secondary will check if the input address is equal with output
> address, it's not equal, so secondary will exit with " Cannot mmap device
> resource file %s to address: %p ".
> 
> 
> Now I use (next_addr = RTE_PTR_ALIGN(current.addr + current.len,
> pagesize)) to solve the problem, and it worked. If it is right, I will submit a
> patch later.
> 
> By the way, I made a mistake, the problem won't happen on VFIO, because
> VFIO don't apply for 16K memory, only apply for 4M size(map0).But I think
> VFIO also needs to be modified.
> 
> 
> -----邮件原件-----
> 发件人: Burakov, Anatoly [mailto:anatoly.burakov@intel.com]
> 发送时间: 2019年11月7日 20:25
> 收件人: Wangyu (Eric) <seven.wangyu@huawei.com>; David Marchand
> <david.marchand@redhat.com>
> 抄送: dev@dpdk.org; ferruh.yigit@intel.com; Linuxarm
> <linuxarm@huawei.com>; humin (Q) <humin29@huawei.com>; Liyuan
> (Larry) <Larry.T@huawei.com>; dengxiaofeng <dengxiaofeng@huawei.com>
> 主题: Re: 答复: [dpdk-dev] [PATCH v2] bus/pci: resolve multiple NICs
> address conflicts
> 
> On 07-Nov-19 5:44 AM, Wangyu (Eric) wrote:
> > Hi, Anatoly
> >
> > Thank you for advices. This problem will happen in both VFIO and UIO, I
> will modify both according to your advices and test them.
> >
> > I did some tests with mmap() on my system, when I provided address not
> page-aligned, mmap() could return page-aligned address too, but the code
> will return fault because mmap() return address was not equal with address
> I provided(problem occurs in pci_uio_map_secondary()).
> >
> 
> I still don't understand how do you get addresses aligned on a 16K boundary
> with 64K page size.
> 
> The mapping process is as follows:
> 
> 0) start with max_va_end, or with previous addres + previous len
> 1) reserve virtual area with mmap() (accepts any return address)
> 2) map the BAR with MAP_FIXED (checks return address, but should work
> because we already have that area reserved)
> 
> The error you're referring to would've happened at step 2 (MAP_FIXED with
> unaligned addresses will cause the mmap() to fail), but at that point we
> already have a valid virtual area for the bar. If you get a 16K-aligned page
> address for the BAR, you get it on step 1, not step 2.
> 
> So, if, by your own admission, your mmap() implementation does return a
> 64K-aligned address... What exactly is the issue then? How does your BAR
> end up with an invalid address?
> 
> --
> Thanks,
> Anatoly

  parent reply	other threads:[~2019-11-12  6:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  7:26 [dpdk-dev] " Wangyu (Turing Solution Development Dep)
2019-11-05 14:33 ` David Marchand
     [not found]   ` <D3165BB52137B64493C4E18DC69F10D62C8E7CDC@DGGEMM501-MBX.china.huawei.com>
2019-11-06  6:15     ` [dpdk-dev] 答复: " Wangyu (Eric)
2019-11-06  7:37       ` [dpdk-dev] " David Marchand
2019-11-06 10:35         ` Burakov, Anatoly
     [not found]           ` <D3165BB52137B64493C4E18DC69F10D62C8E903A@DGGEMM501-MBX.china.huawei.com>
2019-11-07  3:17             ` [dpdk-dev] 答复: " Wangyu (Eric)
2019-11-06 11:14         ` [dpdk-dev] " Burakov, Anatoly
     [not found]           ` <D3165BB52137B64493C4E18DC69F10D62C8E9085@DGGEMM501-MBX.china.huawei.com>
2019-11-07  5:44             ` [dpdk-dev] 答复: " Wangyu (Eric)
2019-11-07 12:24               ` Burakov, Anatoly
     [not found]                 ` <D3165BB52137B64493C4E18DC69F10D62C8F159A@dggemm521-mbx.china.huawei.com>
2019-11-11  9:37                   ` [dpdk-dev] 答复: " Wangyu (Eric)
2019-11-11 13:07                     ` Burakov, Anatoly
2019-11-12  6:37                     ` Gavin Hu (Arm Technology China) [this message]
2019-11-06 10:29       ` [dpdk-dev] " Burakov, Anatoly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR08MB53765F807333EA2CBC0DD81B8F770@VI1PR08MB5376.eurprd08.prod.outlook.com \
    --to=gavin.hu@arm.com \
    --cc=Larry.T@huawei.com \
    --cc=anatoly.burakov@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dengxiaofeng@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=humin29@huawei.com \
    --cc=linuxarm@huawei.com \
    --cc=nd@arm.com \
    --cc=seven.wangyu@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).