Skip to contentSkip to conversation

eal: fix use of RTE_PTR_ALIGN_CEIL macro on 32bits system

PATCH In review David Marchand 2 participants 4 messages Feb 28, 2014 – Mar 20, 2014 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 eal: fix use of RTE_PTR_ALIGN_CEIL macro on 32bits system

Build issue reported by Mats Liljegren :

CC eal.o
In file included from /home/lwrt/build/dpdk/lib/librte_eal/linuxapp/eal/eal.c:55:0:
/home/lwrt/build/dpdk/lib/librte_eal/linuxapp/eal/eal.c: In function ‘eal_parse_base_virtaddr’:
/home/lwrt/build/dpdk/i686-default-linuxapp-gcc/include/rte_common.h:133:22:
error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)

                      ^
/home/lwrt/build/dpdk/i686-default-linuxapp-gcc/include/rte_common.h:115:10:
note: in definition of macro ‘RTE_PTR_ALIGN_FLOOR’
  (typeof(ptr))rte_align_floor_int((uintptr_t)ptr, align)
          ^
/home/lwrt/build/dpdk/lib/librte_eal/linuxapp/eal/eal.c:566:9: note:
in expansion of macro ‘RTE_PTR_ALIGN_CEIL’
  addr = RTE_PTR_ALIGN_CEIL(addr, RTE_PGSIZE_2M);
         ^

/home/lwrt/build/dpdk/i686-default-linuxapp-gcc/include/rte_common.h:133:22:
error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)

                      ^
/home/lwrt/build/dpdk/i686-default-linuxapp-gcc/include/rte_common.h:115:46:
note: in definition of macro ‘RTE_PTR_ALIGN_FLOOR’
  (typeof(ptr))rte_align_floor_int((uintptr_t)ptr, align)
                                              ^
/home/lwrt/build/dpdk/lib/librte_eal/linuxapp/eal/eal.c:566:9: note:
in expansion of macro ‘RTE_PTR_ALIGN_CEIL’
  addr = RTE_PTR_ALIGN_CEIL(addr, RTE_PGSIZE_2M);
         ^

cc1: all warnings being treated as errors

RTE_PTR_ALIGN_CEIL return type is the same as what we give it as input. So instead of casting the returned value, cast 'addr' which should be the same as base_virtaddr.

---
 lib/librte_eal/linuxapp/eal/eal.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +2 -2
index db0e15c..72b4dd7 100644
@@ -563,9 +563,9 @@ eal_parse_base_virtaddr(const char *arg)
 #endif
 
 	/* align the addr on 2M boundary */
-	addr = RTE_PTR_ALIGN_CEIL(addr, RTE_PGSIZE_2M);
+	internal_config.base_virtaddr = RTE_PTR_ALIGN_CEIL((uintptr_t)addr,
+	                                                   RTE_PGSIZE_2M);
 
-	internal_config.base_virtaddr = (uintptr_t) addr;
 	return 0;
 }
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/2 mem: fix build on 32bits system

In reply to a message not in the archive

Rebase commit 57c24af85d9eaa81549a212169605b4e2468a29f introduced a build regression for 32bits system.

CC eal_memory.o
/home/marchand/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function ‘rte_mem_virt2phy’:
/home/marchand/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:140:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

  virtual = (uint64_t) virtaddr;
            ^

cc1: all warnings being treated as errors

Rework this patch so that it is equivalent to what we had in 1.5.2.

---
 lib/librte_eal/linuxapp/eal/eal_memory.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
lib/librte_eal/linuxapp/eal/eal_memory.c +6 -8
index 296f172..242f1b3 100644
@@ -131,13 +131,14 @@ phys_addr_t
 rte_mem_virt2phy(const void *virtaddr)
 {
 	int fd;
-	uint64_t page, physaddr, virtual;
-	unsigned long virt_pfn;
 	int page_size;
+	unsigned long virtual;
+	uint64_t page;
+	off_t offset;
 
 	/* standard page size */
 	page_size = getpagesize();
-	virtual = (uint64_t) virtaddr;
+	virtual = (unsigned long) virtaddr;
 
 	fd = open("/proc/self/pagemap", O_RDONLY);
 	if (fd < 0) {
@@ -146,9 +147,7 @@ rte_mem_virt2phy(const void *virtaddr)
 		return (uint64_t) -1;
 	}
 
-	off_t offset;
-	virt_pfn = (unsigned long)virtaddr / page_size;
-	offset = sizeof(uint64_t) * virt_pfn;
+	offset = sizeof(uint64_t) * virtual / page_size;
 	if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
 		RTE_LOG(ERR, EAL, "%s(): seek error in /proc/self/pagemap: %s\n",
 				__func__, strerror(errno));
@@ -166,9 +165,8 @@ rte_mem_virt2phy(const void *virtaddr)
 	 * the pfn (page frame number) are bits 0-54 (see
 	 * pagemap.txt in linux Documentation)
 	 */
-	physaddr = ((page & 0x7fffffffffffffULL) * page_size) + (virtual % page_size);
 	close(fd);
-	return physaddr;
+	return ((page & 0x7fffffffffffffULL) * page_size) + (virtual % page_size);
 }
 
 /*
Signature · 1 line
1.7.10.4
#5 lore raw
In reply to a message not in the archive

28/02/2014 09:21, David Marchand :

Quoted 6 lines

RTE_PTR_ALIGN_CEIL return type is the same as what we give it as input. So instead of casting the returned value, cast 'addr' which should be the same as base_virtaddr.

Acked and applied with title
"mem: fix build of virtual address hinting for 32-bit"

Thank you

Signature · 1 line
Thomas
#4 lore raw

Re: [PATCH 2/2] mem: fix build on 32bits system

In reply to a message not in the archive

28/02/2014 09:21, David Marchand :

Quoted 2 lines

Rebase commit 57c24af85d9eaa81549a212169605b4e2468a29f introduced a build regression for 32bits system.

The commit log of the rebased commit was also wrong for branch 1.6.0. So I've reverted the rebased commit and did a new one. It's better now.

Thank you for reporting

Signature · 1 line
Thomas