From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: [RFC PATCH 4/6] mempool: add a function to flush default cache Date: Thu, 14 Dec 2017 14:38:38 +0100 Message-ID: <20171214133837.y5feayfpoxeou6z3@platinum> References: <1511539591-20966-1-git-send-email-arybchenko@solarflare.com> <1511539591-20966-5-git-send-email-arybchenko@solarflare.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, "Artem V. Andreev" 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 958921D8E for ; Thu, 14 Dec 2017 14:38:45 +0100 (CET) Content-Disposition: inline In-Reply-To: <1511539591-20966-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 Fri, Nov 24, 2017 at 04:06:29PM +0000, Andrew Rybchenko wrote: > From: "Artem V. Andreev" > > Mempool get/put API cares about cache itself, but sometimes it is > required to flush the cache explicitly. I don't disagree, but do you have some use-case in mind? > Also dedicated API allows to decouple it from block get API (to be > added) and provides more fine-grained control. > > Signed-off-by: Artem V. Andreev > Signed-off-by: Andrew Rybchenko > --- > lib/librte_mempool/rte_mempool.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h > index 9bcb8b7..3a52b93 100644 > --- a/lib/librte_mempool/rte_mempool.h > +++ b/lib/librte_mempool/rte_mempool.h > @@ -1161,6 +1161,22 @@ rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id) > } > > /** > + * Ensure that a default per-lcore mempool cache is flushed, if it is present > + * > + * @param mp > + * A pointer to the mempool structure. > + */ > +static __rte_always_inline void > +rte_mempool_ensure_cache_flushed(struct rte_mempool *mp) > +{ > + struct rte_mempool_cache *cache; > + cache = rte_mempool_default_cache(mp, rte_lcore_id()); > + if (cache != NULL && cache->len > 0) > + rte_mempool_cache_flush(cache, mp); > +} > + We already have rte_mempool_cache_flush(). Why not just extending it instead of adding a new function? I mean: static __rte_always_inline void rte_mempool_cache_flush(struct rte_mempool_cache *cache, struct rte_mempool *mp) { + if (cache == NULL) + cache = rte_mempool_default_cache(mp, rte_lcore_id()); + if (cache == NULL || cache->len == 0) + return; rte_mempool_ops_enqueue_bulk(mp, cache->objs, cache->len); cache->len = 0; }