R&D/DPDK

DPDK bugfix

sunshout 2014. 7. 25. 20:22

commit c033f1a052e009f60f99ae729be3c23dfb1cba20

Author: Choonho Son <choonho.son@gmail.com>

Date:   Fri Jul 25 20:16:13 2014 +0900


    examples/multi_process/simple_mp


    rte_ring_dequeue in a secondary thread should dequeue send_ring instead of recv_ring,

    since primary and secondary threads share same rte_ring.


    This is also an answer for http://dpdk.org/ml/archives/dev/2013-November/000704.html


diff --git a/examples/multi_process/simple_mp/main.c b/examples/multi_process/simple_mp/main.c

index 8e1ace9..3b75e58 100644

--- a/examples/multi_process/simple_mp/main.c

+++ b/examples/multi_process/simple_mp/main.c

@@ -91,7 +91,7 @@ lcore_recv(__attribute__((unused)) void *arg)

        printf("Starting core %u\n", lcore_id);

        while (!quit){

                void *msg;

-               if (rte_ring_dequeue(recv_ring, &msg) < 0){

+               if (rte_ring_dequeue(send_ring, &msg) < 0){

                        usleep(5);

                        continue;

                }

@@ -118,19 +118,14 @@ main(int argc, char **argv)

        if (ret < 0)

                rte_exit(EXIT_FAILURE, "Cannot init EAL\n");


-       if (rte_eal_process_type() == RTE_PROC_PRIMARY){

-               send_ring = rte_ring_create(_PRI_2_SEC, ring_size, rte_socket_id(), flags);

-               recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, rte_socket_id(), flags);

-               message_pool = rte_mempool_create(_MSG_POOL, pool_size,

-                               string_size, pool_cache, priv_data_sz,

-                               NULL, NULL, NULL, NULL,

-                               rte_socket_id(), flags);

-       } else {

-               recv_ring = rte_ring_lookup(_PRI_2_SEC);

-               send_ring = rte_ring_lookup(_SEC_2_PRI);

-               message_pool = rte_mempool_lookup(_MSG_POOL);

-       }

-       if (send_ring == NULL)

+    send_ring = rte_ring_create(_PRI_2_SEC, ring_size, rte_socket_id(), flags);

+    recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, rte_socket_id(), flags);

+    message_pool = rte_mempool_create(_MSG_POOL, pool_size,

+            string_size, pool_cache, priv_data_sz,

+            NULL, NULL, NULL, NULL,

+            rte_socket_id(), flags);

+

+    if (send_ring == NULL)

                rte_exit(EXIT_FAILURE, "Problem getting sending ring\n");

        if (recv_ring == NULL)

                rte_exit(EXIT_FAILURE, "Problem getting receiving ring\n");