From: "=?UTF-8?B?5b6Q5Lqu?=" Subject: =?utf-8?b?562U5aSN77yaW1BBVENIIHYyXSBlYWw6IG1hcCB1aW8g?= =?utf-8?q?resources_after_hugepages_when_the_base=5Fvirtaddr_is_configure?= =?utf-8?q?d=2E?= Date: Thu, 06 Nov 2014 22:48:47 +0800 Message-ID: <69a73749-cfb8-43fd-89be-b5d533ad7e8f@cinfotech.cn> 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 Reply-To: =?UTF-8?B?5b6Q5Lqu?= Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable To: "=?UTF-8?B?QnVyYWtvdiwgQW5hdG9seQ==?=" , "dev-VfR2kkLFssw@public.gmane.org" Return-path: In-Reply-To: b4328080-b71e-4cb4-b41b-ccdf8523a0ea-ucjhinso5X1BDgjK7y7TUQ@public.gmane.org List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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-uqgZSDCUmcY3TOWNJCPdyQ@public.gmane.org>=EF=BC=8Cdev-VfR2kkLFssw@public.gmane.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-uqgZSDCUmcY3TOWNJCPdyQ@public.gmane.org] =0ASent: Th= ursday, November 6, 2014 2:12 PM=0ATo: dev-VfR2kkLFssw@public.gmane.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