From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 920EEB0C8 for ; Tue, 3 Jun 2014 12:18:03 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 03 Jun 2014 03:18:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,964,1392192000"; d="scan'208";a="521934565" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 03 Jun 2014 03:18:12 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s53AIBYA023406; Tue, 3 Jun 2014 11:18:11 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s53AIBjK026957; Tue, 3 Jun 2014 11:18:11 +0100 Received: (from aburakov@localhost) by sivswdev02.ir.intel.com with id s53AIBhT026953; Tue, 3 Jun 2014 11:18:11 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Tue, 3 Jun 2014 11:18:05 +0100 Message-Id: <000d4ba049ebe7864b397003fda2dcf4ff5b6f61.1401789384.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 16/20] eal: make --no-huge use mmap instead of malloc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2014 10:18:05 -0000 This makes it possible to run DPDK without hugepage memory when VFIO is used, as VFIO uses virtual addresses to set up DMA mappings. Technically, malloc is just fine, but we want to guarantee that memory will be page-aligned, so using mmap to be safe. Signed-off-by: Anatoly Burakov --- lib/librte_eal/linuxapp/eal/eal_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 8d1edd9..315214b 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.8.1.4