DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, anatoly.burakov@intel.com,
	Jianfeng Tan <jianfeng.tan@intel.com>
Subject: [dpdk-dev] [RFC 8/8] ipc: remove IPC thread for message read
Date: Thu, 19 Apr 2018 15:03:36 +0000	[thread overview]
Message-ID: <1524150216-3407-9-git-send-email-jianfeng.tan@intel.com> (raw)
In-Reply-To: <1524150216-3407-1-git-send-email-jianfeng.tan@intel.com>

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.burakov@intel.com>

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Jianfeng Tan <jianfeng.tan@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

  parent reply	other threads:[~2018-04-19 15:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 15:03 [dpdk-dev] [RFC 0/8] remove IPC threads Jianfeng Tan
2018-04-19 15:03 ` [dpdk-dev] [RFC 1/8] ipc: clearn up code Jianfeng Tan
2018-04-19 15:03 ` [dpdk-dev] [RFC 2/8] ipc: fix timeout not properly handled in async Jianfeng Tan
2018-04-19 15:03 ` [dpdk-dev] [RFC 3/8] eal/linux: use glibc malloc in alarm Jianfeng Tan
2018-04-19 15:03 ` [dpdk-dev] [RFC 4/8] ipc: remove IPC thread for async request Jianfeng Tan
2018-04-20  9:03   ` Burakov, Anatoly
2018-04-19 15:03 ` [dpdk-dev] [RFC 5/8] eal/linux: use glibc malloc in interrupt handling Jianfeng Tan
2018-04-19 15:03 ` [dpdk-dev] [RFC 6/8] eal: bring forward init of " Jianfeng Tan
2018-04-19 15:03 ` [dpdk-dev] [RFC 7/8] eal: add IPC type for interrupt thread Jianfeng Tan
2018-04-19 15:03 ` Jianfeng Tan [this message]
2018-04-19 15:22 ` [dpdk-dev] [RFC 0/8] remove IPC threads Thomas Monjalon
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 0/6] Remove " Anatoly Burakov
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 1/6] eal/linux: use glibc malloc in alarm Anatoly Burakov
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 2/6] ipc: remove IPC thread for async requests Anatoly Burakov
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 3/6] eal/linux: use glibc malloc in interrupt handling Anatoly Burakov
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 4/6] eal: bring forward init of " Anatoly Burakov
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 5/6] eal: add IPC type for interrupt thread Anatoly Burakov
2018-05-31 10:12 ` [dpdk-dev] [RFC v2 6/6] ipc: remove main IPC thread Anatoly Burakov

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=1524150216-3407-9-git-send-email-jianfeng.tan@intel.com \
    --to=jianfeng.tan@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).