From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: konstantin.ananyev@intel.com, thomas@monjalon.net,
bruce.richardson@intel.com, Jianfeng Tan <jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH 8/8] ipc: remove main IPC thread
Date: Fri, 15 Jun 2018 15:25:08 +0100 [thread overview]
Message-ID: <40da3a6a106dd43bfd551b0307e91d0d0f642486.1529071026.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1529071026.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1529071026.git.anatoly.burakov@intel.com>
Previously, to handle requests from peer(s), or replies for a
request (sync or async) by itself, a dedicated IPC thread was set
up.
Now that every other piece of the puzzle is in place, we can get rid
of the IPC thread, and move waiting for IPC messages entirely into the
interrupt thread.
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Suggested-by: Thomas Monjalon <thomas@monjalon.net>
---
Notes:
RFC->RFCv2:
- Fixed resource leaks
- Improved readability
lib/librte_eal/common/eal_common_proc.c | 46 ++++++++++++++-----------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index 6f3366403..162d67ca5 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;
+
/* forward declarations */
static int
mp_send(struct rte_mp_msg *msg, const char *peer, int type);
@@ -350,18 +353,17 @@ 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;
+ process_msg(&msg, &sa);
}
-
- return NULL;
}
static int
@@ -570,7 +572,6 @@ rte_mp_channel_init(void)
{
char path[PATH_MAX];
int dir_fd;
- pthread_t mp_handle_tid;
/* create filter path */
create_socket_path("*", path, sizeof(path));
@@ -585,36 +586,32 @@ rte_mp_channel_init(void)
if (dir_fd < 0) {
RTE_LOG(ERR, EAL, "failed to open %s: %s\n",
mp_dir_path, strerror(errno));
- return -1;
+ goto fail;
}
if (flock(dir_fd, LOCK_EX)) {
RTE_LOG(ERR, EAL, "failed to lock %s: %s\n",
mp_dir_path, strerror(errno));
- close(dir_fd);
- return -1;
+ goto fail;
}
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 fail;
}
if (open_socket_fd() < 0) {
- close(dir_fd);
- return -1;
+ goto fail;
}
- if (rte_ctrl_thread_create(&mp_handle_tid, "rte_mp_handle",
- NULL, mp_handle, NULL) < 0) {
- RTE_LOG(ERR, EAL, "failed to create mp thead: %s\n",
- strerror(errno));
- close(mp_fd);
- close(dir_fd);
- mp_fd = -1;
- return -1;
+ 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 interrupt callback: %s\n",
+ strerror(errno));
+ goto fail;
}
/* unlock the directory */
@@ -622,6 +619,13 @@ rte_mp_channel_init(void)
close(dir_fd);
return 0;
+fail:
+ if (dir_fd >= 0)
+ close(dir_fd);
+ if (mp_fd >= 0)
+ close(mp_fd);
+ mp_fd = -1;
+ return -1;
}
/**
--
2.17.1
next prev parent reply other threads:[~2018-06-15 14:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 14:25 [dpdk-dev] [PATCH 0/8] Remove IPC threads Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 1/8] eal/linux: use glibc malloc in alarm Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 2/8] eal/linux: use glibc malloc in interrupt handling Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 3/8] ipc: remove IPC thread for async requests Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 4/8] eal: bring forward init of interrupt handling Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 5/8] eal: add IPC type for interrupt thread Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 6/8] eal/bsdapp: add " Anatoly Burakov
2018-06-15 14:25 ` [dpdk-dev] [PATCH 7/8] eal/bsdapp: add alarm support Anatoly Burakov
2018-06-15 14:25 ` Anatoly Burakov [this message]
2018-06-26 1:19 ` [dpdk-dev] [PATCH 0/8] Remove IPC threads Zhang, Qi Z
2018-06-26 7:03 ` Zhang, Qi Z
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 0/7] Remove asynchronous IPC thread Anatoly Burakov
2018-07-13 10:44 ` Thomas Monjalon
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 1/7] eal/linux: use glibc malloc in alarm Anatoly Burakov
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 2/7] eal/linux: use glibc malloc in interrupt handling Anatoly Burakov
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 3/7] eal/bsdapp: add interrupt thread Anatoly Burakov
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 4/7] eal/bsdapp: add alarm support Anatoly Burakov
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 5/7] eal: bring forward init of interrupt handling Anatoly Burakov
2018-07-12 22:36 ` Thomas Monjalon
2018-07-13 7:41 ` Burakov, Anatoly
2018-07-13 8:09 ` David Marchand
2018-07-13 9:10 ` Tiwei Bie
2018-07-13 11:28 ` David Marchand
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 6/7] ipc: remove IPC thread for async requests Anatoly Burakov
2018-06-26 10:53 ` [dpdk-dev] [PATCH v2 7/7] doc: document IPC callback limitations 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=40da3a6a106dd43bfd551b0307e91d0d0f642486.1529071026.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=jianfeng.tan@intel.com \
--cc=konstantin.ananyev@intel.com \
--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).