[dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support
Suanming.Mou
mousuanming at huawei.com
Thu May 2 07:20:32 CEST 2019
When primary app exits, the residual running pdump will stop the
primary app to restart. Add pdump exits with primary support.
Signed-off-by: Suanming.Mou <mousuanming at huawei.com>
---
Change in V6:
- remove "Suggested-by" tags and head line '.' in git log.
- adjust the rte_alarm.h head file position.
- add comment for MONITOR_INTERVAL.
- remove redunt fail in log.
- treat rte_eal_alarm_set fail as warning only.
- adjust the multiple line comments coding style.
---
app/pdump/main.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/app/pdump/main.c b/app/pdump/main.c
index 3d20854..947fea3 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
+/* Enough to set it to 500ms for exiting. */
+#define MONITOR_INTERVAL (500 * 1000)
/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -413,6 +416,18 @@ 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);
+ else
+ quit_signal = 1;
+}
+
+static void
print_pdump_stats(void)
{
int i;
@@ -537,6 +552,20 @@ struct parse_val {
}
static void
+disable_primary_monitor(void)
+{
+ int ret;
+
+ /*
+ * Don't worry about it is primary exit case. The alarm cancel
+ * function will take care about that. Ignore the ENOENT case.
+ */
+ 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 +939,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)
{
@@ -950,11 +990,13 @@ struct parse_val {
rte_exit(EXIT_FAILURE, "Invalid argument\n");
}
- /* create mempool, ring and vdevs info */
+ /* create mempool, ring, vdevs info and primary monitor */
create_mp_ring_vdev();
enable_pdump();
+ enable_primary_monitor();
dump_packets();
+ disable_primary_monitor();
cleanup_pdump_resources();
/* dump debug stats */
print_pdump_stats();
--
1.8.3.4
More information about the dev
mailing list