From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [RFC v2 04/17] mempool: add op to populate objects using provided memory Date: Wed, 31 Jan 2018 17:45:29 +0100 Message-ID: <20180131164529.laku7jdh3hgriall@platinum> References: <1511539591-20966-1-git-send-email-arybchenko@solarflare.com> <1516713372-10572-1-git-send-email-arybchenko@solarflare.com> <1516713372-10572-5-git-send-email-arybchenko@solarflare.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org To: Andrew Rybchenko Return-path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id AC8701B7F0 for ; Wed, 31 Jan 2018 17:45:31 +0100 (CET) Content-Disposition: inline In-Reply-To: <1516713372-10572-5-git-send-email-arybchenko@solarflare.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Jan 23, 2018 at 01:15:59PM +0000, Andrew Rybchenko wrote: > The callback allows to customize how objects are stored in the > memory chunk. Default implementation of the callback which simply > puts objects one by one is available. > > Suggested-by: Olivier Matz > Signed-off-by: Andrew Rybchenko ... > > +int > +rte_mempool_populate_one_by_one(struct rte_mempool *mp, unsigned int max_objs, > + void *vaddr, rte_iova_t iova, size_t len, > + rte_mempool_populate_obj_cb_t *obj_cb) We shall find a better name for this function. Unfortunatly rte_mempool_populate_default() already exists... I'm also wondering if having a file rte_mempool_ops_default.c with all the default behaviors would make sense? ... > @@ -466,16 +487,13 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > else > off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_CACHE_LINE_SIZE) - vaddr; > > - while (off + total_elt_sz <= len && mp->populated_size < mp->size) { > - off += mp->header_size; > - if (iova == RTE_BAD_IOVA) > - mempool_add_elem(mp, (char *)vaddr + off, > - RTE_BAD_IOVA); > - else > - mempool_add_elem(mp, (char *)vaddr + off, iova + off); > - off += mp->elt_size + mp->trailer_size; > - i++; > - } > + if (off > len) > + return -EINVAL; > + > + i = rte_mempool_ops_populate(mp, mp->size - mp->populated_size, > + (char *)vaddr + off, > + (iova == RTE_BAD_IOVA) ? RTE_BAD_IOVA : (iova + off), > + len - off, mempool_add_elem); My initial idea was to provide populate_iova(), populate_virt(), ... as mempool ops. I don't see any strong requirement for doing it now, but on the other hand it would break the API to do it later. What's your opinion? Also, I see that mempool_add_elem() is passed as a callback to rte_mempool_ops_populate(). Instead, would it make sense to export mempool_add_elem() and let the implementation of populate() ops to call it?