Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/122521/?format=api
https://patches.dpdk.org/api/patches/122521/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230125183205.96554-1-stephen@networkplumber.org/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20230125183205.96554-1-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20230125183205.96554-1-stephen@networkplumber.org", "date": "2023-01-25T18:32:05", "name": "[v9] testpmd: cleanup cleanly from signal", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "ab661e94ef301f69d4fa3a580cbce85c579471f4", "submitter": { "id": 27, "url": "https://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 319, "url": "https://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230125183205.96554-1-stephen@networkplumber.org/mbox/", "series": [ { "id": 26652, "url": "https://patches.dpdk.org/api/series/26652/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=26652", "date": "2023-01-25T18:32:05", "name": "[v9] testpmd: cleanup cleanly from signal", "version": 9, "mbox": "https://patches.dpdk.org/series/26652/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/122521/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/122521/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 072AF42441;\n\tWed, 25 Jan 2023 19:32:12 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 9DD1442D4C;\n\tWed, 25 Jan 2023 19:32:11 +0100 (CET)", "from mail-pg1-f178.google.com (mail-pg1-f178.google.com\n [209.85.215.178])\n by mails.dpdk.org (Postfix) with ESMTP id 7215242D47\n for <dev@dpdk.org>; Wed, 25 Jan 2023 19:32:09 +0100 (CET)", "by mail-pg1-f178.google.com with SMTP id e10so13981144pgc.9\n for <dev@dpdk.org>; Wed, 25 Jan 2023 10:32:09 -0800 (PST)", "from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218])\n by smtp.gmail.com with ESMTPSA id\n z2-20020aa791c2000000b0058a7bacd31fsm3938471pfa.32.2023.01.25.10.32.07\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Jan 2023 10:32:07 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20210112.gappssmtp.com; s=20210112;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=ieW2t4rebWcCQwfCS9bd0Ux7gNXOTFsqC+yuDVGmbKU=;\n b=J9MAhV9jv0vNfrHb+hHJ2FN/g+NA+PS/OoNcAWyGNwHLrx9PXdvEfaBgNBwzi1TDS0\n GRnInGDS6I8qFYVB4vqMmLJzMKuTKSOxlYo36kVgPDKREW36yU/aOvxWVJ6MaliAYGQY\n IvyC4wnp/M62QU9E0+qg9T6L7txDK69CGDBDJ8CLgA8Paf6QQNGv0bR4e4ZZCEvT8gQf\n MwVl/gxvq2SGlvZjhoTDYrbu2CCI9auuMkGFCRHJlKhzi32yg/TxTeuMC4BajU45zKe1\n TJ/SmK7H+UR6Dy5QabmZIObNsPXJF1EMwwoWfc9BJC+89PfssMLAe7TQSwztfX5ziQlj\n U9ng==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=ieW2t4rebWcCQwfCS9bd0Ux7gNXOTFsqC+yuDVGmbKU=;\n b=qRLHNkChPmgKKJgfsxY3aDybnjORvpQri3HBLWUCYF3i5qo23Ayb7jK7CHgeWdeBRU\n Z46cSqgDqv+Uq3ZP4bnqA9SEyPw/RBav9BwD7TTpLvstGcAEXkL0izKuyquZGGSljcp8\n E/FLuub6TRsmYBqwSQGK96llfXmdK1TKavjaj6XV2bRejccev/CBPThz6Mq1rq2XE2pF\n Gri8KlWGc3jyV2x0y8h5Q/u6X9cb/vubFlGv8KcsbOpwXekQdYpIbTOxPHdQ5SpomZnN\n 2tt/Hg+bC5C/Mm6SIZvMoupc0pzdZ2m+I6NxfqboTS1XBHgxjZn6Y7Nn1te1JAir/DoH\n Y+Pg==", "X-Gm-Message-State": "AFqh2kperGf5wloVf7PgB+S5IzUUb4Dwd5Z5/f8YwlvOFRejVbkP95yP\n zaQEikh0fluLgc7Xky+uFLsuSTJpaA6D+/d7wDs=", "X-Google-Smtp-Source": "\n AMrXdXuc1Q4lPCn41Zx7/9JcQR4MprbpkDZV54rqdhnEvE64Jy1LIMZ7h98n6HRjAHE37XByUIWG3A==", "X-Received": "by 2002:a62:aa0c:0:b0:58d:af0c:92f with SMTP id\n e12-20020a62aa0c000000b0058daf0c092fmr30968747pff.27.1674671528004;\n Wed, 25 Jan 2023 10:32:08 -0800 (PST)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Aman Singh <aman.deep.singh@intel.com>,\n Yuying Zhang <yuying.zhang@intel.com>, Phil Yang <phil.yang@arm.com>,\n Jianbo Liu <jianbo.liu@arm.com>", "Subject": "[PATCH v9] testpmd: cleanup cleanly from signal", "Date": "Wed, 25 Jan 2023 10:32:05 -0800", "Message-Id": "<20230125183205.96554-1-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.39.0", "In-Reply-To": "<20221112172839.70087-1-stephen@networkplumber.org>", "References": "<20221112172839.70087-1-stephen@networkplumber.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Do a clean shutdown of testpmd when a signal is received; instead of\nhaving testpmd kill itself. This fixes the problem where a signal could\nbe received in the middle of a PMD and then the signal handler would\ncall PMD's close routine leading to locking problems.\n\nAn added benefit is it gets rid of some Windows specific code.\n\nFixes: d9a191a00e81 (\"app/testpmd: fix quitting in container\")\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\nv9 - also handle the interactive case.\n use cmdine_poll() rather than signals and atexit\n\n app/test-pmd/cmdline.c | 28 +++++----------\n app/test-pmd/testpmd.c | 77 ++++++++++++++++++++----------------------\n app/test-pmd/testpmd.h | 1 +\n 3 files changed, 46 insertions(+), 60 deletions(-)", "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex b32dc8bfd445..fbe9ad694dee 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -65,7 +65,6 @@\n #include \"cmdline_tm.h\"\n #include \"bpf_cmd.h\"\n \n-static struct cmdline *testpmd_cl;\n static cmdline_parse_ctx_t *main_ctx;\n static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =\n \tTAILQ_HEAD_INITIALIZER(driver_commands_head);\n@@ -12921,28 +12920,19 @@ cmdline_read_from_file(const char *filename)\n void\n prompt(void)\n {\n-\tint ret;\n+\tstruct cmdline *cl;\n \n-\ttestpmd_cl = cmdline_stdin_new(main_ctx, \"testpmd> \");\n-\tif (testpmd_cl == NULL)\n+\tcl = cmdline_stdin_new(main_ctx, \"testpmd> \");\n+\tif (cl == NULL)\n \t\treturn;\n \n-\tret = atexit(prompt_exit);\n-\tif (ret != 0)\n-\t\tfprintf(stderr, \"Cannot set exit function for cmdline\\n\");\n-\n-\tcmdline_interact(testpmd_cl);\n-\tif (ret != 0)\n-\t\tcmdline_stdin_exit(testpmd_cl);\n-}\n-\n-void\n-prompt_exit(void)\n-{\n-\tif (testpmd_cl != NULL) {\n-\t\tcmdline_quit(testpmd_cl);\n-\t\tcmdline_stdin_exit(testpmd_cl);\n+\twhile (f_quit == 0 && cl_quit == 0) {\n+\t\tif (cmdline_poll(cl) < 0)\n+\t\t\tbreak;\n \t}\n+\n+\tcmdline_quit(cl);\n+\tcmdline_stdin_exit(cl);\n }\n \n void\ndiff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex 134d79a55547..d01b6105b7de 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -11,6 +11,7 @@\n #include <fcntl.h>\n #ifndef RTE_EXEC_ENV_WINDOWS\n #include <sys/mman.h>\n+#include <sys/select.h>\n #endif\n #include <sys/types.h>\n #include <errno.h>\n@@ -231,7 +232,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to show */\n * In container, it cannot terminate the process which running with 'stats-period'\n * option. Set flag to exit stats period loop after received SIGINT/SIGTERM.\n */\n-static volatile uint8_t f_quit;\n+volatile uint8_t f_quit;\n uint8_t cl_quit; /* Quit testpmd from cmdline. */\n \n /*\n@@ -4315,13 +4316,6 @@ init_port(void)\n \tmemset(txring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);\n }\n \n-static void\n-force_quit(void)\n-{\n-\tpmd_test_exit();\n-\tprompt_exit();\n-}\n-\n static void\n print_stats(void)\n {\n@@ -4340,28 +4334,9 @@ print_stats(void)\n }\n \n static void\n-signal_handler(int signum)\n+signal_handler(int signum __rte_unused)\n {\n-\tif (signum == SIGINT || signum == SIGTERM) {\n-\t\tfprintf(stderr, \"\\nSignal %d received, preparing to exit...\\n\",\n-\t\t\tsignum);\n-#ifdef RTE_LIB_PDUMP\n-\t\t/* uninitialize packet capture framework */\n-\t\trte_pdump_uninit();\n-#endif\n-#ifdef RTE_LIB_LATENCYSTATS\n-\t\tif (latencystats_enabled != 0)\n-\t\t\trte_latencystats_uninit();\n-#endif\n-\t\tforce_quit();\n-\t\t/* Set flag to indicate the force termination. */\n-\t\tf_quit = 1;\n-\t\t/* exit with the expected status */\n-#ifndef RTE_EXEC_ENV_WINDOWS\n-\t\tsignal(signum, SIG_DFL);\n-\t\tkill(getpid(), signum);\n-#endif\n-\t}\n+\tf_quit = 1;\n }\n \n int\n@@ -4536,15 +4511,9 @@ main(int argc, char** argv)\n \t\t\tstart_packet_forwarding(0);\n \t\t}\n \t\tprompt();\n-\t\tpmd_test_exit();\n \t} else\n #endif\n \t{\n-\t\tchar c;\n-\t\tint rc;\n-\n-\t\tf_quit = 0;\n-\n \t\tprintf(\"No commandline core given, start packet forwarding\\n\");\n \t\tstart_packet_forwarding(tx_first);\n \t\tif (stats_period != 0) {\n@@ -4567,15 +4536,41 @@ main(int argc, char** argv)\n \t\t\t\tprev_time = cur_time;\n \t\t\t\trte_delay_us_sleep(US_PER_S);\n \t\t\t}\n-\t\t}\n+\t\t} else {\n+\t\t\tchar c;\n+\t\t\tfd_set fds;\n+\n+\t\t\tprintf(\"Press enter to exit\\n\");\n \n-\t\tprintf(\"Press enter to exit\\n\");\n-\t\trc = read(0, &c, 1);\n-\t\tpmd_test_exit();\n-\t\tif (rc < 0)\n-\t\t\treturn 1;\n+\t\t\tFD_ZERO(&fds);\n+\t\t\tFD_SET(0, &fds);\n+\n+\t\t\t/* wait for signal or enter */\n+\t\t\tret = select(1, &fds, NULL, NULL, NULL);\n+\t\t\tif (ret < 0 && errno != EINTR)\n+\t\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\t \"Select failed: %s\\n\",\n+\t\t\t\t\t strerror(errno));\n+\n+\t\t\t/* if got enter then consume it */\n+\t\t\tif (ret == 1 && read(0, &c, 1) < 0)\n+\t\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\t \"Read failed: %s\\n\",\n+\t\t\t\t\t strerror(errno));\n+\t\t}\n \t}\n \n+\tpmd_test_exit();\n+\n+#ifdef RTE_LIB_PDUMP\n+\t/* uninitialize packet capture framework */\n+\trte_pdump_uninit();\n+#endif\n+#ifdef RTE_LIB_LATENCYSTATS\n+\tif (latencystats_enabled != 0)\n+\t\trte_latencystats_uninit();\n+#endif\n+\n \tret = rte_eal_cleanup();\n \tif (ret != 0)\n \t\trte_exit(EXIT_FAILURE,\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex 7d24d25970d2..022210a7a964 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -34,6 +34,7 @@\n #define RTE_PORT_HANDLING (uint16_t)3\n \n extern uint8_t cl_quit;\n+extern volatile uint8_t f_quit;\n \n /*\n * It is used to allocate the memory for hash key.\n", "prefixes": [ "v9" ] }{ "id": 122521, "url": "