Skip to contentSkip to conversation

app/pdump: exits once primary app exited

PATCH In review Suanming.Mou 6 participants 54 messages Apr 25, 2019 – Jul 10, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/pdump: exits once primary app exited

If primary app exited, meaningless for pdump keeps running anymore.

---
 app/pdump/main.c | 4 ++++
 1 file changed, 4 insertions(+)
app/pdump/main.c +4 -0
index 3d208548fa13..f1ff2a3ceb4f 100644
@@ -847,6 +847,10 @@ struct parse_val {
 		pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, &pt->stats);
 	if (pt->dir & RTE_PDUMP_FLAG_TX)
 		pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, &pt->stats);
+
+	/* Once primary exits, so will I. */
+	if (!rte_eal_primary_proc_alive(NULL))
+		quit_signal = 1;
 }
 
 static int
Signature · 1 line
1.7.12.4
#1 lore raw

Hi,

snipped

app/pdump/main.c struct parse_val { · line 854

Quoted 9 lines
app/pdump/main.c +4 -0
@@ -847,6 +847,10 @@ struct parse_val {
 		pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, &pt->stats);
 	if (pt->dir & RTE_PDUMP_FLAG_TX)
 		pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, &pt->stats);
+
+	/* Once primary exits, so will I. */
+	if (!rte_eal_primary_proc_alive(NULL))
+		quit_signal = 1;
 }

As per the current suggested code flow check is added to while loop in function `dump_packets'.

Questions:
1. What is impact in performance with and without patch?
2. For various packet sizes and port speed what are delta in drops for packet capture?

Note: If pdump application is still alive when primary is not running, primary cannot be started. Is this a cue that pdump is still alive and has to be terminated?

Quoted 4 lines
(quoted diff) +0 -1
 static int
--

1.7.12.4

#2 lore raw
Quoted 13 lines · Vipin

Hi,

snipped

Review struct parse_val { · line 854

Quoted 9 lines
(quoted diff) +4 -0
@@ -847,6 +847,10 @@ struct parse_val {
  		pdump_rxtx(pt->rx_ring, pt->rx_vdev_id, &pt->stats);
  	if (pt->dir & RTE_PDUMP_FLAG_TX)
  		pdump_rxtx(pt->tx_ring, pt->tx_vdev_id, &pt->stats);
+
+	/* Once primary exits, so will I. */
+	if (!rte_eal_primary_proc_alive(NULL))
+		quit_signal = 1;
  }

As per the current suggested code flow check is added to while loop in function `dump_packets'.

Thanks for the reply. Since want to make it clean, the code was here. However, it seems need to take care of the performance impact first.

Quoted 2 lines

Questions:
1. What is impact in performance with and without patch?

A1. Do a little trick as the patch below to tested the impact in the single core mode on Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz with no pkts.

app/pdump/main.c +13 -2
index 3d208548fa13..804011b187c4 100644
@@ -141,7 +141,7 @@ struct parse_val {
 
 static int num_tuples;
 static struct rte_eth_conf port_conf_default;
-static volatile uint8_t quit_signal;
+static volatile uint32_t quit_signal;
 static uint8_t multiple_core_capture;
 
 /**< display usage */
@@ -868,6 +868,7 @@ struct parse_val {
 dump_packets(void)
 {
 	int i;
+	uint64_t start, end;
 	uint32_t lcore_id = 0;
 
 	if (!multiple_core_capture) {
@@ -880,10 +881,20 @@ struct parse_val {
 				pdump_t[i].device_id,
 				pdump_t[i].queue);
 
-		while (!quit_signal) {
+		/* make it hot */
+		rte_eal_primary_proc_alive(NULL);
+		rte_eal_primary_proc_alive(NULL)
+
+		start = rte_rdtsc();
+		while (quit_signal < 50000) {
+			/* Just testing with and w/o the 'if' line below */
+			if (rte_eal_primary_proc_alive(NULL))
+				quit_signal++;
 			for (i = 0; i < num_tuples; i++)
 				pdump_packets(&pdump_t[i]);
 		}
+		end = rte_rdtsc();
+		printf("Totally count:%u, cost tsc:%lu\n", quit_signal, end - start);
 
 		return;
 	}

The total tsc cost is about 338809671 with rte_eal_primary_proc_alive(). And the tsc cost is just about 513573 without rte_eal_primary_proc_alive(). The dpdk-pdump had also used taskset to bind to specify isolate core. So it seems the patch do a great performance impact.
Maybe another async method should be introduced to monitor the primary status.

Quoted 1 line

2. For various packet sizes and port speed what are delta in drops for packet capture?

A2. Refer to A1, it's not needed anymore.

Quoted 2 lines

Note: If pdump application is still alive when primary is not running, primary cannot be started. Is this a cue that pdump is still alive and has to be terminated?

Yes, some guys complained that the residual dpdk-pdump impact the restart of the primary app and refuse to add other mechanisms e.g. to kill the dpdk-pdump in the app to avoid that case.

So the patch was created.
Is there any other ways to avoid that.

Quoted 5 lines
Quoted 3 lines
(quoted diff) +0 -1
  static int
--

1.7.12.4

#3 lore raw

Hi,

Looks like something in email format setting is affecting the style. Please find my replies below snipped

As per the current suggested code flow check is added to while loop in function `dump_packets'.

Thanks for the reply. Since want to make it clean, the code was here.

However, it seems need to take care of the performance impact first.

Response> thanks for acknowledging the same.

Questions:

1. What is impact in performance with and without patch?

A1. Do a little trick as the patch below to tested the impact in the single core mode on Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz with no pkts.

app/pdump/main.c +0 -0

index 3d208548fa13..804011b187c4 100644

--- a/app/pdump/main.c

+++ b/app/pdump/main.c

@@ -141,7 +141,7 @@ struct parse_val {

static int num_tuples;

static struct rte_eth_conf port_conf_default;

-static volatile uint8_t quit_signal;

+static volatile uint32_t quit_signal;

static uint8_t multiple_core_capture;

/**< display usage */

@@ -868,6 +868,7 @@ struct parse_val {

dump_packets(void)

{

       int i;

+ uint64_t start, end;

       uint32_t lcore_id = 0;



       if (!multiple_core_capture) {

@@ -880,10 +881,20 @@ struct parse_val {

                              pdump_t[i].device_id,

                              pdump_t[i].queue);

- while (!quit_signal) {

+ /* make it hot */

+ rte_eal_primary_proc_alive(NULL);

+ rte_eal_primary_proc_alive(NULL)

+

+ start = rte_rdtsc();

+ while (quit_signal < 50000) {

+ /* Just testing with and w/o the 'if' line below */

+ if (rte_eal_primary_proc_alive(NULL))

+ quit_signal++;

                      for (i = 0; i < num_tuples; i++)

                              pdump_packets(&pdump_t[i]);

               }

+ end = rte_rdtsc();

+ printf("Totally count:%u, cost tsc:%lu\n", quit_signal, end - start);

               return;

       }

The total tsc cost is about 338809671 with rte_eal_primary_proc_alive().

And the tsc cost is just about 513573 without rte_eal_primary_proc_alive().

The dpdk-pdump had also used taskset to bind to specify isolate core.

So it seems the patch do a great performance impact.

Response> thanks for confirming the suspicion.

Maybe another async method should be introduced to monitor the primary status.

Response> yes, without affecting the capture thread.

2. For various packet sizes and port speed what are delta in drops for packet capture?

A2. Refer to A1, it's not needed anymore.

Response> A1 there is performance impact.

Note: If pdump application is still alive when primary is not running, primary cannot be started. Is this a cue that pdump is still alive and has to be terminated?

Yes, some guys complained that the residual dpdk-pdump impact the restart of the primary app and refuse to add other mechanisms e.g. to kill the dpdk-pdump in the app to avoid that case.

So the patch was created.

Is there any other ways to avoid that.

Response> in my humble opinion, best way around is add user option like ‘--exit’; which then will add periodic rte_timer for user desired seconds ‘0.1, 0.5, 1.0, 5.0’. The timer callback can run on master core which sets ‘quit_signal’ once primary is no longer alive. In case of ‘multi thread’ capture master thread is not involved in dump_packets thus avoiding any packet drops or performance issue..

#4 lore raw

I will leave this suggestion open for comments from the maintainer.

snipped

Hi,

Looks like something in email format setting is affecting the style. Please find my replies below snipped

As per the current suggested code flow check is added to while loop in function `dump_packets'.

Thanks for the reply. Since want to make it clean, the code was here.

However, it seems need to take care of the performance impact first.

Response> thanks for acknowledging the same.

Questions:

1. What is impact in performance with and without patch?

A1. Do a little trick as the patch below to tested the impact in the single core mode on Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz with no pkts.

app/pdump/main.c +0 -0

index 3d208548fa13..804011b187c4 100644

--- a/app/pdump/main.c

+++ b/app/pdump/main.c

@@ -141,7 +141,7 @@ struct parse_val {

static int num_tuples;

static struct rte_eth_conf port_conf_default;

-static volatile uint8_t quit_signal;

+static volatile uint32_t quit_signal;

static uint8_t multiple_core_capture;

/**< display usage */

@@ -868,6 +868,7 @@ struct parse_val {

dump_packets(void)

{

       int i;

+ uint64_t start, end;

       uint32_t lcore_id = 0;



       if (!multiple_core_capture) {

@@ -880,10 +881,20 @@ struct parse_val {

                              pdump_t[i].device_id,

                              pdump_t[i].queue);

- while (!quit_signal) {

+ /* make it hot */

+ rte_eal_primary_proc_alive(NULL);

+ rte_eal_primary_proc_alive(NULL)

+

+ start = rte_rdtsc();

+ while (quit_signal < 50000) {

+ /* Just testing with and w/o the 'if' line below */

+ if (rte_eal_primary_proc_alive(NULL))

+ quit_signal++;

                      for (i = 0; i < num_tuples; i++)

                              pdump_packets(&pdump_t[i]);

               }

+ end = rte_rdtsc();

+ printf("Totally count:%u, cost tsc:%lu\n", quit_signal, end - start);

               return;

       }

The total tsc cost is about 338809671 with rte_eal_primary_proc_alive().

And the tsc cost is just about 513573 without rte_eal_primary_proc_alive().

The dpdk-pdump had also used taskset to bind to specify isolate core.

So it seems the patch do a great performance impact.

Response> thanks for confirming the suspicion.

Maybe another async method should be introduced to monitor the primary status.

Response> yes, without affecting the capture thread.

2. For various packet sizes and port speed what are delta in drops for packet capture?

A2. Refer to A1, it's not needed anymore.

Response> A1 there is performance impact.

Note: If pdump application is still alive when primary is not running, primary cannot be started. Is this a cue that pdump is still alive and has to be terminated?

Yes, some guys complained that the residual dpdk-pdump impact the restart of the primary app and refuse to add other mechanisms e.g. to kill the dpdk-pdump in the app to avoid that case.

So the patch was created.

Is there any other ways to avoid that.

Response> in my humble opinion, best way around is add user option like ‘--exit’; which then will add periodic rte_timer for user desired seconds ‘0.1, 0.5, 1.0, 5.0’. The timer callback can run on master core which sets ‘quit_signal’ once primary is no longer alive. In case of ‘multi thread’ capture master thread is not involved in dump_packets thus avoiding any packet drops or performance issue..

#5 lore raw
Quoted 3 lines · Vipin

I will leave this suggestion open for comments from the maintainer.

Hi,

Thanks for your suggestion. I have also tried to add an slave core to monitor the primary status this afternoon.  It works.

I doubt if it can be add an new option as you suggested, but which will also require people who complain the exiting to add an extra slave core for that.

Please waiting for the new patch in one or two days.

Quoted 79 lines

snipped

Hi,

Looks like something in email format setting is affecting the style. Please find my replies below

snipped

As per the current suggested code flow check is added to while loop in function `dump_packets'.

Thanks for the reply. Since want to make it clean, the code was here. However, it seems need to take care of the performance impact first. Response> thanks for acknowledging the same.

Questions:

1. What is impact in performance with and without patch?

A1. Do a little trick as the patch below to tested the impact in the single core mode on Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz with no pkts.

app/pdump/main.c +13 -2
index 3d208548fa13..804011b187c4 100644
@@ -141,7 +141,7 @@ struct parse_val {
 
  static int num_tuples;
  static struct rte_eth_conf port_conf_default;
-static volatile uint8_t quit_signal;
+static volatile uint32_t quit_signal;
  static uint8_t multiple_core_capture;
 
  /**< display usage */
@@ -868,6 +868,7 @@ struct parse_val {
  dump_packets(void)
  {
        int i;
+      uint64_t start, end;
        uint32_t lcore_id = 0;
 
        if (!multiple_core_capture) {
@@ -880,10 +881,20 @@ struct parse_val {
                               pdump_t[i].device_id,
                               pdump_t[i].queue);
 
-              while (!quit_signal) {
+              /* make it hot */
+              rte_eal_primary_proc_alive(NULL);
+              rte_eal_primary_proc_alive(NULL)
+
+              start = rte_rdtsc();
+              while (quit_signal < 50000) {
+                     /* Just testing with and w/o the 'if' line below */
+                     if (rte_eal_primary_proc_alive(NULL))
+                             quit_signal++;
                       for (i = 0; i < num_tuples; i++)
                               pdump_packets(&pdump_t[i]);
                }
+              end = rte_rdtsc();
+              printf("Totally count:%u, cost tsc:%lu\n", quit_signal, end - start);
 
                return;
        }

The total tsc cost is about 338809671 with rte_eal_primary_proc_alive(). And the tsc cost is just about 513573 without rte_eal_primary_proc_alive(). The dpdk-pdump had also used taskset to bind to specify isolate core. So it seems the patch do a great performance impact.
Response> thanks for confirming the suspicion.
Maybe another async method should be introduced to monitor the primary status. Response> yes, without affecting the capture thread.

2. For various packet sizes and port speed what are delta in drops for packet capture?

A2. Refer to A1, it's not needed anymore.
Response> A1 there is performance impact.
Note: If pdump application is still alive when primary is not running, primary cannot be started. Is this a cue that pdump is still alive and has to be terminated?
Yes, some guys complained that the residual dpdk-pdump impact the restart of the primary app and refuse to add other mechanisms e.g. to kill the dpdk-pdump in the app to avoid that case.
So the patch was created.
Is there any other ways to avoid that.
Response> in my humble opinion, best way around is add user option like ‘--exit’; which then will add periodic rte_timer for user desired seconds ‘0.1, 0.5, 1.0, 5.0’. The timer callback can run on master core which sets ‘quit_signal’ once primary is no longer alive. In case of ‘multi thread’ capture master thread is not involved in dump_packets thus avoiding any packet drops or performance issue..

#6 lore raw
Quoted 5 lines · Suanming.Mou
Quoted 3 lines · Vipin

I will leave this suggestion open for comments from the maintainer.

Quoted 8 lines

Hi,

Thanks for your suggestion. I have also tried to add an slave core to monitor the primary status this afternoon.  It works.

I doubt if it can be add an new option as you suggested, but which will also require people who complain the exiting to add an extra slave core for that.

Please waiting for the new patch in one or two days.

You can use alarm API to check for this regularly. It's not like the interrupt thread is doing much anyway. Just set alarm to fire every N seconds, and that's it.

Signature · 2 lines
Thanks,
Anatoly
#7 lore raw
Quoted 8 lines · Anatoly
Quoted 7 lines · Suanming.Mou
Quoted 3 lines · Vipin

I will leave this suggestion open for comments from the maintainer.

Hi,

Quoted 8 lines
Quoted 6 lines

Thanks for your suggestion. I have also tried to add an slave core to monitor the primary status this afternoon.  It works.

I doubt if it can be add an new option as you suggested, but which will also require people who complain the exiting to add an extra slave core for that.

Please waiting for the new patch in one or two days.

You can use alarm API to check for this regularly. It's not like the interrupt thread is doing much anyway. Just set alarm to fire every N seconds, and that's it.

Hi,

Thank you very much for the suggestion. Yes, that seems the best solution.  Just tested it roughly as the code below:

+static void monitor_primary(void *arg __rte_unused)
+{
+    if (quit_signal)
+        return;
+
+    if (rte_eal_primary_proc_alive(NULL))
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL); +    else
+        quit_signal = 1;
+
+    return;
+}
+
 static inline void
 dump_packets(void)
 {
     int i;
     uint32_t lcore_id = 0;

+    if (exit_with_primary)
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL); +

I will prepare the patch with option exit_with_primary.

Br,

Mou

#8 lore raw
Quoted 47 lines · Suanming.Mou
Quoted 8 lines · Anatoly
Quoted 7 lines · Suanming.Mou
Quoted 3 lines · Vipin

I will leave this suggestion open for comments from the maintainer.

Hi,

Quoted 8 lines
Quoted 6 lines

Thanks for your suggestion. I have also tried to add an slave core to monitor the primary status this afternoon.  It works.

I doubt if it can be add an new option as you suggested, but which will also require people who complain the exiting to add an extra slave core for that.

Please waiting for the new patch in one or two days.

You can use alarm API to check for this regularly. It's not like the interrupt thread is doing much anyway. Just set alarm to fire every N seconds, and that's it.

Hi,

Thank you very much for the suggestion. Yes, that seems the best solution.  Just tested it roughly as the code below:

(quoted diff) +16 -0
+static void monitor_primary(void *arg __rte_unused)
+{
+    if (quit_signal)
+        return;
+
+    if (rte_eal_primary_proc_alive(NULL))
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+    else
+        quit_signal = 1;
+
+    return;
+}
+
  static inline void
  dump_packets(void)
  {
      int i;
      uint32_t lcore_id = 0;
 
+    if (exit_with_primary)
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+
Quoted 2 lines

I will prepare the patch with option exit_with_primary.

Actually, i'm curious if this really does work. Unless my knowledge is out of date, interrupt thread doesn't work in secondary processes, and by extension neither should the alarm API...

Signature · 2 lines
Thanks,
Anatoly
#9 lore raw
Quoted 48 lines · Anatoly
Quoted 47 lines · Suanming.Mou
Quoted 8 lines · Anatoly
Quoted 7 lines · Suanming.Mou
Quoted 3 lines · Vipin

I will leave this suggestion open for comments from the maintainer.

Hi,

Quoted 8 lines
Quoted 6 lines

Thanks for your suggestion. I have also tried to add an slave core to monitor the primary status this afternoon.  It works.

I doubt if it can be add an new option as you suggested, but which will also require people who complain the exiting to add an extra slave core for that.

Please waiting for the new patch in one or two days.

You can use alarm API to check for this regularly. It's not like the interrupt thread is doing much anyway. Just set alarm to fire every N seconds, and that's it.

Hi,

Thank you very much for the suggestion. Yes, that seems the best solution.  Just tested it roughly as the code below:

(quoted diff) +13 -0
+static void monitor_primary(void *arg __rte_unused)
+{
+    if (quit_signal)
+        return;
+
+    if (rte_eal_primary_proc_alive(NULL))
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+    else
+        quit_signal = 1;
+
+    return;
+}
+

  static inline void
  dump_packets(void)
  {
      int i;
      uint32_t lcore_id = 0;

+    if (exit_with_primary)
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL); +

Quoted 4 lines
Quoted 2 lines

I will prepare the patch with option exit_with_primary.

Actually, i'm curious if this really does work. Unless my knowledge is out of date, interrupt thread doesn't work in secondary processes, and by extension neither should the alarm API...

Uh... If I understand correctly, the alarm API has used in the secondary before.

Refer to handle_primary_request()....

#10 lore raw
Quoted 50 lines · Suanming.Mou
Quoted 48 lines · Anatoly
Quoted 47 lines · Suanming.Mou
Quoted 8 lines · Anatoly
Quoted 7 lines · Suanming.Mou
Quoted 3 lines · Vipin

I will leave this suggestion open for comments from the maintainer.

Hi,

Quoted 8 lines
Quoted 6 lines

Thanks for your suggestion. I have also tried to add an slave core to monitor the primary status this afternoon.  It works.

I doubt if it can be add an new option as you suggested, but which will also require people who complain the exiting to add an extra slave core for that.

Please waiting for the new patch in one or two days.

You can use alarm API to check for this regularly. It's not like the interrupt thread is doing much anyway. Just set alarm to fire every N seconds, and that's it.

Hi,

Thank you very much for the suggestion. Yes, that seems the best solution.  Just tested it roughly as the code below:

(quoted diff) +13 -0
+static void monitor_primary(void *arg __rte_unused)
+{
+    if (quit_signal)
+        return;
+
+    if (rte_eal_primary_proc_alive(NULL))
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+    else
+        quit_signal = 1;
+
+    return;
+}
+

  static inline void
  dump_packets(void)
  {
      int i;
      uint32_t lcore_id = 0;

+    if (exit_with_primary)
+        rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL); +

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

I will prepare the patch with option exit_with_primary.

Actually, i'm curious if this really does work. Unless my knowledge is out of date, interrupt thread doesn't work in secondary processes, and by extension neither should the alarm API...

Uh... If I understand correctly, the alarm API has used in the secondary before.

Refer to handle_primary_request()....

Then my knowledge really is out of date :)

Signature · 2 lines
Thanks,
Anatoly
#11 lore raw

PATCH v2 1/1 app/pdump: add exit_with_primary option support.

In reply to Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add an exit_with_primary option to make pdump exit with primary.

---
 app/pdump/main.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
app/pdump/main.c +26 -0
index 3d20854..3909f15 100644
@@ -26,11 +26,14 @@
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 
 #define CMD_LINE_OPT_PDUMP "pdump"
 #define CMD_LINE_OPT_PDUMP_NUM 256
 #define CMD_LINE_OPT_MULTI "multi"
 #define CMD_LINE_OPT_MULTI_NUM 257
+#define CMD_LINE_OPT_EXIT_WP "exit_with_primary"
+#define CMD_LINE_OPT_EXIT_WP_NUM 258
 #define PDUMP_PORT_ARG "port"
 #define PDUMP_PCI_ARG "device_id"
 #define PDUMP_QUEUE_ARG "queue"
@@ -65,6 +68,7 @@
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+#define MONITOR_INTERVEL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -143,12 +147,14 @@ struct parse_val {
 static struct rte_eth_conf port_conf_default;
 static volatile uint8_t quit_signal;
 static uint8_t multiple_core_capture;
+static uint8_t exit_with_primary;
 
 /**< display usage */
 static void
 pdump_usage(const char *prgname)
 {
 	printf("usage: %s [EAL options]"
+			" --["CMD_LINE_OPT_EXIT_WP"]"
 			" --["CMD_LINE_OPT_MULTI"]\n"
 			" --"CMD_LINE_OPT_PDUMP" "
 			"'(port=<port id> | device_id=<pci id or vdev name>),"
@@ -383,6 +389,7 @@ struct parse_val {
 	static struct option long_option[] = {
 		{CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM},
 		{CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM},
+		{CMD_LINE_OPT_EXIT_WP, 0, 0, CMD_LINE_OPT_EXIT_WP_NUM},
 		{NULL, 0, 0, 0}
 	};
 
@@ -403,6 +410,9 @@ struct parse_val {
 		case CMD_LINE_OPT_MULTI_NUM:
 			multiple_core_capture = 1;
 			break;
+		case CMD_LINE_OPT_EXIT_WP_NUM:
+			exit_with_primary = 1;
+			break;
 		default:
 			pdump_usage(prgname);
 			return -1;
@@ -864,12 +874,28 @@ struct parse_val {
 	return 0;
 }
 
+static void monitor_primary(void *arg __rte_unused)
+{
+	if (quit_signal)
+		return;
+
+	if (rte_eal_primary_proc_alive(NULL))
+		rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+	else
+		quit_signal = 1;
+
+	return;
+}
+
 static inline void
 dump_packets(void)
 {
 	int i;
 	uint32_t lcore_id = 0;
 
+	if (exit_with_primary)
+		rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+
 	if (!multiple_core_capture) {
 		printf(" core (%u), capture for (%d) tuples\n",
 				rte_lcore_id(), num_tuples);
Signature · 1 line
1.8.3.4
#12 lore raw

PATCH v3 1/1 app/pdump: add exit_with_primary option support.

When primary app exits, the residual running pdump will stop the primary app to restart. Add an exit_with_primary option to make pdump exit with primary.

---
 app/pdump/main.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
app/pdump/main.c +24 -0
index 3d20854..b69ef4e 100644
@@ -26,11 +26,14 @@
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 
 #define CMD_LINE_OPT_PDUMP "pdump"
 #define CMD_LINE_OPT_PDUMP_NUM 256
 #define CMD_LINE_OPT_MULTI "multi"
 #define CMD_LINE_OPT_MULTI_NUM 257
+#define CMD_LINE_OPT_EXIT_WP "exit_with_primary"
+#define CMD_LINE_OPT_EXIT_WP_NUM 258
 #define PDUMP_PORT_ARG "port"
 #define PDUMP_PCI_ARG "device_id"
 #define PDUMP_QUEUE_ARG "queue"
@@ -65,6 +68,7 @@
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+#define MONITOR_INTERVEL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -143,12 +147,14 @@ struct parse_val {
 static struct rte_eth_conf port_conf_default;
 static volatile uint8_t quit_signal;
 static uint8_t multiple_core_capture;
+static uint8_t exit_with_primary;
 
 /**< display usage */
 static void
 pdump_usage(const char *prgname)
 {
 	printf("usage: %s [EAL options]"
+			" --["CMD_LINE_OPT_EXIT_WP"]"
 			" --["CMD_LINE_OPT_MULTI"]\n"
 			" --"CMD_LINE_OPT_PDUMP" "
 			"'(port=<port id> | device_id=<pci id or vdev name>),"
@@ -383,6 +389,7 @@ struct parse_val {
 	static struct option long_option[] = {
 		{CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM},
 		{CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM},
+		{CMD_LINE_OPT_EXIT_WP, 0, 0, CMD_LINE_OPT_EXIT_WP_NUM},
 		{NULL, 0, 0, 0}
 	};
 
@@ -403,6 +410,9 @@ struct parse_val {
 		case CMD_LINE_OPT_MULTI_NUM:
 			multiple_core_capture = 1;
 			break;
+		case CMD_LINE_OPT_EXIT_WP_NUM:
+			exit_with_primary = 1;
+			break;
 		default:
 			pdump_usage(prgname);
 			return -1;
@@ -864,12 +874,26 @@ struct parse_val {
 	return 0;
 }
 
+static void monitor_primary(void *arg __rte_unused)
+{
+	if (quit_signal)
+		return;
+
+	if (rte_eal_primary_proc_alive(NULL))
+		rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+	else
+		quit_signal = 1;
+}
+
 static inline void
 dump_packets(void)
 {
 	int i;
 	uint32_t lcore_id = 0;
 
+	if (exit_with_primary)
+		rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+
 	if (!multiple_core_capture) {
 		printf(" core (%u), capture for (%d) tuples\n",
 				rte_lcore_id(), num_tuples);
Signature · 1 line
1.8.3.4
#13 lore raw

PATCH v4 1/1 app/pdump: add pudmp exits with primary support.

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---
 app/pdump/main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
app/pdump/main.c +16 -0
index 3d20854..c3413da 100644
@@ -26,6 +26,7 @@
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 
 #define CMD_LINE_OPT_PDUMP "pdump"
 #define CMD_LINE_OPT_PDUMP_NUM 256
@@ -65,6 +66,7 @@
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+#define MONITOR_INTERVAL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -864,12 +866,26 @@ struct parse_val {
 	return 0;
 }
 
+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 inline void
 dump_packets(void)
 {
 	int i;
 	uint32_t lcore_id = 0;
 
+	/* Once primary exits, so will pdump. */
+	rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL);
+
 	if (!multiple_core_capture) {
 		printf(" core (%u), capture for (%d) tuples\n",
 				rte_lcore_id(), num_tuples);
Signature · 1 line
1.8.3.4
#14 lore raw

Re: [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support.

Thanks for the patch work with rte_eal_alaram. But I am not able to find

1. the documentation update.
2. cover letter.
3. for signal SIGINT, set for rte_eal_alarm_cancel.

Can you share a new patch as v5 with these changes?

Thanks
Vipin Varghese

Quoted 67 lines

-----Original Message-----
From: Suanming.Mou <[email protected]>
Sent: Tuesday, April 30, 2019 9:09 AM
To: [email protected]
Cc: Varghese, Vipin <[email protected]>; Burakov, Anatoly <[email protected]>
Subject: [PATCH v4] app/pdump: add pudmp exits with primary support.

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---
 app/pdump/main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
app/pdump/main.c index 3d20854..c3413da renamed from app/pdump/main.c +0 -0

100644

app/pdump/main.c +2 -0
@@ -26,6 +26,7 @@
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 
 #define CMD_LINE_OPT_PDUMP "pdump"
 #define CMD_LINE_OPT_PDUMP_NUM 256
@@ -65,6 +66,7 @@
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+#define MONITOR_INTERVAL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -864,12 +866,26 @@ struct

parse_val {

app/pdump/main.c +6 -0
 	return 0;
 }
 
+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);

app/pdump/main.c +7 -1
+	else
+		quit_signal = 1;
+}
+
 static inline void
 dump_packets(void)
 {
 	int i;
 	uint32_t lcore_id = 0;
 
+	/* Once primary exits, so will pdump. */
+	rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL);
+
 	if (!multiple_core_capture) {
 		printf(" core (%u), capture for (%d) tuples\n",
 				rte_lcore_id(), num_tuples);
--

1.8.3.4

#15 lore raw

Re: [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support.

Quoted 3 lines · Vipin

Thanks for the patch work with rte_eal_alaram. But I am not able to find

1. the documentation update.

I'd like to reconfirm that since Anatoly suggested to make the option default, I deleted the option supporting code.

Is it aligned that we can make it default?

If it is aligned to make it default, then if I understand correctly, to add a new note in the documentation to describe pdump will exit with primary will be OK?

Quoted 1 line

2. cover letter.

Sorry for that. Will add the cover letter in the V5 patch.

Quoted 1 line

3. for signal SIGINT, set for rte_eal_alarm_cancel.

Ah, yes.

Quoted 2 lines

Can you share a new patch as v5 with these changes?

Thanks for your reviewing. I will send the next patch after Q1 confirmed.

Quoted 74 lines

Thanks
Vipin Varghese

Quoted 66 lines

-----Original Message-----
From: Suanming.Mou <[email protected]>
Sent: Tuesday, April 30, 2019 9:09 AM
To: [email protected]
Cc: Varghese, Vipin <[email protected]>; Burakov, Anatoly <[email protected]>
Subject: [PATCH v4] app/pdump: add pudmp exits with primary support.

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---
  app/pdump/main.c | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
app/pdump/main.c index 3d20854..c3413da renamed from app/pdump/main.c +0 -0

100644

app/pdump/main.c +2 -0
@@ -26,6 +26,7 @@
  #include <rte_ring.h>
  #include <rte_string_fns.h>
  #include <rte_pdump.h>
+#include <rte_alarm.h>
 
  #define CMD_LINE_OPT_PDUMP "pdump"
  #define CMD_LINE_OPT_PDUMP_NUM 256
@@ -65,6 +66,7 @@
  #define SIZE 256
  #define BURST_SIZE 32
  #define NUM_VDEVS 2
+#define MONITOR_INTERVAL (500 * 1000)
 
  /* true if x is a power of 2 */
  #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -864,12 +866,26 @@ struct

parse_val {
return 0;
}

app/pdump/main.c +6 -0
+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);

app/pdump/main.c +7 -1
+	else
+		quit_signal = 1;
+}
+
  static inline void
  dump_packets(void)
  {
  	int i;
  	uint32_t lcore_id = 0;
 
+	/* Once primary exits, so will pdump. */
+	rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL);
+
  	if (!multiple_core_capture) {
  		printf(" core (%u), capture for (%d) tuples\n",
  				rte_lcore_id(), num_tuples);
--
Quoted 1 line

1.8.3.4

.

#16 lore raw

Re: [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support.

snipped

Quoted 10 lines
Quoted 2 lines

1. the documentation update.

I'd like to reconfirm that since Anatoly suggested to make the option default, I deleted the option supporting code.

Is it aligned that we can make it default?

If it is aligned to make it default, then if I understand correctly, to add a new note in the documentation to describe pdump will exit with primary will be OK?

I am not aware of the conversation and will leave this to maintainer if the option should be --exit-with-primary or --do-not-exit-primary.

Please add the changes to doc/guides/tools/proc_info.rst of the changes and new option that gets added.

Quoted 3 lines
Quoted 2 lines

2. cover letter.

Sorry for that. Will add the cover letter in the V5 patch.

thanks

Quoted 2 lines
Quoted 1 line

3. for signal SIGINT, set for rte_eal_alarm_cancel.

Ah, yes.

Thanks

Quoted 3 lines
Quoted 2 lines

Can you share a new patch as v5 with these changes?

Thanks for your reviewing. I will send the next patch after Q1 confirmed.

Ok

snipped

#17 lore raw

Re: [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support.

In reply to Varghese, Vipin
Quoted 4 lines · Vipin

Thanks for the patch work with rte_eal_alaram. But I am not able to find

1. the documentation update.
2. cover letter.

Why would a single patch need a cover letter? I don't think it's needed in this case. The commit message is enough.

Quoted 7 lines

3. for signal SIGINT, set for rte_eal_alarm_cancel.

Can you share a new patch as v5 with these changes?

Thanks
Vipin Varghese

Signature · 2 lines
Thanks,
Anatoly
#18 lore raw

Re: [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support.

snipped

Quoted 8 lines
Quoted 5 lines

Thanks for the patch work with rte_eal_alaram. But I am not able to find

1. the documentation update.
2. cover letter.

Why would a single patch need a cover letter? I don't think it's needed in this case. The commit message is enough.

In my opinion, the cover letter is to be added as it is new feature and explains the reasoning behind the new change. Please let me know if there change in the same?

snipped

#19 lore raw

Re: [dpdk-dev] [PATCH v4] app/pdump: add pudmp exits with primary support.

Quoted 7 lines · Vipin

snipped

Quoted 6 lines
Quoted 5 lines

Thanks for the patch work with rte_eal_alaram. But I am not able to find

1. the documentation update.
2. cover letter.

Quoted 7 lines
Quoted 2 lines

Why would a single patch need a cover letter? I don't think it's needed in this case. The commit message is enough.

In my opinion, the cover letter is to be added as it is new feature and explains the reasoning behind the new change. Please let me know if there change in the same?

snipped

I'm obviously not an expert in cover letters, but in my view, cover letter is only necessary whenever there is a complex patchset that requires some explanation, background, etc. If there is only one patch, everything that you could reasonably put in the cover letter should go either into the commit message itself, or into commit notes if there is some supplemental data (e.g. benchmark results etc.). Creating cover letters for single patches is just unnecessary work IMO.

Signature · 2 lines
Thanks,
Anatoly
#20 lore raw

PATCH v5 1/1 Make pdump exits with primary.

In reply to Suanming.Mou

When primary exits, pdump as the sencondary keeps running will make primary fail to restart. Add the primary monitor in pdump to make it eixts with primary.

Note:
One more thing still not confirmed is that if it can be set default. In the V5 patch, it is still set as default. Since it seems there is no disadvantages to make it exit with primary as default as Anatoly suggested. But the exit_with_primary configuration is needed, there will be a v6 patch and the doc update.

Change in v5:
- add rte_eal_alarm_cancel
- make the primary monitor enable/disable more indepence.

Change in v4:
- remove the exit_with_primary option as Anatoly suggested.
- fix typo.

Change in v3:
- remove the redundant return.

Change in v2:
- add exit_with_primary option.
- use rte_eal_alarm_set to monitor the primary.

Suanming.Mou (1):
app/pdump: add pudmp exits with primary support.

 app/pdump/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.4
#21 lore raw

PATCH v5 1/1 app/pdump: add pudmp exits with primary support.

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---
 app/pdump/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
app/pdump/main.c +42 -1
index 3d20854..cc46f65 100644
@@ -26,6 +26,7 @@
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 
 #define CMD_LINE_OPT_PDUMP "pdump"
 #define CMD_LINE_OPT_PDUMP_NUM 256
@@ -65,6 +66,7 @@
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+#define MONITOR_INTERVAL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -413,6 +415,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 +551,18 @@ 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. */
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor fail:%d\n", ret);
+}
+
+static void
 signal_handler(int sig_num)
 {
 	if (sig_num == SIGINT) {
@@ -910,6 +936,19 @@ 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) {
+		cleanup_pdump_resources();
+		rte_exit(EXIT_FAILURE, "Fail to monitor primary:%d\n", ret);
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -950,11 +989,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();
Signature · 1 line
1.8.3.4
#22 lore raw

Re: [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support.

Quoted 7 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---

<snip>

app/pdump/main.c struct parse_val { · line 562

Quoted 10 lines

static void

app/pdump/main.c +9 -0
+disable_primary_monitor(void)
+{
+	int ret;
+
+	/* Don't worry about it is primary exit case. The alarm cancel
+	 * function will take care about that. */
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor fail:%d\n", ret);

Double fail :)

Quoted 11 lines
app/pdump/main.c +4 -0
+}
+
+static void
  signal_handler(int sig_num)
  {
  	if (sig_num == SIGINT) {
@@ -910,6 +936,19 @@ struct parse_val {
  		;
  }
 
+static void

app/pdump/main.c struct parse_val { · line 949

Quoted 10 lines
app/pdump/main.c +10 -0
+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) {
+		cleanup_pdump_resources();
+		rte_exit(EXIT_FAILURE, "Fail to monitor primary:%d\n", ret);
+	}

Why is this function void, when you could've called rte_exit() in the caller on failure? And why is it such a fatal error to set up the timer? IMO just a warning would've been enough.

Quoted 21 lines
app/pdump/main.c +5 -1
+}
+
  int
  main(int argc, char **argv)
  {
@@ -950,11 +989,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();
Signature · 2 lines
Thanks,
Anatoly
#23 lore raw

Re: [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support.

Quoted 11 lines · Anatoly
Quoted 7 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---

<snip>

Quoted 12 lines

app/pdump/main.c struct parse_val { · line 562

Quoted 10 lines

  static void

app/pdump/main.c +9 -0
+disable_primary_monitor(void)
+{
+    int ret;
+
+    /* Don't worry about it is primary exit case. The alarm cancel
+     * function will take care about that. */
+    ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+    if (ret < 0)
+        printf("Fail to disable monitor fail:%d\n", ret);

Double fail :)

Ah, yes, sorry for that the code gets worse.  :(

Quoted 15 lines
Quoted 15 lines
app/pdump/main.c +3 -0
+}
+
+static void

  signal_handler(int sig_num)
  {
      if (sig_num == SIGINT) {

(quoted diff) +0 -0
@@ -910,6 +936,19 @@ struct parse_val {
           ;
   }

  +static void

app/pdump/main.c +4 -0
+enable_primary_monitor(void)
+{
+    int ret;
+
Quoted 8 lines
Quoted 6 lines

+    /* Once primary exits, so will pdump. */
+    ret = rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL); +    if (ret < 0) {
+        cleanup_pdump_resources();
+        rte_exit(EXIT_FAILURE, "Fail to monitor primary:%d\n", ret); +    }

Why is this function void, when you could've called rte_exit() in the caller on failure? And why is it such a fatal error to set up the timer? IMO just a warning would've been enough.

Here comes with two issues:

Q1. The return value of the function:

A1: I'm so sorry that it does not seem to make sense to check the function's return value. Does it mean if we change the timer set up from error to warning, then we can use the return value to judge if need to disable the primary_monitor?

Q2. The choice when rte_eal_alarm_set fail:

A2: OK, agree with that.

Quoted 22 lines
Quoted 20 lines
(quoted diff) +2 -0
+}
+

  int
  main(int argc, char **argv)
  {

app/pdump/main.c +0 -0
@@ -950,11 +989,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();

#24 lore raw

Re: [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support.

Quoted 52 lines · Suanming.Mou
Quoted 11 lines · Anatoly
Quoted 7 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---

<snip>

Quoted 12 lines

app/pdump/main.c struct parse_val { · line 562

Quoted 10 lines

  static void

app/pdump/main.c +9 -0
+disable_primary_monitor(void)
+{
+    int ret;
+
+    /* Don't worry about it is primary exit case. The alarm cancel
+     * function will take care about that. */
+    ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+    if (ret < 0)
+        printf("Fail to disable monitor fail:%d\n", ret);

Double fail :)

Ah, yes, sorry for that the code gets worse.  :(

Quoted 15 lines
Quoted 15 lines
app/pdump/main.c +3 -0
+}
+
+static void

  signal_handler(int sig_num)
  {
      if (sig_num == SIGINT) {

(quoted diff) +0 -0
@@ -910,6 +936,19 @@ struct parse_val {
           ;
   }

  +static void

app/pdump/main.c +4 -0
+enable_primary_monitor(void)
+{
+    int ret;
+
Quoted 8 lines
Quoted 6 lines

+    /* Once primary exits, so will pdump. */
+    ret = rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL); +    if (ret < 0) {
+        cleanup_pdump_resources();
+        rte_exit(EXIT_FAILURE, "Fail to monitor primary:%d\n", ret); +    }

Why is this function void, when you could've called rte_exit() in the caller on failure? And why is it such a fatal error to set up the timer? IMO just a warning would've been enough.

Here comes with two issues:

Quoted 7 lines

Q1. The return value of the function:

A1: I'm so sorry that it does not seem to make sense to check the function's return value. Does it mean if we change the timer set up from error to warning, then we can use the return value to judge if need to disable the primary_monitor?

Q2. The choice when rte_eal_alarm_set fail:

A2: OK, agree with that.

If this is non-fatal, no need to change anything - just print out a warning instead of rte_exit, and no more changes needed here.

Quoted 25 lines
Quoted 23 lines
Quoted 21 lines
(quoted diff) +2 -0
+}
+

  int
  main(int argc, char **argv)
  {

app/pdump/main.c +0 -0
@@ -950,11 +989,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();

Signature · 2 lines
Thanks,
Anatoly
#25 lore raw

Re: [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support.

Quoted 55 lines · Anatoly
Quoted 54 lines · Suanming.Mou
Quoted 11 lines · Anatoly
Quoted 7 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---

<snip>

Quoted 12 lines

app/pdump/main.c struct parse_val { · line 562

Quoted 10 lines

  static void

app/pdump/main.c +9 -0
+disable_primary_monitor(void)
+{
+    int ret;
+
+    /* Don't worry about it is primary exit case. The alarm cancel
+     * function will take care about that. */
+    ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+    if (ret < 0)
+        printf("Fail to disable monitor fail:%d\n", ret);

Double fail :)

Ah, yes, sorry for that the code gets worse.  :(

Quoted 15 lines
Quoted 15 lines
app/pdump/main.c +3 -0
+}
+
+static void

  signal_handler(int sig_num)
  {
      if (sig_num == SIGINT) {

(quoted diff) +0 -0
@@ -910,6 +936,19 @@ struct parse_val {
           ;
   }

  +static void

app/pdump/main.c +4 -0
+enable_primary_monitor(void)
+{
+    int ret;
+
Quoted 8 lines
Quoted 6 lines

+    /* Once primary exits, so will pdump. */
+    ret = rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL); +    if (ret < 0) {
+        cleanup_pdump_resources();
+        rte_exit(EXIT_FAILURE, "Fail to monitor primary:%d\n", ret); +    }

Why is this function void, when you could've called rte_exit() in the caller on failure? And why is it such a fatal error to set up the timer? IMO just a warning would've been enough.

Here comes with two issues:

Q1. The return value of the function:

Quoted 7 lines
Quoted 5 lines

A1: I'm so sorry that it does not seem to make sense to check the function's return value. Does it mean if we change the timer set up from error to warning, then we can use the return value to judge if need to disable the primary_monitor?

Q2. The choice when rte_eal_alarm_set fail:

A2: OK, agree with that.

If this is non-fatal, no need to change anything - just print out a warning instead of rte_exit, and no more changes needed here.

Happy may day holiday! Thanks for your confirmation.

Quoted 28 lines
Quoted 26 lines
Quoted 24 lines
Quoted 22 lines
(quoted diff) +2 -0
+}
+

  int
  main(int argc, char **argv)
  {

app/pdump/main.c +0 -0
@@ -950,11 +989,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();

#26 lore raw

Re: [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support.

In reply to Suanming.Mou
Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Suanming.Mou
Sent: Tuesday, April 30, 2019 12:35 PM
To: [email protected]
Cc: Varghese, Vipin <[email protected]>; Burakov, Anatoly <[email protected]>
Subject: [dpdk-dev] [PATCH v5] app/pdump: add pudmp exits with primary support.

Quoted 6 lines

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

You need to run below scripts, and fix the issues reported before sending next version.

1)
Ex:
export DPDK_CHECKPATCH_PATH=/usr/src/kernels/4.18.9-200.fc28.x86_64/scripts/checkpatch.pl [DPDK]# ./devtools/checkpatches.sh

### app/pdump: add pudmp exits with primary support.

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line #62: FILE: app/pdump/main.c:559:
+ * function will take care about that. */

total: 0 errors, 1 warnings, 83 lines checked

0/1 valid patch

2)
[DPDK]# ./devtools/check-git-log.sh
Wrong headline format:
app/pdump: add pudmp exits with primary support.

Need to remove full stop at the end.

Wrong tag:

Might need to remove ,

app/pdump/main.c line 30

Quoted 6 lines
app/pdump/main.c +1 -0
@@ -26,6 +26,7 @@
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 

Nitpick:

As per the coding guidelines(https://doc.dpdk.org/guides/contributing/coding_style.html) the order of the headers is below, so you can include rte_alarm.h after <rte_eal.h>

libc includes (system includes first)
DPDK EAL includes
DPDK misc libraries includes
application-specific includes

app/pdump/main.c line 69

Quoted 1 line
app/pdump/main.c +1 -0
+#define MONITOR_INTERVAL (500 * 1000)

Adding comment on how many ms/us would be helpful.

<snipped>

app/pdump/main.c struct parse_val { · line 559

Quoted 2 lines
app/pdump/main.c +2 -0
+	/* Don't worry about it is primary exit case. The alarm cancel
+	 * function will take care about that. */

Multiline comments should be like below.

/*
* Multi-line comments look like this. Make them real sentences. Fill
* them so they look like real paragraphs.
*/

Source: https://doc.dpdk.org/guides/contributing/coding_style.html

Thanks,
Reshma

#27 lore raw

PATCH v6 1/1 app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---

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(-)
app/pdump/main.c +43 -1
index 3d20854..947fea3 100644
@@ -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();
Signature · 1 line
1.8.3.4
#28 lore raw

Re: [dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support

Hi Suanming,

snipped

Quoted 3 lines

/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -413,6 +416,18 @@ struct

Can we use RTE_IS_POWER_OF_2(n) ' instead of POWEROF2`?

app/pdump/main.c struct parse_val { · line 428

Quoted 13 lines

parse_val { }

static void

app/pdump/main.c +6 -0
+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);

app/pdump/main.c +3 -0
+	else
+		quit_signal = 1;
+}

This is suggestion, why not omit else part with

`

if (rte_eal_primary_proc_alive(NULL)) {
	rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary,NULL);
	return;
}

`

Snipped

As suggested in v4 can you update the pdump.rst on the new behaviour?

Thanks
Vipin Varghese

#29 lore raw

Re: [dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support

Quoted 6 lines · Vipin

Hi Suanming,

snipped

Quoted 2 lines

/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -413,6 +416,18 @@ struct

Can we use RTE_IS_POWER_OF_2(n) ' instead of POWEROF2`?

I'm sorry, but that line is not add by this patch this time.

Maybe another commit is more suitable to fix the previous code.

Quoted 16 lines
Quoted 11 lines

parse_val { }

static void

app/pdump/main.c +6 -0
+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);

app/pdump/main.c struct parse_val { · line 428

Quoted 3 lines
app/pdump/main.c +3 -0
+	else
+		quit_signal = 1;
+}

This is suggestion, why not omit else part with

Quoted 6 lines

`

if (rte_eal_primary_proc_alive(NULL)) {
	rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary,NULL);
	return;
}

`

Thanks for the suggestion. It's OK for me. If there's one more vote, I will do it.

Quoted 4 lines

Snipped

As suggested in v4 can you update the pdump.rst on the new behaviour?

As noted in the cover letter in v5. The exit with primary configuration should be made as default or not is still not confirmed from the maintainer.

Since exit with primary is now removed in the patch and made as default per Anatoly's suggestion and not get more information from the maintainer, the update of the doc is also got hung up.

Quoted 5 lines

Thanks
Vipin Varghese

#30 lore raw

Re: [dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support

Quoted 4 lines · Suanming.Mou
Quoted 2 lines · Vipin

Hi Suanming,

Quoted 8 lines
Quoted 4 lines

snipped

Quoted 2 lines

  /* true if x is a power of 2 */
  #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -413,6 +416,18 @@ struct

Can we use RTE_IS_POWER_OF_2(n) ' instead of POWEROF2`?

I'm sorry, but that line is not add by this patch this time.

Maybe another commit is more suitable to fix the previous code.

Yes, if there are issues with the code that aren't directly related to the patch and aren't touched by it, they should be addressed as a separate patch.

Quoted 17 lines
Quoted 17 lines
Quoted 11 lines

parse_val {  }

  static void

app/pdump/main.c +6 -0
+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,
Quoted 4 lines

NULL);
+    else
+        quit_signal = 1;
+}

This is suggestion, why not omit else part with

Quoted 7 lines
Quoted 6 lines

`
if (rte_eal_primary_proc_alive(NULL)) { rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary,NULL); return;
}
`

Thanks for the suggestion. It's OK for me. If there's one more vote, I will do it.

No preference. Either way works, so i'd keep it as is.

Signature · 2 lines
Thanks,
Anatoly
#31 lore raw

Re: [dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou

HI Suanming,

snipped

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -413,6 +416,18 @@
struct

Can we use RTE_IS_POWER_OF_2(n) ' instead of POWEROF2`?

I'm sorry, but that line is not add by this patch this time.

Maybe another commit is more suitable to fix the previous code.

Ok

Snipped

Quoted 9 lines
Quoted 2 lines

As suggested in v4 can you update the pdump.rst on the new behaviour?

As noted in the cover letter in v5. The exit with primary configuration should be made as default or not is still not confirmed from the maintainer.

Since exit with primary is now removed in the patch and made as default per Anatoly's suggestion and not get more information from the maintainer, the update of the doc is also got hung up.

I am not clear with this, if there is change in behaviour of the application it has to be documented.

Thanks
Vipin Varghese

#32 lore raw

Re: [dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou
Quoted 4 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Suanming.Mou

<snip>

app/pdump/main.c struct parse_val { · line 429

Quoted 12 lines

static void

app/pdump/main.c +6 -0
+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);

app/pdump/main.c +4 -0
+	else
+		quit_signal = 1;
+}
+

Adding the log message saying primary existing so, secondary.. would be helpful here. I am ok to have it as default behaviour.
As Vipin mentioned, can you also update the document doc/guides/tools/pdump.rst

Thanks,
Reshma

#33 lore raw

Re: [dpdk-dev] [PATCH v6] app/pdump: add pudmp exits with primary support

Hi,

Thanks for the advises from you all.

The latest v7 patch has sent out.

Br,

Mou

Quoted 26 lines · Reshma
Quoted 3 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Suanming.Mou

<snip>

app/pdump/main.c struct parse_val { · line 429

Quoted 12 lines

static void

app/pdump/main.c +6 -0
+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);

app/pdump/main.c +4 -0
+	else
+		quit_signal = 1;
+}
+

Adding the log message saying primary existing so, secondary.. would be helpful here. I am ok to have it as default behaviour.
As Vipin mentioned, can you also update the document doc/guides/tools/pdump.rst

Thanks,
Reshma

#34 lore raw

PATCH v7 1/1 app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---
V7:
* omit else in monitor_primary.
* add eixting due to primary is not alive message.
* add pdump.rst update.

 app/pdump/main.c           | 47 +++++++++++++++++++++++++++++++++++++++++++++-
 doc/guides/tools/pdump.rst |  2 ++
 2 files changed, 48 insertions(+), 1 deletion(-)
app/pdump/main.c +46 -1
index 3d20854..0b74c27 100644
@@ -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,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("Exiting dump while primary is not alive...\n");
+	quit_signal = 1;
+}
+
+static void
 print_pdump_stats(void)
 {
 	int i;
@@ -537,6 +555,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 +942,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 +993,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();
doc/guides/tools/pdump.rst +2 -0
index 53cd2b4..62b4a5e 100644
@@ -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
 -----------------------
Signature · 1 line
1.8.3.4
Acked-by on v7 1/1
#35 lore raw

Re: [dpdk-dev] [PATCH v7] app/pdump: add pudmp exits with primary support

Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Suanming.Mou
Sent: Thursday, May 2, 2019 1:35 PM
To: [email protected]
Cc: Varghese, Vipin <[email protected]>; Burakov, Anatoly <[email protected]>
Subject: [dpdk-dev] [PATCH v7] app/pdump: add pudmp exits with primary support

Quoted 4 lines

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

Reviewed-by on v7 1/1
#36 lore raw

Re: [dpdk-dev] [PATCH v7] app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou
Quoted 5 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---

<...>

app/pdump/main.c struct parse_val { · line 429

Quoted 6 lines
app/pdump/main.c +6 -0
+	if (rte_eal_primary_proc_alive(NULL)) {
+		rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL);
+		return;
+	}
+
+	printf("Exiting dump while primary is not alive...\n");

May i suggest rewording:

Primary process is no longer active, exiting

I think the above would be clearer.

Otherwise,

Quoted 6 lines
app/pdump/main.c +4 -0
+	quit_signal = 1;
+}
+
+static void
  print_pdump_stats(void)
  {

<snip>

Quoted 10 lines
app/pdump/main.c +1 -0
+	disable_primary_monitor();
  	cleanup_pdump_resources();
  	/* dump debug stats */
  	print_pdump_stats();
doc/guides/tools/pdump.rst +0 -0
index 53cd2b4..62b4a5e 100644

doc/guides/tools/pdump.rst a DPDK secondary process and is capable of enabling packet capture on dpdk ports · line 33

Quoted 8 lines
doc/guides/tools/pdump.rst +2 -0
@@ -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
  -----------------------

Worth adding this to release notes as well?

Signature · 2 lines
Thanks,
Anatoly
#37 lore raw

PATCH v8 1/1 app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

---
V8:
* reword the print info in monitor_primary.
* add release_19_05.rst update.
* add Reviewed-by tag.

 app/pdump/main.c                       | 47 +++++++++++++++++++++++++++++++++-
 doc/guides/rel_notes/release_19_05.rst |  4 +++
 doc/guides/tools/pdump.rst             |  2 ++
 3 files changed, 52 insertions(+), 1 deletion(-)
app/pdump/main.c +46 -1
index 3d20854..f92098f 100644
@@ -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,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,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 +942,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 +993,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();
doc/guides/rel_notes/release_19_05.rst +4 -0
index 468e325..7c4b39e 100644
@@ -200,6 +200,10 @@ New Features
   Improved testpmd application performance on ARM platform. For ``macswap``
   forwarding mode, NEON intrinsics were used to do swap to save CPU cycles.
 
+* **Updated the pdump application.**
+
+  Add support for pdump to exit with primary process.
+
 
 Removed Items
 -------------
doc/guides/tools/pdump.rst +2 -0
index 53cd2b4..62b4a5e 100644
@@ -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
 -----------------------
Signature · 1 line
1.8.3.4
#38 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

Hi,

03/05/2019 07:48, Suanming. Mou:

Quoted 2 lines

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

Sorry I fail to parse this sentence.
Maybe it should be longer to be more explicit about what it the current issue and how it is solved. Some comments in the code may also be improved.

Quoted 1 line

I think you should remove the dot in your name.

Quoted 6 lines

---
V8:
* reword the print info in monitor_primary.
* add release_19_05.rst update.

As it is not a fix, it will slip in 19.08.

#39 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

Quoted 8 lines · Thomas Monjalon

Hi,

03/05/2019 07:48, Suanming. Mou:

Quoted 2 lines

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

Sorry I fail to parse this sentence.
Maybe it should be longer to be more explicit about what it the current issue and how it is solved.

Thanks for the suggestion. It's fine to add more contents.

Quoted 1 line

Some comments in the code may also be improved.

Could you please help to show the detail? Or it will be hard to do the improvement.

There are a thousand Hamlets in a thousand people's eyes.

Quoted 3 lines
Quoted 2 lines

I think you should remove the dot in your name.

Sorry for that, maybe I missed some important instructions which notes the dot.

I will remove it later.

Quoted 8 lines
Quoted 7 lines

---
V8:
* reword the print info in monitor_primary.
* add release_19_05.rst update.

As it is not a fix, it will slip in 19.08.

It seems 19.08 is still not started yet.

Does that mean the patch should be hung till 19.08 be started?

Quoted 5 lines
#40 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

05/05/2019 03:20, Suanming. Mou:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

Hi,

03/05/2019 07:48, Suanming. Mou:

Quoted 2 lines

When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.

Sorry I fail to parse this sentence.
Maybe it should be longer to be more explicit about what it the current issue and how it is solved.

Quoted 7 lines

Thanks for the suggestion. It's fine to add more contents.

Quoted 1 line

Some comments in the code may also be improved.

Could you please help to show the detail? Or it will be hard to do the improvement.

There are a thousand Hamlets in a thousand people's eyes.

Yes, you're right :)

[..]

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

V8:
* reword the print info in monitor_primary.
* add release_19_05.rst update.

As it is not a fix, it will slip in 19.08.

It seems 19.08 is still not started yet.

Does that mean the patch should be hung till 19.08 be started?

Yes, either to wait one week, or fake the 19.08 release notes template to do your patch on top.

#41 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

Quoted 2 lines · Thomas Monjalon

Yes, either to wait one week, or fake the 19.08 release notes template to do your patch on top.

Thanks.  I think it will be updated when 19.08 started.

#42 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

In reply to Suanming.Mou

Hi,

I try to suggest some rewording below.

03/05/2019 07:48, Suanming. Mou:

app/pdump/main.c line 70

Quoted 2 lines
app/pdump/main.c +2 -0
+/* Enough to set it to 500ms for exiting. */
+#define MONITOR_INTERVAL (500 * 1000)

What is "enough"?
What is "it"?
What is the relation between MONITOR_INTERVAL and exiting?

[...]

app/pdump/main.c struct parse_val { · line 565

Quoted 4 lines
app/pdump/main.c +4 -0
+	/*
+	 * Don't worry about it is primary exit case. The alarm cancel
+	 * function will take care about that. Ignore the ENOENT case.
+	 */

I don't understand the comment.
Maybe you can explicit what is "it" and "that".
It would be probably simpler if you just describe why you cancel this alarm.
How is it related to ENOENT?

Quoted 3 lines
app/pdump/main.c +3 -0
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor:%d\n", ret);

[...]

app/pdump/main.c struct parse_val { · line 996

Quoted 2 lines
app/pdump/main.c +1 -1
-	/* create mempool, ring and vdevs info */
+	/* create mempool, ring, vdevs info and primary monitor */

I don't see any value to this comment. You may just drop it.

Quoted 3 lines
app/pdump/main.c +1 -0
 	create_mp_ring_vdev();
 	enable_pdump();
+	enable_primary_monitor();
#43 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

Quoted 3 lines · Thomas Monjalon

Hi,

I try to suggest some rewording below.

Thanks very much.

First,  let me explain what is the patch work for.

As we all know, the pdump tool works as the secondary process.

When the primary process exits, if the secondary process keeps running there, 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 just 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.

Quoted 5 lines

03/05/2019 07:48, Suanming. Mou:

app/pdump/main.c line 70

Quoted 2 lines
app/pdump/main.c +2 -0
+/* Enough to set it to 500ms for exiting. */
+#define MONITOR_INTERVAL (500 * 1000)

What is "enough"?

The 'enough' here means it will be fine to make the alarm to run periodically in every 500ms to check if the primary process exits.

(Yes, someone can also suggest, "Well , I think xxxms will be better.")

Quoted 1 line

What is "it"?

So, the "it" here means the MONITOR_INTERVAL...

Quoted 1 line

What is the relation between MONITOR_INTERVAL and exiting?

Once the primary exits, as the alarm runs every 500ms, the alarm will help the pdump to exit, the worst case will take 500ms for the pudmp to exit.

Quoted 11 lines

[...]

app/pdump/main.c struct parse_val { · line 565

Quoted 4 lines
app/pdump/main.c +4 -0
+	/*
+	 * Don't worry about it is primary exit case. The alarm cancel
+	 * function will take care about that. Ignore the ENOENT case.
+	 */

I don't understand the comment.
Maybe you can explicit what is "it" and "that".
It would be probably simpler if you just describe why you cancel this alarm.
How is it related to ENOENT?

The 'it' and 'that' both means the pdump 'monitor_primary' recognises the primary process exited and set the 'quit_signal' case.

In that case, the 'monitor_primary' is not readd to the alarm. I add the comment in case someone want to say that "You are canceling a non-existent alarm."

It's OK to cancel a non-existent alarm. The 'rte_eal_alarm_cancel' just return 0 and set the ENOENT errno.

Quoted 9 lines
Quoted 4 lines
app/pdump/main.c +3 -0
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor:%d\n", ret);

[...]

app/pdump/main.c struct parse_val { · line 996

Quoted 2 lines
app/pdump/main.c +1 -1
-	/* create mempool, ring and vdevs info */
+	/* create mempool, ring, vdevs info and primary monitor */

I don't see any value to this comment. You may just drop it.

That's OK.

Quoted 7 lines

app/pdump/main.c struct parse_val { · line 999

Quoted 4 lines
  	create_mp_ring_vdev();
  	enable_pdump();
app/pdump/main.c +1 -0
+	enable_primary_monitor();

And one more word, the 'app' in the git log  means 'application'.

Maybe it's better to change it to  'process' to make it describes more clearly.

Thanks again for the suggestions.

BR,

Mou

#44 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

About the title, you can write: "app/pdump: exit with primary process"

08/05/2019 11:37, Suanming. Mou:

Quoted 14 lines · Thomas Monjalon
Quoted 3 lines

Hi,

I try to suggest some rewording below.

Thanks very much.

First, let me explain what is the patch work for.

As we all know, the pdump tool works as the secondary process.

When the primary process exits, if the secondary process keeps running there, it will make the primary process can't start up again.

Quoted 7 lines

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

If you feel some explanation is missing,
feel free to add it in the commit log.

Quoted 9 lines
Quoted 4 lines

03/05/2019 07:48, Suanming. Mou:

app/pdump/main.c line 70

Quoted 2 lines
app/pdump/main.c +2 -0
+/* Enough to set it to 500ms for exiting. */
+#define MONITOR_INTERVAL (500 * 1000)

What is "enough"?

The 'enough' here means it will be fine to make the alarm to run periodically in every 500ms to check if the primary process exits.

(Yes, someone can also suggest, "Well , I think xxxms will be better.")

So it looks like you reply to a ghost in the code comment :)

Quoted 9 lines
Quoted 1 line

What is "it"?

So, the "it" here means the MONITOR_INTERVAL...

Quoted 1 line

What is the relation between MONITOR_INTERVAL and exiting?

Once the primary exits, as the alarm runs every 500ms, the alarm will help the pdump to exit, the worst case will take 500ms for the pudmp to exit.

Let's write it in a simpler descriptive form:

	/* Maximum delay for exiting after primary process. */
Quoted 14 lines
Quoted 10 lines

[...]

app/pdump/main.c struct parse_val { · line 565

Quoted 4 lines
app/pdump/main.c +4 -0
+	/*
+	 * Don't worry about it is primary exit case. The alarm cancel
+	 * function will take care about that. Ignore the ENOENT case.
+	 */

I don't understand the comment.
Maybe you can explicit what is "it" and "that".
It would be probably simpler if you just describe why you cancel this alarm.
How is it related to ENOENT?

The 'it' and 'that' both means the pdump 'monitor_primary' recognises the primary process exited and set the 'quit_signal' case.

Quoted 6 lines

In that case, the 'monitor_primary' is not readd to the alarm. I add the comment in case someone want to say that "You are canceling a non-existent alarm."

It's OK to cancel a non-existent alarm. The 'rte_eal_alarm_cancel' just return 0 and set the ENOENT errno.

OK, so let's be more explicit:
"
Cancel monitoring of primary process. There will be no error if no alarm is set (in case primary process kill was detected earlier).
"

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
app/pdump/main.c +3 -0
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor:%d\n", ret);

[...]

Quoted 4 lines

And one more word, the 'app' in the git log means 'application'.

Maybe it's better to change it to 'process' to make it describes more clearly.

Indeed, "process" is more correct in this context.

Quoted 1 line

Thanks again for the suggestions.

You're welcome.

#45 lore raw

Re: [dpdk-dev] [PATCH v8] app/pdump: add pudmp exits with primary support

Quoted 19 lines · Thomas Monjalon

About the title, you can write: "app/pdump: exit with primary process"

08/05/2019 11:37, Suanming. Mou:

Quoted 16 lines · Thomas Monjalon
Quoted 3 lines

Hi,

I try to suggest some rewording below.

Thanks very much.

First, let me explain what is the patch work for.

As we all know, the pdump tool works as the secondary process.

When the primary process exits, if the secondary process keeps running there, 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.

Quoted 6 lines
Quoted 4 lines

The patch is just 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.

If you feel some explanation is missing,
feel free to add it in the commit log.

Yes, it will be updated in the next patch.

Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

03/05/2019 07:48, Suanming. Mou:

app/pdump/main.c line 70

Quoted 2 lines
app/pdump/main.c +2 -0
+/* Enough to set it to 500ms for exiting. */
+#define MONITOR_INTERVAL (500 * 1000)

What is "enough"?

The 'enough' here means it will be fine to make the alarm to run periodically in every 500ms to check if the primary process exits.

(Yes, someone can also suggest, "Well , I think xxxms will be better.")

So it looks like you reply to a ghost in the code comment :)

:)

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

What is "it"?

So, the "it" here means the MONITOR_INTERVAL...

Quoted 1 line

What is the relation between MONITOR_INTERVAL and exiting?

Once the primary exits, as the alarm runs every 500ms, the alarm will help the pdump to exit, the worst case will take 500ms for the pudmp to exit.

Let's write it in a simpler descriptive form:

	/* Maximum delay for exiting after primary process. */

Got it.

Quoted 18 lines
Quoted 18 lines
Quoted 11 lines

[...]

app/pdump/main.c struct parse_val { · line 565

Quoted 4 lines
app/pdump/main.c +4 -0
+	/*
+	 * Don't worry about it is primary exit case. The alarm cancel
+	 * function will take care about that. Ignore the ENOENT case.
+	 */

I don't understand the comment.
Maybe you can explicit what is "it" and "that".
It would be probably simpler if you just describe why you cancel this alarm.
How is it related to ENOENT?

The 'it' and 'that' both means the pdump 'monitor_primary' recognises the primary process exited and set the 'quit_signal' case.

In that case, the 'monitor_primary' is not readd to the alarm. I add the comment in case someone want to say that "You are canceling a non-existent alarm."

Quoted 8 lines
Quoted 2 lines

It's OK to cancel a non-existent alarm. The 'rte_eal_alarm_cancel' just return 0 and set the ENOENT errno.

OK, so let's be more explicit:
"
Cancel monitoring of primary process. There will be no error if no alarm is set (in case primary process kill was detected earlier).
"

Great, it becomes more official now.  The original one seems little emotional.

Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
app/pdump/main.c +3 -0
+	ret = rte_eal_alarm_cancel(monitor_primary, NULL);
+	if (ret < 0)
+		printf("Fail to disable monitor:%d\n", ret);

[...]

Quoted 4 lines

And one more word, the 'app' in the git log means 'application'.

Maybe it's better to change it to 'process' to make it describes more clearly.

Indeed, "process" is more correct in this context.

Quoted 1 line

Thanks again for the suggestions.

You're welcome.

.

#46 lore raw

PATCH v9 1/1 app/pdump: exit with primary process

In reply to Suanming.Mou

From: Suanming Mou <[email protected]>

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.

---
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(+)
app/pdump/main.c +46 -0
index 3d20854..859a96c 100644
@@ -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();
doc/guides/rel_notes/release_19_08.rst +3 -0
index b9510f9..e3a22e0 100644
@@ -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
 -------------
doc/guides/tools/pdump.rst +2 -0
index 53cd2b4..62b4a5e 100644
@@ -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
 -----------------------
Signature · 1 line
1.8.3.4
Acked-by on v9 1/1
#47 lore raw

Re: [dpdk-dev] [PATCH v9] app/pdump: exit with primary process

Quoted 28 lines

-----Original Message-----
From: Suanming.Mou [mailto:[email protected]]
Sent: Wednesday, May 15, 2019 6:11 AM
To: [email protected]
Cc: Varghese, Vipin <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]; Pattan, Reshma <[email protected]>
Subject: [PATCH v9] app/pdump: exit with primary process

From: Suanming Mou <[email protected]>

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.

Quoted 6 lines

---
V9:
* reword the comments and update the git log.
* move release note to release_19_08.rst.
* remove dot in name.

Acked-by line is missing, so re acking. Keep my ack if you have to send next version.

#48 lore raw

Re: [dpdk-dev] [PATCH v9] app/pdump: exit with primary process

20/06/2019 15:32, Pattan, Reshma:

Quoted 12 lines

From: Suanming.Mou [mailto:[email protected]]

Quoted 11 lines

---
V9:
* reword the comments and update the git log.
* move release note to release_19_08.rst.
* remove dot in name.

Quoted 2 lines

Acked-by line is missing, so re acking. Keep my ack if you have to send next version.

That's not correct to add Reviewed-by lines if it was not explicitly found in a previous reply.
Suanming, I think you need to remove some lines above.

Reviewed-by Anatoly Burakov Acked-by Reshma Pattan
#49 lore raw

Re: [dpdk-dev] [PATCH v9] app/pdump: exit with primary process

Quoted 13 lines · Thomas Monjalon

20/06/2019 15:32, Pattan, Reshma:

Quoted 12 lines

From: Suanming.Mou [mailto:[email protected]]

Quoted 11 lines

---
V9:
* reword the comments and update the git log.
* move release note to release_19_08.rst.
* remove dot in name.

Quoted 9 lines
Quoted 2 lines

Acked-by line is missing, so re acking. Keep my ack if you have to send next version.

That's not correct to add Reviewed-by lines if it was not explicitly found in a previous reply.
Suanming, I think you need to remove some lines above.

Hi Thomas,

Thanks for the guidelines.
Yes, the tags should be as below since just Anatoly gave the Reviewed-by tag and Reshma gave the Acked-by tag in the previous mail.

Sorry for the mistake and the late response.
(I wish my thunderbird would correctly handle the In-Reply-To header by direct click the mailto link.)

BR
SuanmingMou

#50 lore raw

Re: [dpdk-dev] [PATCH v9] app/pdump: exit with primary process

10/07/2019 16:04, Suanming Mou:

Quoted 23 lines · Thomas Monjalon
Quoted 13 lines

20/06/2019 15:32, Pattan, Reshma:

Quoted 12 lines

From: Suanming.Mou [mailto:[email protected]]

Quoted 11 lines

---
V9:
* reword the comments and update the git log.
* move release note to release_19_08.rst.
* remove dot in name.

Quoted 5 lines
Quoted 2 lines

Acked-by line is missing, so re acking. Keep my ack if you have to send next version.

That's not correct to add Reviewed-by lines if it was not explicitly found in a previous reply.
Suanming, I think you need to remove some lines above.

Thanks for the guidelines.
Yes, the tags should be as below since just Anatoly gave the Reviewed-by tag and Reshma gave the Acked-by tag in the previous mail.

Quoted 6 lines

Sorry for the mistake and the late response.
(I wish my thunderbird would correctly handle the In-Reply-To header by direct click the mailto link.)

Applied, thanks

#51 lore raw

Re: [dpdk-dev] [PATCH v2] app/pdump: add exit_with_primary option support.

In reply to Suanming.Mou
Quoted 17 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add an exit_with_primary option to make pdump exit with primary.

---
  app/pdump/main.c | 26 ++++++++++++++++++++++++++
  1 file changed, 26 insertions(+)
app/pdump/main.c +0 -0
index 3d20854..3909f15 100644
@@ -26,11 +26,14 @@
  #include <rte_ring.h>

app/pdump/main.c line 36

Quoted 10 lines
app/pdump/main.c +3 -0
  #include <rte_string_fns.h>
  #include <rte_pdump.h>
+#include <rte_alarm.h>
 
  #define CMD_LINE_OPT_PDUMP "pdump"
  #define CMD_LINE_OPT_PDUMP_NUM 256
  #define CMD_LINE_OPT_MULTI "multi"
  #define CMD_LINE_OPT_MULTI_NUM 257
+#define CMD_LINE_OPT_EXIT_WP "exit_with_primary"
+#define CMD_LINE_OPT_EXIT_WP_NUM 258

Unrelated to this patch, but seems very flaky and prone to error. How about replacing this stuff with enum-based automatic value assignment, like in lib/librte_eal/common/eal_options.h ?

app/pdump/main.c line 71

Quoted 8 lines
app/pdump/main.c +1 -0
  #define PDUMP_PORT_ARG "port"
  #define PDUMP_PCI_ARG "device_id"
  #define PDUMP_QUEUE_ARG "queue"
@@ -65,6 +68,7 @@
  #define SIZE 256
  #define BURST_SIZE 32
  #define NUM_VDEVS 2
+#define MONITOR_INTERVEL (500 * 1000)

I believe it should be INTERVAL

Quoted 9 lines
app/pdump/main.c +1 -0
  /* true if x is a power of 2 */
  #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -143,12 +147,14 @@ struct parse_val {
  static struct rte_eth_conf port_conf_default;
  static volatile uint8_t quit_signal;
  static uint8_t multiple_core_capture;
+static uint8_t exit_with_primary;
 

<snip>

app/pdump/main.c struct parse_val { · line 415

Quoted 8 lines
app/pdump/main.c +3 -0
@@ -403,6 +410,9 @@ struct parse_val {
  		case CMD_LINE_OPT_MULTI_NUM:
  			multiple_core_capture = 1;
  			break;
+		case CMD_LINE_OPT_EXIT_WP_NUM:
+			exit_with_primary = 1;
+			break;

Any particular reason why it is not made the default?

Signature · 2 lines
Thanks,
Anatoly
#52 lore raw

Re: [dpdk-dev] [PATCH v2] app/pdump: add exit_with_primary option support.

Quoted 21 lines · Anatoly
Quoted 20 lines · Suanming.Mou

When primary app exits, the residual running pdump will stop the primary app to restart. Add an exit_with_primary option to make pdump exit with primary.

---
  app/pdump/main.c | 26 ++++++++++++++++++++++++++

  1 file changed, 26 insertions(+)
app/pdump/main.c +1 -0
index 3d20854..3909f15 100644
@@ -26,11 +26,14 @@
   #include <rte_ring.h>
   #include <rte_string_fns.h>
   #include <rte_pdump.h>
+#include <rte_alarm.h>
Quoted 8 lines

app/pdump/main.c line 36

Quoted 6 lines
app/pdump/main.c +2 -0
     #define CMD_LINE_OPT_PDUMP "pdump"
   #define CMD_LINE_OPT_PDUMP_NUM 256
   #define CMD_LINE_OPT_MULTI "multi"
   #define CMD_LINE_OPT_MULTI_NUM 257
+#define CMD_LINE_OPT_EXIT_WP "exit_with_primary"
+#define CMD_LINE_OPT_EXIT_WP_NUM 258

Unrelated to this patch, but seems very flaky and prone to error. How about replacing this stuff with enum-based automatic value assignment, like in lib/librte_eal/common/eal_options.h ?

:)

Quoted 11 lines

app/pdump/main.c line 71

Quoted 9 lines
app/pdump/main.c +1 -0
   #define PDUMP_PORT_ARG "port"
   #define PDUMP_PCI_ARG "device_id"
   #define PDUMP_QUEUE_ARG "queue"
@@ -65,6 +68,7 @@
   #define SIZE 256
   #define BURST_SIZE 32
   #define NUM_VDEVS 2
+#define MONITOR_INTERVEL (500 * 1000)

I believe it should be INTERVAL

Ah, yes, sorry for the typo.

Quoted 10 lines
Quoted 8 lines
app/pdump/main.c +1 -0
     /* true if x is a power of 2 */
   #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -143,12 +147,14 @@ struct parse_val {
   static struct rte_eth_conf port_conf_default;
   static volatile uint8_t quit_signal;
   static uint8_t multiple_core_capture;
+static uint8_t exit_with_primary;

<snip>

Could you please help to confirm that the 'snip' here mean we should delete the 'exit_with_primary' code?

Quoted 10 lines
Quoted 8 lines

  @@ -403,6 +410,9 @@ struct parse_val {
          case CMD_LINE_OPT_MULTI_NUM:
              multiple_core_capture = 1;
              break;
+        case CMD_LINE_OPT_EXIT_WP_NUM:
+            exit_with_primary = 1;
+            break;

Any particular reason why it is not made the default?

It's OK to make it default.  How about Varghese ?

Thank you for the review.

#53 lore raw

Re: [dpdk-dev] [PATCH v2] app/pdump: add exit_with_primary option support.

Quoted 1 line · Suanming.Mou

<snip> :)

Quoted 10 lines
Quoted 9 lines
Quoted 7 lines

    /* true if x is a power of 2 */
  #define POWEROF2(x) ((((x)-1) & (x)) == 0)

app/pdump/main.c +1 -0
@@ -143,12 +147,14 @@ struct parse_val {
   static struct rte_eth_conf port_conf_default;
   static volatile uint8_t quit_signal;
   static uint8_t multiple_core_capture;
+static uint8_t exit_with_primary;

<snip>

Could you please help to confirm that the 'snip' here mean we should delete the 'exit_with_primary' code?

No, "snip" means i'm skipping irrelevant sections, just to keep my reply shorter and to the point :)

Signature · 2 lines
Thanks,
Anatoly