summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuanming Mou <mousuanming@huawei.com>2019-05-15 05:10:39 +0000
committerThomas Monjalon <thomas@monjalon.net>2019-07-11 00:26:17 +0200
commita99a311ba101ea7ebde256732bf65f512882d2b6 (patch)
treee9caa215a309d4036ab7097e08b634b9a59d43b9
parent0c4d3e4268576ce31c11e6d09d819b43592c1323 (diff)
downloaddpdk-a99a311ba101ea7ebde256732bf65f512882d2b6.zip
dpdk-a99a311ba101ea7ebde256732bf65f512882d2b6.tar.gz
dpdk-a99a311ba101ea7ebde256732bf65f512882d2b6.tar.xz
app/pdump: exit with primary process
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> Acked-by: Reshma Pattan <reshma.pattan@intel.com>
-rw-r--r--app/pdump/main.c46
-rw-r--r--doc/guides/rel_notes/release_19_08.rst4
-rw-r--r--doc/guides/tools/pdump.rst3
3 files changed, 53 insertions, 0 deletions
diff --git a/app/pdump/main.c b/app/pdump/main.c
index cd0986a..c1b9012 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 @@ launch_args_parse(int argc, char **argv, char *prgname)
}
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 @@ cleanup_pdump_resources(void)
}
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 @@ dump_packets(void)
;
}
+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 @@ main(int argc, char **argv)
/* 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 ac496b3..4a1fd8d 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -204,6 +204,10 @@ New Features
Added telemetry mode to l3fwd-power application to report
application level busyness, empty and full polls of rte_eth_rx_burst().
+* **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..8a499c6 100644
--- a/doc/guides/tools/pdump.rst
+++ b/doc/guides/tools/pdump.rst
@@ -26,6 +26,9 @@ 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
-----------------------