From patchwork Wed May 15 05:10:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suanming.Mou" X-Patchwork-Id: 53415 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F39582C17; Wed, 15 May 2019 05:07:17 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id BEE022BF2 for ; Wed, 15 May 2019 05:07:16 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E590561A9098D386B5BC; Wed, 15 May 2019 11:07:14 +0800 (CST) Received: from huawei.com (10.175.100.202) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 15 May 2019 11:07:11 +0800 From: Suanming.Mou To: CC: , , , Date: Wed, 15 May 2019 05:10:39 +0000 Message-ID: <1557897039-89555-1-git-send-email-mousuanming@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1556862508-61677-1-git-send-email-mousuanming@huawei.com> References: <1556862508-61677-1-git-send-email-mousuanming@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.202] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v9] app/pdump: exit with primary process 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" From: Suanming Mou The pdump tool works as the secondary process. When the primary process exits and the residual secondary process keeps running, it will make the primary process can't start up again. Since the ex-fbarry files are still attached by the secondary process pdump, the 'new' primary process can't get these files locked. The patch is to set up an alarm which runs every 0.5s periodically to monitor the primary process in the pdump. Once the primary exits, so will the pdump. Signed-off-by: Suanming Mou Reviewed-by: Anatoly Burakov Reviewed-by: Vipin Varghese Reviewed-by: Reshma Pattan Reviewed-by: Thomas Monjalon Acked-by: Reshma Pattan Reviewed-by: Anatoly Burakov Acked-by: Reshma Pattan reshma.pattan@intel.com --- 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(+) diff --git a/app/pdump/main.c b/app/pdump/main.c index 3d20854..859a96c 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 +/* 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(); diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst index b9510f9..e3a22e0 100644 --- a/doc/guides/rel_notes/release_19_08.rst +++ b/doc/guides/rel_notes/release_19_08.rst @@ -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 ------------- 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 -----------------------