[dpdk-users] Mempool Multi-Operation Unsafe?
forsakening at sina.cn
forsakening at sina.cn
Thu Dec 17 08:37:49 CET 2015
Hi Everyone:
In <Prog_guide-2.0.pfd> Chapter 2.1 Fast-Path API,
"The ring library is based on a lockless ring-buffer algorithm that maintains its original design for thread safety. Moreover, it provides high performance for either multi- or singleconsumer/producer enqueue/dequeue operations. The mempool library is based on the DPDK lockless ring library and therefore is also multi-thread safe."
I use the below code to test the "rte_pktmbuf_alloc & rte_pktmbuf_free" api:
#define TEST_THREAD_CNT 2
#define TEST_MBUF_CNT 10000
#define TEST_LOOP_CNT 10000000
l2fwd_pktmbuf_pool = rte_mempool_create("mbuf_test", TEST_MBUF_CNT,
MBUF_SIZE, 32, // 32 means use cache
sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL,
rte_socket_id(), 0);
I create the mempool of TEST_MBUF_CNT numbers, and create TEST_THREAD_CNT threads to alloc and free mbufs, but it happens to segment fault.
Below is my thread loop:
while(1)
{
if (i++ >= TEST_LOOP_CNT)
break;
if (i % 1000 == 0)
{
printf("Threadid:%d work %d, at:%lld[s]...\n", threadid, i, vst_gettime_sec() - start_time);
}
mbuf = rte_pktmbuf_alloc(l2fwd_pktmbuf_pool);
if (NULL != mbuf)
{
__tmp64 = (mbuf->pkt.data + 32);
(*__tmp64)++;
rte_pktmbuf_free(mbuf);
}
}
Is anybody face the same problem,or is anything i made wrong? Thanks a lot!
zhengxiang
More information about the users
mailing list