From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g2t2355.austin.hpe.com (g2t2355.austin.hpe.com [15.233.44.28]) by dpdk.org (Postfix) with ESMTP id BDD1A56A8 for ; Wed, 21 Sep 2016 23:10:51 +0200 (CEST) Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2355.austin.hpe.com (Postfix) with ESMTP id DE9B664 for ; Wed, 21 Sep 2016 21:10:50 +0000 (UTC) Received: from masterns.labs.hpecorp.net (masterns.labs.hpe.com [16.111.40.8]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id B2D5839 for ; Wed, 21 Sep 2016 21:10:50 +0000 (UTC) Received: from bougret.labs.hpecorp.net (bougret.labs.hpecorp.net [16.111.8.16]) by masterns.labs.hpecorp.net (8.14.4/8.14.4/HPL-PA Hub) with ESMTP id u8LLAoKJ011652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Sep 2016 14:10:50 -0700 Received: from jt by bougret.labs.hpecorp.net with local (Exim 4.84_2) (envelope-from ) id 1bmon4-0007AD-4U for dev@dpdk.org; Wed, 21 Sep 2016 14:10:50 -0700 Date: Wed, 21 Sep 2016 14:10:50 -0700 From: Jean Tourrilhes To: dev@dpdk.org Message-ID: <20160921211049.GA27472@labs.hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organisation: HP Labs Palo Alto Address: HP Labs, MS1184, 1501 Page Mill road, Palo Alto, CA 94304, USA. E-mail: jean.tourrilhes@hpe.com User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [dpdk-dev] [PATCH 1/1 v2] eal: Fix misleading error messages, errno can't be trusted. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: jean.tourrilhes@hpe.com List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2016 21:10:52 -0000 lib/librte_eal/linuxapp/eal/eal.c | 14 +++++++++++--- lib/librte_eal/linuxapp/eal/eal_memory.c | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 3fb2188..5df9f6a 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -238,7 +238,8 @@ rte_eal_config_attach(void) mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config), PROT_READ, MAP_SHARED, mem_cfg_fd, 0); if (mem_config == MAP_FAILED) - rte_panic("Cannot mmap memory for rte_config\n"); + rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n", + errno, strerror(errno)); rte_config.mem_config = mem_config; } @@ -263,9 +264,16 @@ rte_eal_config_reattach(void) mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr, sizeof(*mem_config), PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0); + if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) { + if (mem_config != MAP_FAILED) + /* errno is stale, don't use */ + rte_panic("Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option\n", + rte_mem_cfg_addr, mem_config); + else + rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n", + errno, strerror(errno)); + } close(mem_cfg_fd); - if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) - rte_panic("Cannot mmap memory for rte_config\n"); rte_config.mem_config = mem_config; } diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 41e0a92..b036ffc 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1615,10 +1615,18 @@ rte_eal_hugepage_attach(void) PROT_READ, MAP_PRIVATE, fd_zero, 0); if (base_addr == MAP_FAILED || base_addr != mcfg->memseg[s].addr) { - RTE_LOG(ERR, EAL, "Could not mmap %llu bytes " - "in /dev/zero to requested address [%p]: '%s'\n", - (unsigned long long)mcfg->memseg[s].len, - mcfg->memseg[s].addr, strerror(errno)); + if (base_addr != MAP_FAILED) + /* errno is stale, don't use */ + RTE_LOG(ERR, EAL, "Could not mmap %llu bytes " + "in /dev/zero at [%p], got [%p] - " + "please use '--base-virtaddr' option\n", + (unsigned long long)mcfg->memseg[s].len, + mcfg->memseg[s].addr, base_addr); + else + RTE_LOG(ERR, EAL, "Could not mmap %llu bytes " + "in /dev/zero at [%p]: '%s'\n", + (unsigned long long)mcfg->memseg[s].len, + mcfg->memseg[s].addr, strerror(errno)); if (aslr_enabled() > 0) { RTE_LOG(ERR, EAL, "It is recommended to " "disable ASLR in the kernel "