As discussed here, http://dpdk.org/dev/patchwork/patch/36579/,
we remove IPC thread, rte_mp_handle, in this patch.

Previously, to handle requests from peer(s), or replies for a
request (sync or async) by itself, thread rte_mp_handle will
blockly readmsg on the unix socket for incoming messages.
Now, we change to make use of the IPC event callback mechanism
(added in previous patch); in other words, we merge this into
interrupt thread.

Cc: Anatoly Burakov <anatoly.bura...@intel.com>

Suggested-by: Thomas Monjalon <tho...@monjalon.net>
Signed-off-by: Jianfeng Tan <jianfeng....@intel.com>
---
 lib/librte_eal/common/eal_common_proc.c | 38 ++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_proc.c 
b/lib/librte_eal/common/eal_common_proc.c
index 4cb460e..1f102ce 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -25,6 +25,7 @@
 #include <rte_cycles.h>
 #include <rte_eal.h>
 #include <rte_errno.h>
+#include <rte_interrupts.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
 #include <rte_tailq.h>
@@ -101,6 +102,8 @@ static struct {
        /**< used in async requests only */
 };
 
+static struct rte_intr_handle ipc_intr_handle;
+
 static void async_reply_handle(void *arg);
 
 /* forward declarations */
@@ -339,18 +342,18 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un 
*s)
        }
 }
 
-static void *
+static void
 mp_handle(void *arg __rte_unused)
 {
        struct mp_msg_internal msg;
        struct sockaddr_un sa;
 
        while (1) {
-               if (read_msg(&msg, &sa) == 0)
-                       process_msg(&msg, &sa);
-       }
+               if (read_msg(&msg, &sa) < 0)
+                       break;
 
-       return NULL;
+               process_msg(&msg, &sa);
+       }
 }
 
 static int
@@ -548,10 +551,8 @@ unlink_sockets(const char *filter)
 int
 rte_mp_channel_init(void)
 {
-       char thread_name[RTE_MAX_THREAD_NAME_LEN];
        char path[PATH_MAX];
        int dir_fd;
-       pthread_t mp_handle_tid;
 
        /* create filter path */
        create_socket_path("*", path, sizeof(path));
@@ -579,32 +580,31 @@ rte_mp_channel_init(void)
        if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
                        unlink_sockets(mp_filter)) {
                RTE_LOG(ERR, EAL, "failed to unlink mp sockets\n");
-               close(dir_fd);
-               return -1;
+               goto res;
        }
 
        if (open_socket_fd() < 0) {
-               close(dir_fd);
-               return -1;
+               mp_fd = -1;
+               goto res;
        }
 
-       if (pthread_create(&mp_handle_tid, NULL, mp_handle, NULL) < 0) {
-               RTE_LOG(ERR, EAL, "failed to create mp thead: %s\n",
+       ipc_intr_handle.fd = mp_fd;
+       ipc_intr_handle.type = RTE_INTR_HANDLE_IPC;
+
+       if (rte_intr_callback_register(&ipc_intr_handle,
+                                       mp_handle, NULL) < 0) {
+                RTE_LOG(ERR, EAL, "failed to register IPC callback: %s\n",
                        strerror(errno));
                close(mp_fd);
                mp_fd = -1;
-               return -1;
        }
 
-       /* try best to set thread name */
-       snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "rte_mp_handle");
-       rte_thread_setname(mp_handle_tid, thread_name);
-
+res:
        /* unlock the directory */
        flock(dir_fd, LOCK_UN);
        close(dir_fd);
 
-       return 0;
+       return (mp_fd < 0) ? -1 : 0;
 }
 
 /**
-- 
2.7.4

Reply via email to