DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] Mempool Multi-Operation Unsafe?
@ 2015-12-17  7:37 forsakening
  0 siblings, 0 replies; only message in thread
From: forsakening @ 2015-12-17  7:37 UTC (permalink / raw)
  To: users

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-17  7:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-17  7:37 [dpdk-users] Mempool Multi-Operation Unsafe? forsakening

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).