From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 5AD861C97F for ; Mon, 14 May 2018 18:06:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2018 09:06:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,400,1520924400"; d="scan'208";a="228435304" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga006.fm.intel.com with ESMTP; 14 May 2018 09:06:16 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w4EG6GDR004151; Mon, 14 May 2018 17:06:16 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w4EG6F32015115; Mon, 14 May 2018 17:06:15 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w4EG6FXs015111; Mon, 14 May 2018 17:06:15 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: Olivier Matz , thomas@monjalon.net, konstantin.ananyev@intel.com, arybchenko@solarflare.com, shreyansh.jain@nxp.com Date: Mon, 14 May 2018 17:06:15 +0100 Message-Id: <014e66f8e34cb87fa126b7494ad644ef9ac68978.1526313945.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] mempool: fix virt address mempool population X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 May 2018 16:06:19 -0000 Currently, populate_virt will check if mempool is already populated. This will cause inability to reserve multi-chunk mempools if contiguous memory is not a hard requirement, because if allocating all-contiguous memory fails, mempool will retry with virtual addresses and will call populate_virt. It seems that the original code never anticipated more than one non-physically contiguous area. Fix it by removing the check in populate virt. populate_anon() function calls populate_virt() also, and it can be reasonably inferred that it is expecting that virtual area is not already populated. Even though a similar check is already in place there, also add the check that was part of populate_virt() just in case. Fixes: aab4f62d6c1c ("mempool: support no hugepage mode") Cc: olivier.matz@6wind.com Signed-off-by: Anatoly Burakov --- lib/librte_mempool/rte_mempool.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 9f1a425..8c8b9f8 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -492,9 +492,6 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, size_t off, phys_len; int ret, cnt = 0; - /* mempool must not be populated */ - if (mp->nb_mem_chunks != 0) - return -EEXIST; /* address and len must be page-aligned */ if (RTE_PTR_ALIGN_CEIL(addr, pg_sz) != addr) return -EINVAL; @@ -771,7 +768,7 @@ rte_mempool_populate_anon(struct rte_mempool *mp) char *addr; /* mempool is already populated, error */ - if (!STAILQ_EMPTY(&mp->mem_list)) { + if ((!STAILQ_EMPTY(&mp->mem_list)) || mp->nb_mem_chunks != 0) { rte_errno = EINVAL; return 0; } -- 2.7.4