[dpdk-dev] [PATCH v6 10/10] eal: add multiprocess disable API
David Marchand
david.marchand at redhat.com
Mon Jul 6 22:52:34 CEST 2020
The multiprocess feature has been implicitly enabled so far.
Applications might want to explicitly disable like when using the
non-EAL threads registration API.
Signed-off-by: David Marchand <david.marchand at redhat.com>
---
Changes since v5:
- fixed windows build,
---
app/test/test_mp_secondary.c | 7 +++++++
lib/librte_eal/common/eal_common_proc.c | 7 +++----
lib/librte_eal/common/eal_common_thread.c | 2 +-
lib/librte_eal/common/eal_private.h | 5 -----
lib/librte_eal/include/rte_eal.h | 14 ++++++++++++++
lib/librte_eal/rte_eal_version.map | 1 +
lib/librte_eal/windows/eal.c | 2 +-
7 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/app/test/test_mp_secondary.c b/app/test/test_mp_secondary.c
index ac15ddbf20..3a655c3400 100644
--- a/app/test/test_mp_secondary.c
+++ b/app/test/test_mp_secondary.c
@@ -97,6 +97,13 @@ run_secondary_instances(void)
(1 << rte_get_master_lcore()));
ret |= launch_proc(argv1);
+ printf("### Testing rte_mp_disable() reject:\n");
+ if (rte_mp_disable()) {
+ printf("Error: rte_mp_disable() has been accepted\n");
+ ret |= -1;
+ } else {
+ printf("# Checked rte_mp_disable() is refused\n");
+ }
ret |= launch_proc(argv2);
ret |= !(launch_proc(argv3));
diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index 10142683f8..d35b9c0380 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -1236,10 +1236,9 @@ rte_mp_reply(struct rte_mp_msg *msg, const char *peer)
/* Internally, the status of the mp feature is represented as a three-state:
* - "unknown" as long as no secondary process attached to a primary process
- * and there was no call to eal_disable_multiprocess yet,
+ * and there was no call to rte_mp_disable yet,
* - "enabled" as soon as a secondary process attaches to a primary process,
- * - "disabled" when a primary process successfully called
- * eal_disable_multiprocess,
+ * - "disabled" when a primary process successfully called rte_mp_disable,
*/
enum mp_status {
MP_STATUS_UNKNOWN,
@@ -1264,7 +1263,7 @@ set_mp_status(enum mp_status status)
}
bool
-eal_disable_multiprocess(void)
+rte_mp_disable(void)
{
return set_mp_status(MP_STATUS_DISABLED);
}
diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c
index ea09a4f3e0..73a055902a 100644
--- a/lib/librte_eal/common/eal_common_thread.c
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -261,7 +261,7 @@ rte_thread_register(void)
rte_errno = EINVAL;
return -1;
}
- if (!eal_disable_multiprocess()) {
+ if (!rte_mp_disable()) {
RTE_LOG(ERR, EAL, "Multiprocess in use, registering non-EAL threads is not supported.\n");
rte_errno = EINVAL;
return -1;
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 535e008474..a917727e41 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -733,11 +733,6 @@ void __rte_thread_init(unsigned int lcore_id, rte_cpuset_t *cpuset);
*/
void __rte_thread_uninit(void);
-/**
- * Mark primary process as not supporting multi-process.
- */
-bool eal_disable_multiprocess(void);
-
/**
* Instruct primary process that a secondary process wants to attach.
*/
diff --git a/lib/librte_eal/include/rte_eal.h b/lib/librte_eal/include/rte_eal.h
index 0913d1947c..fc7db2d427 100644
--- a/lib/librte_eal/include/rte_eal.h
+++ b/lib/librte_eal/include/rte_eal.h
@@ -151,6 +151,20 @@ int rte_eal_cleanup(void);
*/
int rte_eal_primary_proc_alive(const char *config_file_path);
+/**
+ * Disable multiprocess.
+ *
+ * This function can be called to indicate that multiprocess won't be used for
+ * the rest of the application life.
+ *
+ * @return
+ * - true if called from a primary process that had no secondary processes
+ * attached,
+ * - false, otherwise.
+ */
+__rte_experimental
+bool rte_mp_disable(void);
+
#define RTE_MP_MAX_FD_NUM 8 /* The max amount of fds */
#define RTE_MP_MAX_NAME_LEN 64 /* The max length of action name */
#define RTE_MP_MAX_PARAM_LEN 256 /* The max length of param */
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 3aeb5b11ab..d17f13f8d3 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -399,6 +399,7 @@ EXPERIMENTAL {
rte_lcore_callback_unregister;
rte_lcore_dump;
rte_lcore_iterate;
+ rte_mp_disable;
rte_thread_register;
rte_thread_unregister;
};
diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
index 9fc831fe6f..e50601dd36 100644
--- a/lib/librte_eal/windows/eal.c
+++ b/lib/librte_eal/windows/eal.c
@@ -67,7 +67,7 @@ eal_proc_type_detect(void)
}
bool
-eal_disable_multiprocess(void)
+rte_mp_disable(void)
{
return true;
}
--
2.23.0
More information about the dev
mailing list