From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id D97A61B7F9 for ; Tue, 15 May 2018 15:04:34 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 4AEB178007E; Tue, 15 May 2018 13:04:33 +0000 (UTC) Received: from [192.168.38.17] (84.52.114.114) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 15 May 2018 14:04:27 +0100 To: Anatoly Burakov , CC: Olivier Matz , , , References: <014e66f8e34cb87fa126b7494ad644ef9ac68978.1526313945.git.anatoly.burakov@intel.com> From: Andrew Rybchenko Message-ID: <0d2ca8e2-58fa-78ca-03ab-1e965f20b436@solarflare.com> Date: Tue, 15 May 2018 16:04:23 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <014e66f8e34cb87fa126b7494ad644ef9ac68978.1526313945.git.anatoly.burakov@intel.com> Content-Language: en-GB X-Originating-IP: [84.52.114.114] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.100.1062-23844.003 X-TM-AS-Result: No--17.772800-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-MDID: 1526389474-ed-lAvg-7wmf Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [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: Tue, 15 May 2018 13:04:35 -0000 On 05/14/2018 07:06 PM, Anatoly Burakov wrote: > 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) { I've seen the description above. I see no point to add the check here since it is basically duplication. nb_mem_chunks is incremented when chunk is added to mem_list and decremented when chunk is removed from mem_list. However, it is not a problem anyway. So, OK to go as is. > rte_errno = EINVAL; > return 0; > } Reviewed-by: Andrew Rybchenko