From 53a9ca3c570311a8e729cf86ea5a3da0a2520e8e Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Thu, 20 Mar 2014 12:15:23 +0100 Subject: [PATCH] mem: revert "get physical address of any pointer" This reverts commit 57c24af85d9eaa81549a212169605b4e2468a29f which was wrongly rebased in 1.6.0 branch: - commit log must be changed for 1.6.0 - it breaks building for 32-bit A new version of this commit has to be done. --- lib/librte_eal/common/include/rte_memory.h | 22 --------------- lib/librte_eal/linuxapp/eal/eal_memory.c | 33 ++++++---------------- 2 files changed, 9 insertions(+), 46 deletions(-) diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h index 4f04f4a9d1..4ae3bf75a7 100644 --- a/lib/librte_eal/common/include/rte_memory.h +++ b/lib/librte_eal/common/include/rte_memory.h @@ -73,7 +73,6 @@ enum rte_page_sizes { #define __rte_cache_aligned __attribute__((__aligned__(CACHE_LINE_SIZE))) typedef uint64_t phys_addr_t; /**< Physical address definition. */ -#define RTE_BAD_PHYS_ADDR ((phys_addr_t)-1) /** * Physical memory segment descriptor. @@ -98,27 +97,6 @@ struct rte_memseg { #endif } __attribute__((__packed__)); -/** - * Lock page in physical memory and prevent from swapping. - * - * @param virt - * The virtual address. - * @return - * 0 on success, negative on error. - */ -int rte_mem_lock_page(const void *virt); - -/** - * Get physical address of any mapped virtual address in the current process. - * It is found by browsing the /proc/self/pagemap special file. - * The page must be locked. - * - * @param virt - * The virtual address. - * @return - * The physical address or RTE_BAD_PHYS_ADDR on error. - */ -phys_addr_t rte_mem_virt2phy(const void *virt); /** * Get the layout of the available physical memory. diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 296f17272c..39b2d48991 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -61,7 +61,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define _FILE_OFFSET_BITS 64 #include #include #include @@ -114,30 +113,16 @@ static uint64_t baseaddr_offset; #define RANDOMIZE_VA_SPACE_FILE "/proc/sys/kernel/randomize_va_space" -/* Lock page in physical memory and prevent from swapping. */ -int -rte_mem_lock_page(const void *virt) -{ - unsigned long virtual = (unsigned long)virt; - int page_size = getpagesize(); - unsigned long aligned = (virtual & ~ (page_size - 1)); - return mlock((void*)aligned, page_size); -} - -/* - * Get physical address of any mapped virtual address in the current process. - */ -phys_addr_t -rte_mem_virt2phy(const void *virtaddr) +static uint64_t +get_physaddr(void * virtaddr) { int fd; - uint64_t page, physaddr, virtual; + uint64_t page, physaddr; unsigned long virt_pfn; int page_size; /* standard page size */ page_size = getpagesize(); - virtual = (uint64_t) virtaddr; fd = open("/proc/self/pagemap", O_RDONLY); if (fd < 0) { @@ -166,7 +151,7 @@ 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); + physaddr = ((page & 0x7fffffffffffffULL) * page_size); close(fd); return physaddr; } @@ -182,8 +167,8 @@ find_physaddrs(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi) phys_addr_t addr; for (i = 0; i < hpi->num_pages[0]; i++) { - addr = rte_mem_virt2phy(hugepg_tbl[i].orig_va); - if (addr == RTE_BAD_PHYS_ADDR) + addr = get_physaddr(hugepg_tbl[i].orig_va); + if (addr == (phys_addr_t) -1) return -1; hugepg_tbl[i].physaddr = addr; } @@ -508,9 +493,9 @@ remap_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi) rte_snprintf(hugepg_tbl[page_idx].filepath, MAX_HUGEPAGE_PATH, "%s", filepath); - physaddr = rte_mem_virt2phy(vma_addr); + physaddr = get_physaddr(vma_addr); - if (physaddr == RTE_BAD_PHYS_ADDR) + if (physaddr == (phys_addr_t) -1) return -1; hugepg_tbl[page_idx].final_va = vma_addr; @@ -531,7 +516,7 @@ remap_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi) expected_physaddr = hugepg_tbl[page_idx].physaddr + offset; page_addr = RTE_PTR_ADD(vma_addr, offset); - physaddr = rte_mem_virt2phy(page_addr); + physaddr = get_physaddr(page_addr); if (physaddr != expected_physaddr) { RTE_LOG(ERR, EAL, "Segment sanity check failed: wrong physaddr " -- 2.20.1