From: Neil Horman Date: Thu, 12 Apr 2018 11:16:40 +0000 (-0400) Subject: mem: set fd to -1 for anonymous mmap X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=34fbfa585cbfa5e3e1de5b0137e91ecfdc87e4f9;p=dpdk.git mem: set fd to -1 for anonymous mmap https://dpdk.org/tracker/show_bug.cgi?id=18 Indicated that several mmap call sites in the [linux|bsd]app eal code set fd that was not -1 in their calls while using MAP_ANONYMOUS. While probably not a huge deal, the man page does say the fd should be -1 for portability, as some implementations don't ignore fd as they should for MAP_ANONYMOUS. Suggested-by: Solal Pirelli Signed-off-by: Neil Horman Acked-by: Anatoly Burakov --- diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c b/lib/librte_eal/bsdapp/eal/eal_memory.c index b27262c7eb..a5e034789a 100644 --- a/lib/librte_eal/bsdapp/eal/eal_memory.c +++ b/lib/librte_eal/bsdapp/eal/eal_memory.c @@ -70,7 +70,7 @@ rte_eal_hugepage_init(void) addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (addr == MAP_FAILED) { RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__, strerror(errno)); diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 7cdd3048ec..b7a2e951dc 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1329,7 +1329,7 @@ eal_legacy_hugepage_init(void) } addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (addr == MAP_FAILED) { RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__, strerror(errno));