* [dpdk-dev] [PATCH v2] lib/librte_eal/linuxapp: fix runtime config mmap issue
@ 2019-10-23 10:31 Li Han
0 siblings, 0 replies; only message in thread
From: Li Han @ 2019-10-23 10:31 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:
-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..d4cd5bb 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] only message in thread
only message in thread, other threads:[~2019-10-23 11:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 10:31 [dpdk-dev] [PATCH v2] lib/librte_eal/linuxapp: fix runtime config mmap issue Li Han
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).