* Re: [dpdk-dev] [PATCH v2 11/16] Make --no-huge use mmap instead of malloc
@ 2014-05-27 3:28 Xu, HuilongX
0 siblings, 0 replies; 3+ messages in thread
From: Xu, HuilongX @ 2014-05-27 3:28 UTC (permalink / raw)
To: dev, Burakov, Anatoly
This makes it possible to run DPDK without hugepage memory when VFIO
is used, as VFIO uses virtual addresses to set up DMA mappings.
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com<http://dpdk.org/ml/listinfo/dev>>
Test-by: HuilongX Xu huilongx.xu@intel.com<mailto:huilongx.xu@intel.com>
Compile pass
>>Compile OS: FC20 x86_64
>>Kernel version: 3.13.6-200
>>GCC version: 4.8.2
>>Server: Crownpass
---
lib/librte_eal/linuxapp/eal/eal_memory.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5a10a80..3fc0d28 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1031,7 +1031,13 @@ rte_eal_hugepage_init(void)
/* hugetlbfs can be disabled */
if (internal_config.no_hugetlbfs) {
- addr = malloc(internal_config.memory);
+ addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ if (addr == MAP_FAILED) {
+ RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__,
+ strerror(errno));
+ return -1;
+ }
mcfg->memseg[0].phys_addr = (phys_addr_t)(uintptr_t)addr;
mcfg->memseg[0].addr = addr;
mcfg->memseg[0].len = internal_config.memory;
--
1.7.0.7
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH v2 11/16] Make --no-huge use mmap instead of malloc
2014-05-19 15:51 ` [dpdk-dev] [PATCH v2 11/16] Make --no-huge use mmap instead of malloc Anatoly Burakov
@ 2014-05-22 13:04 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2014-05-22 13:04 UTC (permalink / raw)
To: Anatoly Burakov; +Cc: dev
2014-05-19 16:51, Anatoly Burakov:
> This makes it possible to run DPDK without hugepage memory when VFIO
> is used, as VFIO uses virtual addresses to set up DMA mappings.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> - addr = malloc(internal_config.memory);
> + addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
Please, could you add a comment to explain why using mmap helps?
--
Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
* [dpdk-dev] [PATCH v2 11/16] Make --no-huge use mmap instead of malloc
2014-05-01 11:05 [dpdk-dev] [PATCH 00/16] [RFC] [VFIO] Add VFIO support to DPDK Burakov, Anatoly
@ 2014-05-19 15:51 ` Anatoly Burakov
2014-05-22 13:04 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Anatoly Burakov @ 2014-05-19 15:51 UTC (permalink / raw)
To: dev
This makes it possible to run DPDK without hugepage memory when VFIO
is used, as VFIO uses virtual addresses to set up DMA mappings.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/linuxapp/eal/eal_memory.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5a10a80..3fc0d28 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1031,7 +1031,13 @@ rte_eal_hugepage_init(void)
/* hugetlbfs can be disabled */
if (internal_config.no_hugetlbfs) {
- addr = malloc(internal_config.memory);
+ addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ if (addr == MAP_FAILED) {
+ RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__,
+ strerror(errno));
+ return -1;
+ }
mcfg->memseg[0].phys_addr = (phys_addr_t)(uintptr_t)addr;
mcfg->memseg[0].addr = addr;
mcfg->memseg[0].len = internal_config.memory;
--
1.7.0.7
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-27 3:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-27 3:28 [dpdk-dev] [PATCH v2 11/16] Make --no-huge use mmap instead of malloc Xu, HuilongX
-- strict thread matches above, loose matches on Subject: below --
2014-05-01 11:05 [dpdk-dev] [PATCH 00/16] [RFC] [VFIO] Add VFIO support to DPDK Burakov, Anatoly
2014-05-19 15:51 ` [dpdk-dev] [PATCH v2 11/16] Make --no-huge use mmap instead of malloc Anatoly Burakov
2014-05-22 13:04 ` Thomas Monjalon
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).