DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming.Mou <mousuanming@huawei.com>
To: <dev@dpdk.org>
Cc: <vipin.varghese@intel.com>, <anatoly.burakov@intel.com>,
	<thomas@monjalon.net>, <reshma.pattan@intel.com>
Subject: [dpdk-dev] [PATCH v9] app/pdump: exit with primary process
Date: Wed, 15 May 2019 05:10:39 +0000	[thread overview]
Message-ID: <1557897039-89555-1-git-send-email-mousuanming@huawei.com> (raw)
In-Reply-To: <1556862508-61677-1-git-send-email-mousuanming@huawei.com>

From: Suanming Mou <mousuanming@huawei.com>

The pdump tool works as the secondary process. When the primary process
exits and the residual secondary process keeps running, it will make the
primary process can't start up again. Since the ex-fbarry files are still
attached by the secondary process pdump, the 'new' primary process can't
get these files locked.

The patch is to set up an alarm which runs every 0.5s periodically
to monitor the primary process in the pdump. Once the primary exits,
so will the pdump.

Signed-off-by: Suanming Mou <mousuanming@huawei.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: Vipin Varghese <vipin.varghese@intel.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
Reviewed-by: Thomas Monjalon <thomas@monjalon.net>
---
V9:
* reword the comments and update the git log.
* move release note to release_19_08.rst.
* remove dot in name.

 app/pdump/main.c                       | 46 ++++++++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_19_08.rst |  3 +++
 doc/guides/tools/pdump.rst             |  2 ++
 3 files changed, 51 insertions(+)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 3d20854..859a96c 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -13,6 +13,7 @@
 #include <net/if.h>
 
 #include <rte_eal.h>
+#include <rte_alarm.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_ethdev.h>
@@ -65,6 +66,8 @@
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+/* Maximum delay for exiting after primary process. */
+#define MONITOR_INTERVAL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -413,6 +416,21 @@ struct parse_val {
 }
 
 static void
+monitor_primary(void *arg __rte_unused)
+{
+	if (quit_signal)
+		return;
+
+	if (rte_eal_primary_proc_alive(NULL)) {
+		rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL);
+		return;
+	}
+
+	printf("Primary process is no longer active, exiting...\n");
+	quit_signal = 1;
+}
+
+static void
 print_pdump_stats(void)
 {
 	int i;
@@ -537,6 +555,21 @@ struct parse_val {
 }
 
 static void
+disable_primary_monitor(void)
+{
+	int ret;
+
+	/*
+	 * Cancel monitoring of primary process.
+	 * There will be no error if no alarm is set
+	 * (in case primary process kill was detected earlier).
+	 */
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor:%d\n", ret);
+}
+
+static void
 signal_handler(int sig_num)
 {
 	if (sig_num == SIGINT) {
@@ -910,6 +943,17 @@ struct parse_val {
 		;
 }
 
+static void
+enable_primary_monitor(void)
+{
+	int ret;
+
+	/* Once primary exits, so will pdump. */
+	ret = rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to enable monitor:%d\n", ret);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -953,8 +997,10 @@ struct parse_val {
 	/* create mempool, ring and vdevs info */
 	create_mp_ring_vdev();
 	enable_pdump();
+	enable_primary_monitor();
 	dump_packets();
 
+	disable_primary_monitor();
 	cleanup_pdump_resources();
 	/* dump debug stats */
 	print_pdump_stats();
diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index b9510f9..e3a22e0 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -54,6 +54,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the pdump application.**
+
+  Add support for pdump to exit with primary process.
 
 Removed Items
 -------------
diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst
index 53cd2b4..62b4a5e 100644
--- a/doc/guides/tools/pdump.rst
+++ b/doc/guides/tools/pdump.rst
@@ -26,6 +26,8 @@ a DPDK secondary process and is capable of enabling packet capture on dpdk ports
         Once the libpcap development files are installed, the libpcap based PMD
         can be enabled by setting CONFIG_RTE_LIBRTE_PMD_PCAP=y and recompiling the DPDK.
 
+      * The ``dpdk-pdump`` tool runs as a DPDK secondary process. It exits when
+        the primary application exits.
 
 Running the Application
 -----------------------
-- 
1.8.3.4

  parent reply	other threads:[~2019-05-15  3:07 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 16:35 [dpdk-dev] [PATCH] app/pdump: exits once primary app exited Suanming.Mou
2019-04-25 15:51 ` Varghese, Vipin
2019-04-25 15:51   ` Varghese, Vipin
2019-04-26  7:11   ` Suanming.Mou
2019-04-26  7:11     ` Suanming.Mou
2019-04-26 10:54     ` Varghese, Vipin
2019-04-26 10:54       ` Varghese, Vipin
2019-04-26 10:56       ` Varghese, Vipin
2019-04-26 10:56         ` Varghese, Vipin
2019-04-26 12:08         ` Suanming.Mou
2019-04-26 12:08           ` Suanming.Mou
2019-04-26 13:46           ` Burakov, Anatoly
2019-04-26 13:46             ` Burakov, Anatoly
2019-04-26 14:32             ` Suanming.Mou
2019-04-26 14:32               ` Suanming.Mou
2019-04-26 14:39               ` Burakov, Anatoly
2019-04-26 14:39                 ` Burakov, Anatoly
2019-04-26 14:49                 ` Suanming.Mou
2019-04-26 14:49                   ` Suanming.Mou
2019-04-26 14:50                   ` Burakov, Anatoly
2019-04-26 14:50                     ` Burakov, Anatoly
2019-04-25 16:35 ` Suanming.Mou
2019-04-28  4:58 ` [dpdk-dev] [PATCH v2] app/pdump: add exit_with_primary option support Suanming.Mou
2019-04-28  4:58   ` Suanming.Mou
2019-04-28  5:07   ` [dpdk-dev] [PATCH v3] " Suanming.Mou
2019-04-28  5:07     ` Suanming.Mou
2019-04-30  3:39     ` [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support Suanming.Mou
2019-04-30  2:33       ` Varghese, Vipin
2019-04-30  2:33         ` Varghese, Vipin
2019-04-30  3:43         ` Suanming.Mou
2019-04-30  3:43           ` Suanming.Mou
2019-04-30  5:03           ` Varghese, Vipin
2019-04-30  5:03             ` Varghese, Vipin
2019-04-30  9:34         ` Burakov, Anatoly
2019-04-30  9:34           ` Burakov, Anatoly
2019-04-30 10:37           ` Varghese, Vipin
2019-04-30 10:37             ` Varghese, Vipin
2019-04-30 16:38             ` Burakov, Anatoly
2019-04-30 16:38               ` Burakov, Anatoly
2019-04-30  3:39       ` Suanming.Mou
2019-04-30 11:35       ` [dpdk-dev] [PATCH v5] Make pdump exits with primary Suanming.Mou
2019-04-30 11:35         ` Suanming.Mou
2019-04-30 11:35         ` [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support Suanming.Mou
2019-04-30  9:42           ` Burakov, Anatoly
2019-04-30  9:42             ` Burakov, Anatoly
2019-04-30 11:25             ` Suanming.Mou
2019-04-30 11:25               ` Suanming.Mou
2019-04-30 16:39               ` Burakov, Anatoly
2019-04-30 16:39                 ` Burakov, Anatoly
2019-05-02  3:07                 ` Suanming.Mou
2019-05-02  3:07                   ` Suanming.Mou
2019-04-30 11:35           ` Suanming.Mou
2019-04-30 12:44           ` Pattan, Reshma
2019-04-30 12:44             ` Pattan, Reshma
2019-05-02  5:20           ` [dpdk-dev] [PATCH v6] " Suanming.Mou
2019-05-02  5:20             ` Suanming.Mou
2019-05-02  8:04             ` Varghese, Vipin
2019-05-02  8:04               ` Varghese, Vipin
2019-05-02  8:32               ` Suanming.Mou
2019-05-02  8:32                 ` Suanming.Mou
2019-05-02  9:12                 ` Burakov, Anatoly
2019-05-02  9:12                   ` Burakov, Anatoly
2019-05-02  9:22                 ` Varghese, Vipin
2019-05-02  9:22                   ` Varghese, Vipin
2019-05-02  9:54             ` Pattan, Reshma
2019-05-02  9:54               ` Pattan, Reshma
2019-05-02 10:40               ` Suanming.Mou
2019-05-02 10:40                 ` Suanming.Mou
2019-05-02 12:35             ` [dpdk-dev] [PATCH v7] " Suanming.Mou
2019-05-02 11:03               ` Pattan, Reshma
2019-05-02 11:03                 ` Pattan, Reshma
2019-05-02 11:31               ` Burakov, Anatoly
2019-05-02 11:31                 ` Burakov, Anatoly
2019-05-02 12:35                 ` mousuanming
2019-05-02 12:35                   ` mousuanming
2019-05-02 12:35               ` Suanming.Mou
2019-05-03  5:48               ` [dpdk-dev] [PATCH v8] " Suanming.Mou
2019-05-03  5:48                 ` Suanming.Mou
2019-05-04 21:17                 ` Thomas Monjalon
2019-05-04 21:17                   ` Thomas Monjalon
2019-05-05  1:20                   ` Suanming.Mou
2019-05-05  1:20                     ` Suanming.Mou
2019-05-05  9:42                     ` Thomas Monjalon
2019-05-05  9:42                       ` Thomas Monjalon
2019-05-05 11:13                       ` Suanming.Mou
2019-05-05 11:13                         ` Suanming.Mou
2019-05-08  8:04                 ` Thomas Monjalon
2019-05-08  8:04                   ` Thomas Monjalon
2019-05-08  9:37                   ` Suanming.Mou
2019-05-08  9:37                     ` Suanming.Mou
2019-05-08 10:22                     ` Thomas Monjalon
2019-05-08 10:22                       ` Thomas Monjalon
2019-05-08 13:14                       ` Suanming.Mou
2019-05-08 13:14                         ` Suanming.Mou
2019-05-15  5:10                 ` Suanming.Mou [this message]
2019-05-15  5:10                   ` [dpdk-dev] [PATCH v9] app/pdump: exit with primary process Suanming.Mou
2019-06-20 12:32                   ` Pattan, Reshma
2019-06-23 22:30                     ` Thomas Monjalon
2019-07-10 14:04                       ` Suanming Mou
2019-07-10 22:28                         ` Thomas Monjalon
2019-04-29  9:14   ` [dpdk-dev] [PATCH v2] app/pdump: add exit_with_primary option support Burakov, Anatoly
2019-04-29  9:14     ` Burakov, Anatoly
2019-04-29  9:43     ` Suanming.Mou
2019-04-29  9:43       ` Suanming.Mou
2019-04-29 10:42       ` Burakov, Anatoly
2019-04-29 10:42         ` Burakov, Anatoly

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=1557897039-89555-1-git-send-email-mousuanming@huawei.com \
    --to=mousuanming@huawei.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    --cc=thomas@monjalon.net \
    --cc=vipin.varghese@intel.com \
    /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).