From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73DB1C43219 for ; Tue, 30 Apr 2019 09:33:06 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 10A3F20835 for ; Tue, 30 Apr 2019 09:33:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10A3F20835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 665FD5F2E; Tue, 30 Apr 2019 11:33:02 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id B06D75F3C for ; Tue, 30 Apr 2019 11:33:00 +0200 (CEST) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5359559D789AAD76969E for ; Tue, 30 Apr 2019 17:32:59 +0800 (CST) Received: from huawei.com (10.175.100.202) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Tue, 30 Apr 2019 17:32:53 +0800 From: Suanming.Mou To: CC: , Date: Tue, 30 Apr 2019 11:35:24 +0000 Message-ID: <1556624124-54930-2-git-send-email-mousuanming@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1556624124-54930-1-git-send-email-mousuanming@huawei.com> References: <1556595548-53745-1-git-send-email-mousuanming@huawei.com> <1556624124-54930-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 v5] 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" When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support. Suggested-by: Varghese, Vipin Suggested-by: Burakov, Anatoly Signed-off-by: Suanming.Mou --- app/pdump/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 3d20854..cc46f65 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #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(); -- 1.8.3.4