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 958921D8E for ; Thu, 14 Dec 2017 14:38:45 +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.84_2) (envelope-from ) id 1ePTou-0007ZH-0D; Thu, 14 Dec 2017 14:45:05 +0100 Received: by droids-corp.org (sSMTP sendmail emulation); Thu, 14 Dec 2017 14:38:38 +0100 Date: Thu, 14 Dec 2017 14:38:38 +0100 From: Olivier MATZ To: Andrew Rybchenko Cc: dev@dpdk.org, "Artem V. Andreev" 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 Content-Disposition: inline In-Reply-To: <1511539591-20966-5-git-send-email-arybchenko@solarflare.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [RFC PATCH 4/6] mempool: add a function to flush default cache 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, 14 Dec 2017 13:38:45 -0000 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; }