Bug ID 1229
Summary rte_mempool_avail_count : returns bigger than mempool size
Product DPDK
Version 22.11
Hardware x86
OS Linux
Status UNCONFIRMED
Severity minor
Priority Normal
Component core
Assignee dev@dpdk.org
Reporter yasinncaner@gmail.com
Target Milestone ---

Hello,

Sometimes rte_mempool_avail_count function returns bigger than mempool size
that cause mis-calculation/overflow/negative of in-use count  (
rte_mempool_in_use_count)


11:51:48 NOTI [UseCount_mpool:00000065][avail_mpool:00010334]
11:51:48 NOTI [UseCount_mpool:4294967135][avail_mpool:00010560]


After adding a condition, it is fixed.

/* Return the number of entries in the mempool */
unsigned int
rte_mempool_avail_count(const struct rte_mempool *mp)
{
        unsigned count;
        unsigned lcore_id;

        count = rte_mempool_ops_get_count(mp);

        if (mp->cache_size == 0){
                if (count > mp->size){
                        return mp->size;
                }
                return count;
        }
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
                count += mp->local_cache[lcore_id].len;

        /*
         * 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;
}
          


You are receiving this mail because: