From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D92FE428F8 for ; Sun, 9 Apr 2023 17:31:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA90742BAC; Sun, 9 Apr 2023 17:31:54 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2046.outbound.protection.outlook.com [40.107.92.46]) by mails.dpdk.org (Postfix) with ESMTP id 276A842B71 for ; Sun, 9 Apr 2023 17:31:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FeLhBDafPhjp4Gj9JDo6SD8cu3/z8wLlP1z2PgC/EvJkSYmyn1nn4SUl0P4NCmXkYIheFzVtaJoFQC4HcTRcIoIrBRqVDnXbmr0XjKhXQFFMRef8sIsHJPVqUqY9is4jsK4/Rk57FfG+uc6bzsA9hIvgIjfh0KxsRZIzPTpSv5ZyMmrWIub7FAKp9fPQSVCAlP9w6TLdZeCj/nxdT2GRf800uvp7jAyI4wUOQ+V8e8OnbFNMc9xWBE+0FmPZ9BleEBKbPoGv+ACVbPgFK4epKGvAQP1tXVi8wGaYZeaQdWugsdAYDht5DKq+WahIgo0LYaG+3IsE2T1OvB5zyq4+zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GGE0akzIqUi+SnlJR3DThEpyVjVd5BIxmx3lfHE4dgI=; b=ZgLQ86d5s7g4V6Han16vFJGgNNaRI2KcSQ0o9dsArhsUPKgtZgkEEbNrLy9az52owPkDyGtsLJVBtiIeRdskJHBgbXsCCJ33WVeL7RTOSDfIk6MVnVkN12O31uAlpHQfPgwlGqMvCE6/NkagqXsJS3sgY+IgK7R1I4GdADI9E4QsDxPM1kmih01jJRGkofAfj1FlJZTKKYAtE/UnimmLDXb3DB22L98ClzJSWL3/RA6kFuCO9cReci8U5XnSK/Z/aG1xro8ngXEeu52bzkbpr34o6KTW8eudrS36EDE2YQ9133MNm83dKY9GJrcgWohHIcBA0Pwt2tWCOPegk5iRQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=networkplumber.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GGE0akzIqUi+SnlJR3DThEpyVjVd5BIxmx3lfHE4dgI=; b=tYPKZm8aDbWlPDhAm/1DgTOvMnBj1qBfDJGdJGnEI1M19zolhLEj89IGjBr9QS7prJBXXZC4m3RY4FpFluogTGRabI8+eH2WN81E1D7+1BQ+zofZtvVSi4HrmPIOsUSWe1RuLkCzvXBNjDhOsbwcaxwv+rOWflTjbkLHgokUgWWJj7h77dyhHHZqwsnuLJP19IvOXOLaAQIwP7XbfhRwgEe8zXFj82f7UIwNGz0yOPMPOoBNKHBsHWTdTmQ2y36wU8jq0QTkHsQPIJSGVh3sLfW80Kup/4bRKKw9oJUmFW0nI7XvWm/ScOTP3brqtUOSzj9Zf97TQd2omDH3kDECMg== Received: from DS7PR07CA0003.namprd07.prod.outlook.com (2603:10b6:5:3af::11) by DM4PR12MB6136.namprd12.prod.outlook.com (2603:10b6:8:a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Sun, 9 Apr 2023 15:31:51 +0000 Received: from DM6NAM11FT097.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::45) by DS7PR07CA0003.outlook.office365.com (2603:10b6:5:3af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36 via Frontend Transport; Sun, 9 Apr 2023 15:31:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT097.mail.protection.outlook.com (10.13.172.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.20 via Frontend Transport; Sun, 9 Apr 2023 15:31:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 9 Apr 2023 08:31:42 -0700 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 9 Apr 2023 08:31:40 -0700 From: Xueming Li To: Stephen Hemminger CC: Ferruh Yigit , dpdk stable Subject: patch 'app/testpmd: cleanup cleanly from signal' has been queued to stable release 22.11.2 Date: Sun, 9 Apr 2023 23:24:18 +0800 Message-ID: <20230409152529.5308-71-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230409152529.5308-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230409152529.5308-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT097:EE_|DM4PR12MB6136:EE_ X-MS-Office365-Filtering-Correlation-Id: 55cd73d5-9bbe-4a60-6e2e-08db390f8a84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FI5locIpnnESRRFuHjr/IHMgR9hz3lZJ19fUhlvn00+egMWnnC+uU675GzEVBxXDWri+JcM2ax/BZvVWo25vHH804ecxb4Hk5GHV7EwxF1zSEY9JbH3C55/acg4rJJ7zH7AidQIN53iziksmGzA0UH/CaRbYcQSQQ7osDcX6Vlj1+ImuhhwLy6QbTlI+eY2Xtg0vxO1WidmZVjJXrOcQ1aqV0WYVfkdCosGCmyJAHEM55gy4UQnsYRSNkKExoh7aBZqxaLSsVgibmqvQT1fyRrfQAe8NR7urtLpIxOqKKOvVRSOreshmkgdA+aLSIq0HDncwOliuEwISznukoA67OoEPDnDIwQvYGF+lW/rqmtjkWPnu3Yx5TLFSw9qdZtpBYvH7olrr5yrmKTo2swFLAHYuy/fsjDQSHwdkXKNrJolbA9+W/OJUFByTCl10Na0xRNeQWDlme4oSm03+u76C58XUAaOAIzp1j8zIOBwW1MdGMTknnV7YlQ7yB/3N6r9evtJVrQm14z6/cXrkoqf1m0zN/+WWc7+8KatZRsJs8EZn33dwjZu/1gYXhFkemHuhsrAFLvxLQPNgW7YqmpDW2vftGbTfmlwHoQ+CWHP+7n4C/UCSnef8eULS/Y7j4l5NQGjYebS0G419w59kgfliRYKU29gVjU49EoGGO3MIrvZ6ZyfWvRxpHoIBaRMc7wGlE8YcMnWVCyFxtn/kPRAPCbrAnAhoEpn1qvG9EpPzS+BTo0LK3qgbu2XnUDzm2Pgp3lCDGM01rZgl8PVVXQNaJkmV+IMm++zoClRjlZPzdwdoVw6q+iKtZy1l14jGewctd4NmM30+pK2r8Ytck5I1NQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(346002)(396003)(376002)(451199021)(36840700001)(40470700004)(46966006)(7696005)(478600001)(86362001)(55016003)(40480700001)(83380400001)(47076005)(36756003)(40460700003)(40140700001)(82740400003)(7636003)(356005)(2616005)(36860700001)(426003)(336012)(6666004)(966005)(2906002)(54906003)(316002)(16526019)(6286002)(186003)(1076003)(53546011)(26005)(8676002)(6916009)(41300700001)(8936002)(5660300002)(82310400005)(4326008)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2023 15:31:51.2722 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55cd73d5-9bbe-4a60-6e2e-08db390f8a84 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT097.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6136 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/11/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/57294e8df49dd6cf276130cc922400ecbab0f983 Thanks. Xueming Li --- >From 57294e8df49dd6cf276130cc922400ecbab0f983 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 3 Feb 2023 11:14:09 -0800 Subject: [PATCH] app/testpmd: cleanup cleanly from signal Cc: Xueming Li [ upstream commit 0fd1386c30c3ad9365d7fdd2829bf7cb2e1b9dff ] Do a clean shutdown of testpmd when a signal is received; instead of having testpmd kill itself. This fixes the problem where a signal could be received in the middle of a PMD and then the signal handler would call PMD's close routine leading to locking problems. The cmdline structure no longer needs to be global it can just be local to the prompt() function. An added benefit is it gets rid of some Windows specific code. Fixes: d9a191a00e81 ("app/testpmd: fix quitting in container") Signed-off-by: Stephen Hemminger Acked-by: Ferruh Yigit --- app/test-pmd/cmdline.c | 29 ++++++---------- app/test-pmd/testpmd.c | 77 ++++++++++++++++++++---------------------- app/test-pmd/testpmd.h | 1 + 3 files changed, 48 insertions(+), 59 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b32dc8bfd4..bd31e16e0f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -65,7 +65,6 @@ #include "cmdline_tm.h" #include "bpf_cmd.h" -static struct cmdline *testpmd_cl; static cmdline_parse_ctx_t *main_ctx; static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = TAILQ_HEAD_INITIALIZER(driver_commands_head); @@ -12921,28 +12920,22 @@ cmdline_read_from_file(const char *filename) void prompt(void) { - int ret; + struct cmdline *cl; - testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); - if (testpmd_cl == NULL) + cl = cmdline_stdin_new(main_ctx, "testpmd> "); + if (cl == NULL) return; - ret = atexit(prompt_exit); - if (ret != 0) - fprintf(stderr, "Cannot set exit function for cmdline\n"); - - cmdline_interact(testpmd_cl); - if (ret != 0) - cmdline_stdin_exit(testpmd_cl); -} + /* loop until signal or quit command */ + while (f_quit == 0 && cl_quit == 0) { + int status = cmdline_poll(cl); -void -prompt_exit(void) -{ - if (testpmd_cl != NULL) { - cmdline_quit(testpmd_cl); - cmdline_stdin_exit(testpmd_cl); + if (status < 0 || status == RDLINE_EXITED) + break; } + + cmdline_quit(cl); + cmdline_stdin_exit(cl); } void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 60b5942d80..1b54698bf6 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -11,6 +11,7 @@ #include #ifndef RTE_EXEC_ENV_WINDOWS #include +#include #endif #include #include @@ -231,7 +232,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to show */ * In container, it cannot terminate the process which running with 'stats-period' * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. */ -static volatile uint8_t f_quit; +volatile uint8_t f_quit; uint8_t cl_quit; /* Quit testpmd from cmdline. */ /* @@ -4392,13 +4393,6 @@ init_port(void) memset(txring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS); } -static void -force_quit(void) -{ - pmd_test_exit(); - prompt_exit(); -} - static void print_stats(void) { @@ -4417,28 +4411,9 @@ print_stats(void) } static void -signal_handler(int signum) +signal_handler(int signum __rte_unused) { - if (signum == SIGINT || signum == SIGTERM) { - fprintf(stderr, "\nSignal %d received, preparing to exit...\n", - signum); -#ifdef RTE_LIB_PDUMP - /* uninitialize packet capture framework */ - rte_pdump_uninit(); -#endif -#ifdef RTE_LIB_LATENCYSTATS - if (latencystats_enabled != 0) - rte_latencystats_uninit(); -#endif - force_quit(); - /* Set flag to indicate the force termination. */ - f_quit = 1; - /* exit with the expected status */ -#ifndef RTE_EXEC_ENV_WINDOWS - signal(signum, SIG_DFL); - kill(getpid(), signum); -#endif - } + f_quit = 1; } int @@ -4618,15 +4593,9 @@ main(int argc, char** argv) start_packet_forwarding(0); } prompt(); - pmd_test_exit(); } else #endif { - char c; - int rc; - - f_quit = 0; - printf("No commandline core given, start packet forwarding\n"); start_packet_forwarding(tx_first); if (stats_period != 0) { @@ -4649,15 +4618,41 @@ main(int argc, char** argv) prev_time = cur_time; rte_delay_us_sleep(US_PER_S); } - } + } else { + char c; + fd_set fds; + + printf("Press enter to exit\n"); - printf("Press enter to exit\n"); - rc = read(0, &c, 1); - pmd_test_exit(); - if (rc < 0) - return 1; + FD_ZERO(&fds); + FD_SET(0, &fds); + + /* wait for signal or enter */ + ret = select(1, &fds, NULL, NULL, NULL); + if (ret < 0 && errno != EINTR) + rte_exit(EXIT_FAILURE, + "Select failed: %s\n", + strerror(errno)); + + /* if got enter then consume it */ + if (ret == 1 && read(0, &c, 1) < 0) + rte_exit(EXIT_FAILURE, + "Read failed: %s\n", + strerror(errno)); + } } + pmd_test_exit(); + +#ifdef RTE_LIB_PDUMP + /* uninitialize packet capture framework */ + rte_pdump_uninit(); +#endif +#ifdef RTE_LIB_LATENCYSTATS + if (latencystats_enabled != 0) + rte_latencystats_uninit(); +#endif + ret = rte_eal_cleanup(); if (ret != 0) rte_exit(EXIT_FAILURE, diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 7d24d25970..022210a7a9 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -34,6 +34,7 @@ #define RTE_PORT_HANDLING (uint16_t)3 extern uint8_t cl_quit; +extern volatile uint8_t f_quit; /* * It is used to allocate the memory for hash key. -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-04-09 21:45:40.562840900 +0800 +++ 0070-app-testpmd-cleanup-cleanly-from-signal.patch 2023-04-09 21:45:38.689042200 +0800 @@ -1 +1 @@ -From 0fd1386c30c3ad9365d7fdd2829bf7cb2e1b9dff Mon Sep 17 00:00:00 2001 +From 57294e8df49dd6cf276130cc922400ecbab0f983 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 0fd1386c30c3ad9365d7fdd2829bf7cb2e1b9dff ] @@ -17 +19,0 @@ -Cc: stable@dpdk.org @@ -28 +30 @@ -index 02c72d06b7..6fa870dc32 100644 +index b32dc8bfd4..bd31e16e0f 100644 @@ -31 +33 @@ -@@ -66,7 +66,6 @@ +@@ -65,7 +65,6 @@ @@ -39 +41 @@ -@@ -13033,28 +13032,22 @@ cmdline_read_from_file(const char *filename) +@@ -12921,28 +12920,22 @@ cmdline_read_from_file(const char *filename) @@ -80 +82 @@ -index 0032696608..2ce19ed47a 100644 +index 60b5942d80..1b54698bf6 100644 @@ -100 +102 @@ -@@ -4447,13 +4448,6 @@ init_port(void) +@@ -4392,13 +4393,6 @@ init_port(void) @@ -114 +116 @@ -@@ -4472,28 +4466,9 @@ print_stats(void) +@@ -4417,28 +4411,9 @@ print_stats(void) @@ -145 +147 @@ -@@ -4677,15 +4652,9 @@ main(int argc, char** argv) +@@ -4618,15 +4593,9 @@ main(int argc, char** argv) @@ -161 +163 @@ -@@ -4708,15 +4677,41 @@ main(int argc, char** argv) +@@ -4649,15 +4618,41 @@ main(int argc, char** argv) @@ -210 +212 @@ -index b9215720b6..bdfbfd36d3 100644 +index 7d24d25970..022210a7a9 100644