From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 91E092BFA for ; Mon, 11 Jul 2016 12:20:38 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 33B4827D66; Mon, 11 Jul 2016 12:20:38 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org, huilongx.xu@intel.com, waterman.cao@intel.com, yuanhan.liu@intel.com, weichunx.chen@intel.com, yu.y.liu@intel.com Cc: thomas.monjalon@6wind.com Date: Mon, 11 Jul 2016 12:20:27 +0200 Message-Id: <1468232428-24088-4-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468232428-24088-1-git-send-email-olivier.matz@6wind.com> References: <1468232428-24088-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 3/4] eal: fix retrieval of phys address with Xen Dom0 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: Mon, 11 Jul 2016 10:20:38 -0000 When using Xen Dom0, it looks that /proc/self/pagemap returns 0. This breaks the creation of mbufs pool. We can workaround this in rte_mem_virt2phy() by browsing the dpdk memory segments. This only works for dpdk memory, but it's enough to fix the mempool creation. Fixes: c042ba20674a ("mempool: rework support of Xen dom0") Fixes: 3097de6e6bfb ("mem: get physical address of any pointer") Signed-off-by: Olivier Matz --- lib/librte_eal/linuxapp/eal/eal_memory.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index b663244..42a29fa 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -164,6 +164,29 @@ rte_mem_virt2phy(const void *virtaddr) int page_size; off_t offset; + /* when using dom0, /proc/self/pagemap always returns 0, check in + * dpdk memory by browsing the memsegs */ + if (rte_xen_dom0_supported()) { + struct rte_mem_config *mcfg; + struct rte_memseg *memseg; + unsigned i; + + mcfg = rte_eal_get_configuration()->mem_config; + for (i = 0; i < RTE_MAX_MEMSEG; i++) { + memseg = &mcfg->memseg[i]; + if (memseg->addr == NULL) + break; + if (virtaddr > memseg->addr && + virtaddr < RTE_PTR_ADD(memseg->addr, + memseg->len)) { + return memseg->phys_addr + + RTE_PTR_DIFF(virtaddr, memseg->addr); + } + } + + return RTE_BAD_PHYS_ADDR; + } + /* Cannot parse /proc/self/pagemap, no need to log errors everywhere */ if (!proc_pagemap_readable) return RTE_BAD_PHYS_ADDR; -- 2.8.1