From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Tourrilhes Subject: [PATCH] mempool: Add sanity check when secondary link in less mempools than primary Date: Wed, 12 Oct 2016 13:04:45 -0700 Message-ID: <20161012200445.GA10029@labs.hpe.com> Reply-To: jean.tourrilhes@hpe.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: dev@dpdk.org, Thomas Monjalon , David Marchand , Sergio Gonzalez Monroy Return-path: Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by dpdk.org (Postfix) with ESMTP id 556D729B6 for ; Wed, 12 Oct 2016 22:04:49 +0200 (CEST) Content-Disposition: inline List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" mempool: Add sanity check when secondary link in less mempools than primary If the primary and secondary process were build using different build systems, the list of constructors included by the linker in each binary might be different. Mempools are registered via constructors, so the linker magic will directly impact which tailqs are registered with the primary and the secondary. DPDK currently assumes that the secondary has a superset of the mempools registered at the primary, and they are in the same order (same index in primary and secondary). In some build scenario, the secondary might not initialise any mempools at all. This would result in an obscure segfault when trying to use the mempool. Instead, fail early with a more explicit error message. Signed-off-by: Jean Tourrilhes --- lib/librte_mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 2e28e2e..4fe9158 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -1275,6 +1275,16 @@ rte_mempool_lookup(const char *name) return NULL; } + /* Sanity check : secondary may have initialised less mempools + * than primary due to linker and constructor magic. Note that + * this does not address the case where the constructor order + * is different between primary and secondary and where the index + * points to the wrong ops. Jean II */ + if(mp->ops_index >= (int32_t) rte_mempool_ops_table.num_ops) { + /* Do not dump mempool list, it will segfault. */ + rte_panic("Cannot find ops for mempool, ops_index %d, num_ops %d - maybe due to build process or linker configuration\n", mp->ops_index, rte_mempool_ops_table.num_ops); + } + return mp; }