Skip to contentSkip to conversation

Looks like rte_mempool_free_count() and rte_mempool_count() are swapped

DISCUSSION Dmitry Vyal 2 participants 2 messages Sep 12, 2013 – Jan 2, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

12/09/2013 09:52, Dmitry Vyal :

Quoted 3 lines

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.

Yes, you're right. mempool's objects are free mbufs.
So mempool_count is the number of free mbufs,
and mempool_free_count is the number of free slots to store more free mbufs. I agree that the naming is confusing but I'm not sure we should change it.

Signature · 1 line
Thomas