From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1134-227.mail.aliyun.com (out1134-227.mail.aliyun.com [42.120.134.227]) by dpdk.org (Postfix) with ESMTP id 310E87EC4 for ; Thu, 6 Nov 2014 15:39:26 +0100 (CET) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.02410913|-1; FP=0|0|0|0|0|-1|-1|-1; HT=r41g08149; MF=liang.xu@cinfotech.cn; PH=DW; RN=2; RT=2; SR=0; Received: from WS-web (liang.xu@cinfotech.cn[222.65.239.251]) by r41g06011.xy2.aliyun.com at Thu, 06 Nov 2014 22:48:47 +0800 Date: Thu, 06 Nov 2014 22:48:47 +0800 From: "=?UTF-8?B?5b6Q5Lqu?=" To: "=?UTF-8?B?QnVyYWtvdiwgQW5hdG9seQ==?=" , "dev@dpdk.org" Message-ID: <69a73749-cfb8-43fd-89be-b5d533ad7e8f@cinfotech.cn> X-Mailer: Alimail-Mailagent revision 2667797 MIME-Version: 1.0 References: <1415193919-17361-1-git-send-email-liang.xu@cinfotech.cn> <1415283104-29970-1-git-send-email-liang.xu@cinfotech.cn>, b4328080-b71e-4cb4-b41b-ccdf8523a0ea@alibaba.com In-Reply-To: b4328080-b71e-4cb4-b41b-ccdf8523a0ea@alibaba.com x-aliyun-mail-creator: Webmail4_2670074_M3LTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTBfMCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzM4LjAuMjEyNS4xMTEgU2FmYXJpLzUzNy4zNg==vN Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] =?utf-8?b?562U5aSN77yaW1BBVENIIHYyXSBlYWw6IG1hcCB1aW8g?= =?utf-8?q?resources_after_hugepages_when_the_base=5Fvirtaddr_is_configure?= =?utf-8?q?d=2E?= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: =?UTF-8?B?5b6Q5Lqu?= List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 14:39:29 -0000 When user configure=C2=A0base_virtaddr, we should believe they can take care i= t.=0AIn my case, I always check /proc/xxxx/maps to find a huge free address sp= ace, such as 0x20 0000 0000, to map all the hugepages and uio resource.=C2=A0=0A= ------------------------------------------------------------------=E5=8F=91=E4= =BB=B6=E4=BA=BA=EF=BC=9ABurakov, Anatoly =E5=8F=91=E9= =80=81=E6=97=B6=E9=97=B4=EF=BC=9A2014=E5=B9=B411=E6=9C=886=E6=97=A5(=E6=98=9F=E6= =9C=9F=E5=9B=9B) 22:29=E6=94=B6=E4=BB=B6=E4=BA=BA=EF=BC=9A=E5=BE=90=E4=BA=AE <= liang.xu@cinfotech.cn>=EF=BC=8Cdev@dpdk.org =E4=B8=BB=E3=80=80=E9= =A2=98=EF=BC=9ARE: [PATCH v2] eal: map uio resources after hugepages when the = base_virtaddr is configured.=0AFew nitpicks.=0A=0AStatic variables are always = initialized to 0, so "=3D NULL" isn't necessary, a declaration will suffice. A= lso, we have a macro RTE_PTR_ADD to add numbers to pointers, I think it would = be better to use those. Otherwise, looks fine to me.=0A=0AI still feel uneasy = about depending on nothing being mapped directly after hugepages (perhaps we c= ould do mmap(bar_size) before trying pci_map_resource, and increment requested= _addr until we find a free spot?), but I imagine this case would be quite rare= , so probably it's not worth the added kludge.=0A=0AThanks,=0AAnatoly=0A=0A---= --Original Message-----=0AFrom: lxu [mailto:liang.xu@cinfotech.cn] =0ASent: Th= ursday, November 6, 2014 2:12 PM=0ATo: dev@dpdk.org=0ACc: Burakov, Anatoly=0AS= ubject: [PATCH v2] eal: map uio resources after hugepages when the base_virtad= dr is configured.=0A=0A---=0A lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 29 += +++++++++++++++++++++++++++-=0A 1 file changed, 28 insertions(+), 1 deletion(-= )=0A=0Adiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal= /linuxapp/eal/eal_pci_uio.c=0Aindex 7e62266..a591da3 100644=0A--- a/lib/librte= _eal/linuxapp/eal/eal_pci_uio.c=0A+++ b/lib/librte_eal/linuxapp/eal/eal_pci_ui= o.c=0A@@ -273,6 +273,24 @@ pci_get_uio_dev(struct rte_pci_device *dev, char *d= stbuf,=0A return uio_num;=0A }=0A =0A+static inline const struct rte_memseg *= =0A+get_physmem_last(void)=0A+{=0A+ const struct rte_memseg * seg =3D rte_eal_= get_physmem_layout();=0A+ const struct rte_memseg * last =3D seg;=0A+ unsigned= i =3D 0;=0A+=0A+ for (i=3D0; iad= dr =3D=3D NULL)=0A+ break;=0A+=0A+ if(seg->addr > last->addr)=0A+ last =3D= seg;=0A+=0A+ }=0A+ return last;=0A+}=0A+=0A /* map the PCI resource of a PCI = device in virtual memory */=0A int=0A pci_uio_map_resource(struct rte_pci_devi= ce *dev)=0A@@ -290,6 +308,13 @@ pci_uio_map_resource(struct rte_pci_device *de= v)=0A struct mapped_pci_resource *uio_res;=0A struct pci_map *maps;=0A =0A+ = /* map uio resource into user required virtual address */=0A+ static void * re= quested_addr =3D NULL;=0A+ if (internal_config.base_virtaddr && NULL =3D=3D re= quested_addr) {=0A+ const struct rte_memseg * last =3D get_physmem_last();=0A= + requested_addr =3D (void *)(last->addr_64 + last->len);=0A+ }=0A+=0A dev->= intr_handle.fd =3D -1;=0A dev->intr_handle.type =3D RTE_INTR_HANDLE_UNKNOWN;=0A= =0A@@ -371,10 +396,12 @@ pci_uio_map_resource(struct rte_pci_device *dev)=0A = if (maps[j].addr !=3D NULL)=0A fail =3D 1;=0A else {=0A- mapaddr = =3D pci_map_resource(NULL, fd, (off_t)offset,=0A+ mapaddr =3D pci_map_resou= rce(requested_addr, fd, (off_t)offset,=0A (size_t)maps[j].size);=0A = if (mapaddr =3D=3D NULL)=0A fail =3D 1;=0A+ else if (NULL !=3D request= ed_addr)=0A+ requested_addr =3D (uint8_t *)mapaddr + maps[j].size;=0A }= =0A =0A if (fail) {=0A-- =0A1.9.1 >From anatoly.burakov@intel.com Thu Nov 6 15:54:34 2014 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 23B417E75 for ; Thu, 6 Nov 2014 15:54:31 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 06 Nov 2014 07:02:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,326,1413270000"; d="scan'208";a="618245383" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga001.fm.intel.com with ESMTP; 06 Nov 2014 06:59:25 -0800 Received: from irsmsx107.ger.corp.intel.com (163.33.3.99) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 6 Nov 2014 14:58:10 +0000 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.101]) by IRSMSX107.ger.corp.intel.com ([169.254.10.154]) with mapi id 14.03.0195.001; Thu, 6 Nov 2014 14:58:09 +0000 From: "Burakov, Anatoly" To: lxu , "dev@dpdk.org" Thread-Topic: [PATCH v3] eal: map uio resources after hugepages when the base_virtaddr is configured. Thread-Index: AQHP+dCl0ziZwg+l7UqDsOao12IOWZxTsFEg Date: Thu, 6 Nov 2014 14:58:09 +0000 Message-ID: References: <1415193919-17361-1-git-send-email-liang.xu@cinfotech.cn> <1415285223-7662-1-git-send-email-liang.xu@cinfotech.cn> In-Reply-To: <1415285223-7662-1-git-send-email-liang.xu@cinfotech.cn> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] eal: map uio resources after hugepages when the base_virtaddr is configured. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 14:54:34 -0000 + requested_addr =3D (uint8_t *)mapaddr + maps[j].size; RTE_PTR_ADD? Thanks, Anatoly -----Original Message----- From: lxu [mailto:liang.xu@cinfotech.cn]=20 Sent: Thursday, November 6, 2014 2:47 PM To: dev@dpdk.org Cc: Burakov, Anatoly Subject: [PATCH v3] eal: map uio resources after hugepages when the base_vi= rtaddr is configured. --- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 29 +++++++++++++++++++++++++++= +- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/lin= uxapp/eal/eal_pci_uio.c index 7e62266..3a218d0 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c @@ -273,6 +273,24 @@ pci_get_uio_dev(struct rte_pci_device *dev, char *dstb= uf, return uio_num; } =20 +static inline const struct rte_memseg * +get_physmem_last(void) +{ + const struct rte_memseg * seg =3D rte_eal_get_physmem_layout(); + const struct rte_memseg * last =3D seg; + unsigned i =3D 0; + + for (i=3D0; iaddr =3D=3D NULL) + break; + + if(seg->addr > last->addr) + last =3D seg; + + } + return last; +} + /* map the PCI resource of a PCI device in virtual memory */ int pci_uio= _map_resource(struct rte_pci_device *dev) @@ -290,6 +308,13 @@ pci_uio_map_= resource(struct rte_pci_device *dev) struct mapped_pci_resource *uio_res; struct pci_map *maps; =20 + /* map uio resource into user required virtual address */ + static void * requested_addr; + if (internal_config.base_virtaddr && NULL =3D=3D requested_addr) { + const struct rte_memseg * last =3D get_physmem_last(); + requested_addr =3D RTE_PTR_ADD(last->addr, last->len); + } + dev->intr_handle.fd =3D -1; dev->intr_handle.type =3D RTE_INTR_HANDLE_UNKNOWN; =20 @@ -371,10 +396,12 @@ pci_uio_map_resource(struct rte_pci_device *dev) if (maps[j].addr !=3D NULL) fail =3D 1; else { - mapaddr =3D pci_map_resource(NULL, fd, (off_t)offset, + mapaddr =3D pci_map_resource(requested_addr, fd, (off_t)offset, (size_t)maps[j].size); if (mapaddr =3D=3D NULL) fail =3D 1; + else if (NULL !=3D requested_addr) + requested_addr =3D (uint8_t *)mapaddr + maps[j].size; } =20 if (fail) { -- 1.9.1