DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime config mmap issue
@ 2019-10-23 10:42 Li Han
  2019-10-23 17:46 ` Burakov, Anatoly
  2019-10-24 11:13 ` [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime config mmap issue Burakov, Anatoly
  0 siblings, 2 replies; 15+ messages in thread
From: Li Han @ 2019-10-23 10:42 UTC (permalink / raw)
  To: thomas; +Cc: dev, Li Han

In rte_eal_config_reattach(),the secondary mmap may fail
due to the rte_mem_cfg_addr already be used by others.do
the change just as the rte_fbarray_init() do.if no
base_virtaddr,use the default 0x100000000.

v2/v3:
-fix code style issues

Signed-off-by: Li Han <han.li1@zte.com.cn>
---
 lib/librte_eal/linux/eal/eal.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index f397206..ab0b5a0 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -308,20 +308,32 @@ enum rte_iova_mode
 {
 	void *rte_mem_cfg_addr;
 	int retval;
+	size_t page_sz, mmap_len;
 
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
 		return 0;
-
+	mmap_len = sizeof(*rte_config.mem_config);
 	/* map the config before hugepage address so that we don't waste a page */
 	if (internal_config.base_virtaddr != 0)
 		rte_mem_cfg_addr = (void *)
 			RTE_ALIGN_FLOOR(internal_config.base_virtaddr -
 			sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE));
-	else
-		rte_mem_cfg_addr = NULL;
-
+	else {
+		page_sz = sysconf(_SC_PAGESIZE);
+		if (page_sz == (size_t)-1) {
+			RTE_LOG(ERR, EAL,
+				"Cannot get SC_PAGESIZE for rte_mem_config\n");
+			return -1;
+		}
+		rte_mem_cfg_addr = eal_get_virtual_area(NULL, &mmap_len, page_sz, 0, 0);
+		if (rte_mem_cfg_addr == NULL) {
+			RTE_LOG(ERR, EAL,
+				"Cannot get virtual addr for rte_mem_config\n");
+			return -1;
+		}
+	}
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0600);
 		if (mem_cfg_fd < 0) {
@@ -349,8 +361,10 @@ enum rte_iova_mode
 		return -1;
 	}
 
-	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
-				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
+	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, mmap_len,
+				PROT_READ | PROT_WRITE,
+				MAP_FIXED | MAP_SHARED,
+				mem_cfg_fd, 0);
 
 	if (rte_mem_cfg_addr == MAP_FAILED){
 		close(mem_cfg_fd);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-11-13  7:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 10:42 [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime config mmap issue Li Han
2019-10-23 17:46 ` Burakov, Anatoly
2019-10-24  7:37   ` David Marchand
2019-10-24  8:30     ` [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime configmmap issue han.li1
2019-10-24 11:13     ` [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime config mmap issue Burakov, Anatoly
2019-10-24 11:23       ` David Marchand
2019-10-24 12:22         ` Burakov, Anatoly
2019-10-24 12:39           ` Burakov, Anatoly
2019-10-25 11:37             ` [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime configmmap issue han.li1
2019-10-25 12:20               ` Burakov, Anatoly
2019-10-26 16:07                 ` David Marchand
2019-11-05 14:14                   ` David Marchand
2019-11-13  7:38                     ` David Marchand
2019-10-24 11:13 ` [dpdk-dev] [PATCH v3] lib/librte_eal/linuxapp: fix runtime config mmap issue Burakov, Anatoly
2019-10-24 12:38   ` Burakov, Anatoly

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).