[v7] app/pdump: add pudmp exits with primary support
Checks
Commit Message
When primary app exits, the residual running pdump will stop the
primary app to restart. Add pdump exits with primary support.
Signed-off-by: Suanming.Mou <mousuanming@huawei.com>
---
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(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Suanming.Mou
> Sent: Thursday, May 2, 2019 1:35 PM
> To: dev@dpdk.org
> Cc: Varghese, Vipin <vipin.varghese@intel.com>; Burakov, Anatoly
> <anatoly.burakov@intel.com>
> Subject: [dpdk-dev] [PATCH v7] 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.
>
> Signed-off-by: Suanming.Mou <mousuanming@huawei.com>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
On 02-May-19 1:35 PM, Suanming.Mou wrote:
> When primary app exits, the residual running pdump will stop the
> primary app to restart. Add pdump exits with primary support.
>
> Signed-off-by: Suanming.Mou <mousuanming@huawei.com>
> ---
<...>
> + 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,
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
> + quit_signal = 1;
> +}
> +
> +static void
> print_pdump_stats(void)
> {
<snip>
> + disable_primary_monitor();
> cleanup_pdump_resources();
> /* dump debug stats */
> print_pdump_stats();
> diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst
> index 53cd2b4..62b4a5e 100644
> --- a/doc/guides/tools/pdump.rst
> +++ b/doc/guides/tools/pdump.rst
> @@ -26,6 +26,8 @@ a DPDK secondary process and is capable of enabling packet capture on dpdk ports
> Once the libpcap development files are installed, the libpcap based PMD
> can be enabled by setting CONFIG_RTE_LIBRTE_PMD_PCAP=y and recompiling the DPDK.
>
> + * The ``dpdk-pdump`` tool runs as a DPDK secondary process. It exits when
> + the primary application exits.
>
> Running the Application
> -----------------------
>
Worth adding this to release notes as well?
Ah, yes!
I'm so sorry that I have left the company today. It's not able to update the patch now.
I think it will be done tomorrow.
Thanks again for your suggestions enriched that simple patch.
(May the reply on mobile phone won't break any mail formats)
--------------------------------------------------
Mou Suanming
Email: mousuanming@huawei.com<mailto:mousuanming@huawei.com>
发件人:Burakov, Anatoly <anatoly.burakov@intel.com>
收件人:mousuanming <mousuanming@huawei.com>;dev@dpdk.org <dev@dpdk.org>
抄 送:vipin.varghese@intel.com <vipin.varghese@intel.com>
时间:2019-05-02 19:31:51
主 题:Re: [PATCH v7] app/pdump: add pudmp exits with primary support
On 02-May-19 1:35 PM, Suanming.Mou wrote:
> When primary app exits, the residual running pdump will stop the
> primary app to restart. Add pdump exits with primary support.
>
> Signed-off-by: Suanming.Mou <mousuanming@huawei.com>
> ---
<...>
> + 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,
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
> + quit_signal = 1;
> +}
> +
> +static void
> print_pdump_stats(void)
> {
<snip>
> + disable_primary_monitor();
> cleanup_pdump_resources();
> /* dump debug stats */
> print_pdump_stats();
> diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst
> index 53cd2b4..62b4a5e 100644
> --- a/doc/guides/tools/pdump.rst
> +++ b/doc/guides/tools/pdump.rst
> @@ -26,6 +26,8 @@ a DPDK secondary process and is capable of enabling packet capture on dpdk ports
> Once the libpcap development files are installed, the libpcap based PMD
> can be enabled by setting CONFIG_RTE_LIBRTE_PMD_PCAP=y and recompiling the DPDK.
>
> + * The ``dpdk-pdump`` tool runs as a DPDK secondary process. It exits when
> + the primary application exits.
>
> Running the Application
> -----------------------
>
Worth adding this to release notes as well?
--
Thanks,
Anatoly
@@ -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();
@@ -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
-----------------------