DPDK patches and discussions
 help / color / mirror / Atom feed
* [Bug 1229] rte_mempool_avail_count : returns bigger than mempool size
@ 2023-05-11 14:00 bugzilla
  2023-05-18  8:56 ` bugzilla
  0 siblings, 1 reply; 2+ messages in thread
From: bugzilla @ 2023-05-11 14:00 UTC (permalink / raw)
  To: dev

[-- Attachment #1: Type: text/plain, Size: 1723 bytes --]

https://bugs.dpdk.org/show_bug.cgi?id=1229

            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:
You are the assignee for the bug.

[-- Attachment #2: Type: text/html, Size: 3615 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-18  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 14:00 [Bug 1229] rte_mempool_avail_count : returns bigger than mempool size bugzilla
2023-05-18  8:56 ` bugzilla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).