From: "forsakening@sina.cn" <forsakening@sina.cn>
To: users <users@dpdk.org>
Subject: [dpdk-users] Mempool Multi-Operation Unsafe?
Date: Thu, 17 Dec 2015 15:37:49 +0800 [thread overview]
Message-ID: <201512171537488860049@sina.cn> (raw)
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
reply other threads:[~2015-12-17 7:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201512171537488860049@sina.cn \
--to=forsakening@sina.cn \
--cc=users@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).