From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 34C262C4F for ; Thu, 2 May 2019 12:32:31 +0200 (CEST) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 180FCA24FEBB27C0306F for ; Thu, 2 May 2019 18:32:29 +0800 (CST) Received: from huawei.com (10.175.100.202) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Thu, 2 May 2019 18:32:24 +0800 From: Suanming.Mou To: CC: , Date: Thu, 2 May 2019 12:35:05 +0000 Message-ID: <1556800505-59917-1-git-send-email-mousuanming@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1556774432-59147-1-git-send-email-mousuanming@huawei.com> References: <1556774432-59147-1-git-send-email-mousuanming@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.100.202] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v7] app/pdump: add pudmp exits with primary support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 May 2019 10:32:31 -0000 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 --- 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(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 3d20854..0b74c27 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -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(); diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst index 53cd2b4..62b4a5e 100644 --- a/doc/guides/tools/pdump.rst +++ b/doc/guides/tools/pdump.rst @@ -26,6 +26,8 @@ a DPDK secondary process and is capable of enabling packet capture on dpdk ports Once the libpcap development files are installed, the libpcap based PMD can be enabled by setting CONFIG_RTE_LIBRTE_PMD_PCAP=y and recompiling the DPDK. + * The ``dpdk-pdump`` tool runs as a DPDK secondary process. It exits when + the primary application exits. Running the Application ----------------------- -- 1.8.3.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 46FD2A0AC5 for ; Thu, 2 May 2019 12:32:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 69CE62C55; Thu, 2 May 2019 12:32:33 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 34C262C4F for ; Thu, 2 May 2019 12:32:31 +0200 (CEST) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 180FCA24FEBB27C0306F for ; Thu, 2 May 2019 18:32:29 +0800 (CST) Received: from huawei.com (10.175.100.202) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Thu, 2 May 2019 18:32:24 +0800 From: Suanming.Mou To: CC: , Date: Thu, 2 May 2019 12:35:05 +0000 Message-ID: <1556800505-59917-1-git-send-email-mousuanming@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1556774432-59147-1-git-send-email-mousuanming@huawei.com> References: <1556774432-59147-1-git-send-email-mousuanming@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Originating-IP: [10.175.100.202] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v7] app/pdump: add pudmp exits with primary support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190502123505.njGUHokceDezv8ZVS6kdJH_AjhLf92YIk6uaMUykoSI@z> 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 --- 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(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 3d20854..0b74c27 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -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(); diff --git a/doc/guides/tools/pdump.rst b/doc/guides/tools/pdump.rst index 53cd2b4..62b4a5e 100644 --- a/doc/guides/tools/pdump.rst +++ b/doc/guides/tools/pdump.rst @@ -26,6 +26,8 @@ a DPDK secondary process and is capable of enabling packet capture on dpdk ports Once the libpcap development files are installed, the libpcap based PMD can be enabled by setting CONFIG_RTE_LIBRTE_PMD_PCAP=y and recompiling the DPDK. + * The ``dpdk-pdump`` tool runs as a DPDK secondary process. It exits when + the primary application exits. Running the Application ----------------------- -- 1.8.3.4