From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Vyal Subject: Looks like rte_mempool_free_count() and rte_mempool_count() are swapped Date: Thu, 12 Sep 2013 11:52:35 +0400 Message-ID: <523172C3.2040309@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit To: dev-VfR2kkLFssw@public.gmane.org Return-path: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Greetings. I had a suspect I run into a mbuf depletion issue and decided to check using rte_mempool_free_count(). To my surprise, it returned a value equal to mempool size. I tried calling rte_mempool_count() and it returned zero. I inspected the code in dpdk-1.3.1-7 and dpdk.1.4.1-4: rte_mempool_count(const struct rte_mempool *mp) { unsigned count; count = rte_ring_count(mp->ring); #if RTE_MEMPOOL_CACHE_MAX_SIZE > 0 { unsigned lcore_id; if (mp->cache_size == 0) return count; for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) count += mp->local_cache[lcore_id].len; } #endif /* * due to race condition (access to len is not locked), the * total can be greater than size... so fix the result */ if (count > mp->size) return mp->size; return count; } If I understand it correctly, the ring contains free buffers and rte_ring_count() returns a number of entries inside a ring. So this function actually calculates the number of free entries, not busy. Moreover, rte_mempool_count() is used in many places. For example it's called in rte_mempool_free_count() and rte_mempool_full(). Can anyone confirm or refute my findings? Regards, Dmitry