From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 60F771F1A; Thu, 1 Feb 2018 11:14:27 +0100 (CET) Received: from lfbn-lil-1-110-231.w90-45.abo.wanadoo.fr ([90.45.197.231] helo=droids-corp.org) by mail.droids-corp.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ehBt5-0008Uj-Ed; Thu, 01 Feb 2018 11:14:37 +0100 Received: by droids-corp.org (sSMTP sendmail emulation); Thu, 01 Feb 2018 11:14:23 +0100 Date: Thu, 1 Feb 2018 11:14:23 +0100 From: Olivier Matz To: Andrew Rybchenko Cc: santosh , dev@dpdk.org, stable@dpdk.org, jerin.jacob@caviumnetworks.com Message-ID: <20180201101423.k5yqxd5a2dk55qqw@platinum> References: <1511539591-20966-1-git-send-email-arybchenko@solarflare.com> <1516713372-10572-1-git-send-email-arybchenko@solarflare.com> <1516713372-10572-2-git-send-email-arybchenko@solarflare.com> <20180131164504.cnfgfwo2x3ftxnaj@platinum> <90005aad-1508-44bc-92a4-7c5d5f7b0246@caviumnetworks.com> <53796b3f-b2c2-dcfc-a10b-71ce1a68d3d2@caviumnetworks.com> <618e4eb2-e66c-592c-2065-f86328916d5d@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <618e4eb2-e66c-592c-2065-f86328916d5d@solarflare.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-stable] [dpdk-dev] [RFC v2 01/17] mempool: fix phys contig check if populate default skipped X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 10:14:27 -0000 On Thu, Feb 01, 2018 at 01:00:12PM +0300, Andrew Rybchenko wrote: > On 02/01/2018 12:30 PM, santosh wrote: > > On Thursday 01 February 2018 02:48 PM, Andrew Rybchenko wrote: > > > On 02/01/2018 12:09 PM, santosh wrote: > > > > On Thursday 01 February 2018 12:24 PM, Andrew Rybchenko wrote: > > > > > On 02/01/2018 08:05 AM, santosh wrote: > > > > > > On Wednesday 31 January 2018 10:15 PM, Olivier Matz wrote: > > > > > > > On Tue, Jan 23, 2018 at 01:15:56PM +0000, Andrew Rybchenko wrote: > > > > > > > > There is not specified dependency between rte_mempool_populate_default() > > > > > > > > and rte_mempool_populate_iova(). So, the second should not rely on the > > > > > > > > fact that the first adds capability flags to the mempool flags. > > > > > > > > > > > > > > > > Fixes: 65cf769f5e6a ("mempool: detect physical contiguous objects") > > > > > > > > Cc: stable@dpdk.org > > > > > > > > > > > > > > > > Signed-off-by: Andrew Rybchenko > > > > > > > Looks good to me. I agree it's strange that the mp->flags are > > > > > > > updated with capabilities only in rte_mempool_populate_default(). > > > > > > > I see that this behavior is removed later in the patchset since the > > > > > > > get_capa() is removed! > > > > > > > > > > > > > > However maybe this single patch could go in 18.02. > > > > > > > +Santosh +Jerin since it's mostly about Octeon. > > > > > > rte_mempool_xmem_size should return correct size if MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS flag > > > > > > is set in 'mp->flags'. Thats why _ops_get_capabilities() called in _populate_default() but not > > > > > > at _populate_iova(). > > > > > > I think, this 'alone' patch may break octeontx mempool. > > > > > The patch does not touch rte_mempool_populate_default(). > > > > > _ops_get_capabilities() is still called there before > > > > > rte_mempool_xmem_size(). The theoretical problem which > > > > > the patch tries to fix is the case when > > > > > rte_mempool_populate_default() is not called at all. I.e. application > > > > > calls _ops_get_capabilities() to get flags, then, together with > > > > > mp->flags, calls rte_mempool_xmem_size() directly, allocates > > > > > calculated amount of memory and calls _populate_iova(). > > > > > > > > > In that case, Application does like below: > > > > > > > >     /* Get mempool capabilities */ > > > >     mp_flags = 0; > > > >     ret = rte_mempool_ops_get_capabilities(mp, &mp_flags); > > > >     if ((ret < 0) && (ret != -ENOTSUP)) > > > >         return ret; > > > > > > > >     /* update mempool capabilities */ > > > >     mp->flags |= mp_flags; > > > Above line is not mandatory. "mp->flags | mp_flags" could be simply > > > passed to  rte_mempool_xmem_size() below. > > > > > That depends and again upto application requirement, if app further down > > wants to refer mp->flags for _align/_contig then better update to mp->flags. > > > > But that wasn't the point of discussion, I'm trying to understand that > > w/o this patch, whats could be the application level problem? > > The problem that it is fragile. If application does not use > rte_mempool_populate_default() it has to care about addition > of mempool capability flags into mempool flags. If it is not done, > rte_mempool_populate_iova/virt/iova_tab() functions will work > incorrectly since F_CAPA_PHYS_CONTIG and > F_CAPA_BLK_ALIGNED_OBJECTS are missing. > > The idea of the patch is to make it a bit more robust. I have no > idea how it can break something. If capability flags are already > there - no problem. If no, just make sure that we locally have them. The example given by Santosh will work, but it is *not* the role of the application to update the mempool flags. And nothing says that it is mandatory to call rte_mempool_ops_get_capabilities() before the populate functions. For instance, in testpmd it calls rte_mempool_populate_anon() when using anonymous memory. The capabilities will never be updated in mp->flags.