From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id CD83E1B8F5 for ; Thu, 1 Feb 2018 09:53:17 +0100 (CET) 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-us3.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 32B36600083; Thu, 1 Feb 2018 08:53:16 +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; Thu, 1 Feb 2018 08:53:11 +0000 To: Olivier Matz CC: , "Artem V. Andreev" References: <1511539591-20966-1-git-send-email-arybchenko@solarflare.com> <1516713372-10572-1-git-send-email-arybchenko@solarflare.com> <1516713372-10572-12-git-send-email-arybchenko@solarflare.com> <20180131164539.qhpfx3vp6k5h2ufp@platinum> From: Andrew Rybchenko Message-ID: <087a6267-f7cb-d5a2-7347-b96e4d6d87e7@solarflare.com> Date: Thu, 1 Feb 2018 11:53:07 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180131164539.qhpfx3vp6k5h2ufp@platinum> 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-23634.003 X-TM-AS-Result: No--12.767900-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-MDID: 1517475197-boNCSdrbM3RP 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] [RFC v2 11/17] mempool: ensure the mempool is initialized before populating 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: Thu, 01 Feb 2018 08:53:18 -0000 On 01/31/2018 07:45 PM, Olivier Matz wrote: > On Tue, Jan 23, 2018 at 01:16:06PM +0000, Andrew Rybchenko wrote: >> From: "Artem V. Andreev" >> >> Callback to calculate required memory area size may require mempool >> driver data to be already allocated and initialized. >> >> Signed-off-by: Artem V. Andreev >> Signed-off-by: Andrew Rybchenko >> --- >> lib/librte_mempool/rte_mempool.c | 29 ++++++++++++++++++++++------- >> 1 file changed, 22 insertions(+), 7 deletions(-) >> >> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c >> index fc9c95a..cbb4dd5 100644 >> --- a/lib/librte_mempool/rte_mempool.c >> +++ b/lib/librte_mempool/rte_mempool.c >> @@ -370,6 +370,21 @@ rte_mempool_free_memchunks(struct rte_mempool *mp) >> } >> } >> >> +static int >> +mempool_maybe_initialize(struct rte_mempool *mp) >> +{ >> + int ret; >> + >> + /* create the internal ring if not already done */ >> + if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) { >> + ret = rte_mempool_ops_alloc(mp); >> + if (ret != 0) >> + return ret; >> + mp->flags |= MEMPOOL_F_POOL_CREATED; >> + } >> + return 0; >> +} > mempool_ops_alloc_once() ? Yes, I like it. Will fix.