DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: add function to check if primary proc alive
@ 2016-01-20 13:25 Harry van Haaren
  2016-01-21  6:14 ` Qiu, Michael
                   ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Harry van Haaren @ 2016-01-20 13:25 UTC (permalink / raw)
  To: david.marchand; +Cc: dev

This patch adds a new function to the EAL API:
int rte_eal_primary_proc_alive(const char *path);

The function indicates if a primary process is alive right now.
This functionality is implemented by testing for a write-
lock on the config file, and the function tests for a lock.

The use case for this functionality is that a secondary
process can wait until a primary process starts by polling
the function and waiting. When the primary is running, the
secondary continues to poll to detect if the primary process
has quit unexpectedly, the secondary process can detect this.

The RTE_MAGIC number is written to the shared config by the
primary process, this is the signal to the secondary process
that the EAL is set up, and ready to be used. The function
rte_eal_mcfg_complete() writes RTE_MAGIC. This has been
delayed in the EAL init proceedure, as the PCI probing in
the primary process can interfere with the secondary running.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/rel_notes/release_2_3.rst            |  7 +++++++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  8 ++++++++
 lib/librte_eal/common/include/rte_eal.h         | 19 +++++++++++++++++++
 lib/librte_eal/linuxapp/eal/eal.c               | 18 ++++++++++++++++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 +++++++
 5 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_3.rst b/doc/guides/rel_notes/release_2_3.rst
index 99de186..14b5b06 100644
--- a/doc/guides/rel_notes/release_2_3.rst
+++ b/doc/guides/rel_notes/release_2_3.rst
@@ -11,6 +11,13 @@ Resolved Issues
 EAL
 ~~~
 
+* **Added rte_eal_primary_proc_alive() function**
+
+  A new function ``rte_eal_primary_proc_alive()`` has been added
+  to allow the user to detect if a primary process is running.
+  Use cases for this feature include fault detection, and monitoring
+  using secondary processes.
+
 
 Drivers
 ~~~~~~~
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 9d7adf1..0e28017 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -135,3 +135,11 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+
+DPDK_2.3 {
+       global:
+
+       rte_eal_primary_proc_alive;
+
+} DPDK_2.2;
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index d2816a8..6eb65f9 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -156,6 +156,25 @@ int rte_eal_iopl_init(void);
  *   - On failure, a negative error value.
  */
 int rte_eal_init(int argc, char **argv);
+
+/**
+ * Check if a primary process is currently alive
+ *
+ * This function returns true when a primary process is currently
+ * active.
+ *
+ * @param config_file_path
+ *   The config_file_path argument provided should point at the location
+ *   that the primary process will create its config file. By default,
+ *   /var/run/.rte_config is used. This path can be customized when starting
+ *   a primary process using --file-prefix=custom_path
+ *
+ * @return
+ *  - If alive, returns one.
+ *  - If dead, returns zero.
+ */
+int rte_eal_primary_proc_alive(const char *config_file_path);
+
 /**
  * Usage function typedef used by the application usage function.
  *
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 635ec36..b419066 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -818,8 +818,6 @@ rte_eal_init(int argc, char **argv)
 
 	eal_check_mem_on_local_socket();
 
-	rte_eal_mcfg_complete();
-
 	if (eal_plugins_init() < 0)
 		rte_panic("Cannot init plugins\n");
 
@@ -877,9 +875,25 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_pci_probe())
 		rte_panic("Cannot probe PCI\n");
 
+	rte_eal_mcfg_complete();
+
 	return fctret;
 }
 
+int
+rte_eal_primary_proc_alive(const char *config_file_path)
+{
+	int config_fd;
+	config_fd = open(config_file_path, O_RDONLY);
+	if (config_fd < 0)
+		return 0;
+
+	int ret = lockf(config_fd, F_TEST, 0);
+	close(config_fd);
+
+	return !!ret;
+}
+
 /* get core role */
 enum rte_lcore_role_t
 rte_eal_lcore_role(unsigned lcore_id)
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index cbe175f..7a8c530 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -138,3 +138,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_eal_primary_proc_alive;
+
+} DPDK_2.2;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2016-03-09 15:19 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 13:25 [dpdk-dev] [PATCH] eal: add function to check if primary proc alive Harry van Haaren
2016-01-21  6:14 ` Qiu, Michael
2016-01-21  6:19   ` Matthew Hall
2016-01-21  9:02   ` Van Haaren, Harry
2016-01-22 17:37     ` Bruce Richardson
2016-01-25  8:06       ` Qiu, Michael
2016-01-25 11:44       ` Van Haaren, Harry
2016-01-26 19:13         ` Bruce Richardson
2016-01-27 10:35           ` Van Haaren, Harry
2016-01-25  8:11 ` Qiu, Michael
2016-01-25 11:51   ` Van Haaren, Harry
2016-01-26  2:25     ` Qiu, Michael
2016-01-26  9:04       ` Van Haaren, Harry
2016-01-26 11:07         ` Qiu, Michael
2016-01-26 11:19           ` Van Haaren, Harry
2016-01-27 10:31 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
2016-02-02 14:11   ` [dpdk-dev] [PATCH v3] " Harry van Haaren
2016-02-23 14:10     ` [dpdk-dev] [PATCH v4] " Harry van Haaren
2016-02-24 13:50       ` Tahhan, Maryam
2016-03-04 18:07       ` Thomas Monjalon
2016-03-07 11:37       ` [dpdk-dev] [PATCH v5] " Harry van Haaren
2016-03-07 12:02         ` [dpdk-dev] [PATCH v6] " Harry van Haaren
2016-03-08  8:42           ` David Marchand
2016-03-08  9:58             ` Van Haaren, Harry
2016-03-08 11:13               ` Thomas Monjalon
2016-03-08 11:19                 ` David Marchand
2016-03-08 13:57                   ` Van Haaren, Harry
2016-03-08 14:40                     ` David Marchand
2016-03-08 17:07           ` [dpdk-dev] [PATCH v7 0/2] eal: add function to check primary alive Harry van Haaren
2016-03-08 17:07             ` [dpdk-dev] [PATCH v7 1/2] eal: fix race-condition in pri/sec proc startup Harry van Haaren
2016-03-08 17:07             ` [dpdk-dev] [PATCH v7 2/2] eal: add function to check if primary proc alive Harry van Haaren
2016-03-09 10:12             ` [dpdk-dev] [PATCH v8 0/2] eal: add function to check primary alive Harry van Haaren
2016-03-09 10:12               ` [dpdk-dev] [PATCH v8 1/2] eal: fix race-condition in pri/sec proc startup Harry van Haaren
2016-03-09 13:23                 ` Sergio Gonzalez Monroy
2016-03-09 10:12               ` [dpdk-dev] [PATCH v8 2/2] eal: add function to check if primary proc alive Harry van Haaren
2016-03-09 11:07               ` [dpdk-dev] [PATCH v8 0/2] eal: add function to check primary alive David Marchand
2016-03-09 12:59                 ` Sergio Gonzalez Monroy
2016-03-09 13:37               ` [dpdk-dev] [PATCH v9 " Harry van Haaren
2016-03-09 13:37                 ` [dpdk-dev] [PATCH v9 1/2] eal: fix race-condition in pri/sec proc startup Harry van Haaren
2016-03-09 14:27                   ` Sergio Gonzalez Monroy
2016-03-09 13:37                 ` [dpdk-dev] [PATCH v9 2/2] eal: add function to check if primary proc alive Harry van Haaren
2016-03-09 15:02                   ` Thomas Monjalon
2016-03-09 15:17                 ` [dpdk-dev] [PATCH v9 0/2] eal: add function to check primary alive Thomas Monjalon

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).