[dpdk-dev,PATCHv2] linuxapp eal: set fd to -1 for MAP_ANONYMOUS cases
diff mbox

Message ID 20180412111640.8977-1-nhorman@tuxdriver.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Neil Horman April 12, 2018, 11:16 a.m. UTC
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.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Thomas Monjalon <thomas@monjalon.net>
CC: Ferruh Yigit <ferruh.yigit@intel.com>

---
Change notes

v2) Rebased to HEAD again to adjust for patches that landed ahead of
this
---
 lib/librte_eal/bsdapp/eal/eal_memory.c   | 2 +-
 lib/librte_eal/linuxapp/eal/eal_memory.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Burakov, Anatoly April 12, 2018, 12:05 p.m. UTC | #1
On 12-Apr-18 12:16 PM, Neil Horman wrote:
> 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.
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Thomas Monjalon <thomas@monjalon.net>
> CC: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> ---
> Change notes
> 
> v2) Rebased to HEAD again to adjust for patches that landed ahead of
> this
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Thomas Monjalon April 12, 2018, 12:40 p.m. UTC | #2
12/04/2018 14:05, Burakov, Anatoly:
> On 12-Apr-18 12:16 PM, Neil Horman wrote:
> > 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.
> > 
> > Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> > CC: Thomas Monjalon <thomas@monjalon.net>
> > CC: Ferruh Yigit <ferruh.yigit@intel.com>
> > 
> > ---
> > Change notes
> > 
> > v2) Rebased to HEAD again to adjust for patches that landed ahead of
> > this
> > ---
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

Patch
diff mbox

diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c b/lib/librte_eal/bsdapp/eal/eal_memory.c
index b27262c7e..a5e034789 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 7cdd3048e..b7a2e951d 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));