Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/125192/?format=api
http://patches.dpdk.org/api/patches/125192/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230316151438.186241-2-aharivel@redhat.com/", "project": { "id": 1, "url": "http://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": "<20230316151438.186241-2-aharivel@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230316151438.186241-2-aharivel@redhat.com", "date": "2023-03-16T15:14:38", "name": "[2/2] app/testpmd: add testpmd based sleeping", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "09ccfd1a9c752c9ba88db29ffbddcb8b8f4ab63a", "submitter": { "id": 3005, "url": "http://patches.dpdk.org/api/people/3005/?format=api", "name": "Anthony Harivel", "email": "aharivel@redhat.com" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230316151438.186241-2-aharivel@redhat.com/mbox/", "series": [ { "id": 27422, "url": "http://patches.dpdk.org/api/series/27422/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=27422", "date": "2023-03-16T15:14:37", "name": "[1/2] app/testpmd: fwd engines report processed packets", "version": 1, "mbox": "http://patches.dpdk.org/series/27422/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/125192/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/125192/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 7464C41EB1;\n\tThu, 16 Mar 2023 16:14:56 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 3D4E942D53;\n\tThu, 16 Mar 2023 16:14:52 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id 42A1E40DDC\n for <dev@dpdk.org>; Thu, 16 Mar 2023 16:14:50 +0100 (CET)", "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-619-QzykoLDMOGmVkHjSQIap8g-1; Thu, 16 Mar 2023 11:14:47 -0400", "from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com\n [10.11.54.6])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15D0D800D8E;\n Thu, 16 Mar 2023 15:14:47 +0000 (UTC)", "from fedora.redhat.com (unknown [10.39.208.19])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 43DB72166B26;\n Thu, 16 Mar 2023 15:14:45 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1678979689;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=fDXrBGzEeZPc+WseW9qG6CsaF3hsZ3Dzc82Wu44SMNA=;\n b=EdprIf7VkjRM2ZsTQy+hf8IiQa+m+I06WwQNPebEmRrDWFbd5d9McHkBi8LmqBoIK+PXcl\n PZK4uXRwUiG1sdgndNPG1CYSj8vielMTFcUJi1pq/RU+hFyYr2m0qAJulqqrKqKUwcjIa8\n O/Npw7q0GuZbRPSyprS1D0h7iyyMYXc=", "X-MC-Unique": "QzykoLDMOGmVkHjSQIap8g-1", "From": "Anthony Harivel <aharivel@redhat.com>", "To": "Aman Singh <aman.deep.singh@intel.com>,\n Yuying Zhang <yuying.zhang@intel.com>", "Cc": "dev@dpdk.org, rjarry@redhat.com, david.marchand@redhat.com,\n ktraynor@redhat.com, Anthony Harivel <aharivel@redhat.com>", "Subject": "[PATCH 2/2] app/testpmd: add testpmd based sleeping", "Date": "Thu, 16 Mar 2023 16:14:38 +0100", "Message-Id": "<20230316151438.186241-2-aharivel@redhat.com>", "In-Reply-To": "<20230316151438.186241-1-aharivel@redhat.com>", "References": "<20230316151438.186241-1-aharivel@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.6", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "Sleep for an incremental amount of time if the fwd engine has processed\nless than at least half a burst of packets (i.e 16pkts with default\nsetting) on a polling iteration of testpmd.\n\nUpon detecting the threshold of >= 16 pkts on an Rxq, reset the sleep\ntime to zero (i.e. no sleep).\n\nSleep time will be increased on each iteration where the low load\nconditions remain up to a total of the max sleep time which is set by\nthe user with the \"--max-sleep-us NUM\" command line argument or when in\ninteractive \"mode set max_sleep NUM\".\n\nThe default max_sleep value is 0, which means that no sleeps will occur\nand the default behaviour is unchanged from previously.\n\nTesting has been performed on AMD EPYC 7702 server with --nb-cores 12.\nThe results were obtained via turbostat for each individual lcore:\n\nmax_sleep 0 ====== ======== ======== ========\n idle 4Mpps 16Mpps Bursts\n=============== ====== ======== ======== ========\nC1-state % 0 0 0 0\nC2-state % 0 0 0 0\n% usage 100 100 100 100\nWatt / core 1.14 1.18 1.19 1.14\n=============== ====== ======== ======== ========\n\nmax_sleep 500 ====== ======== ======== ========\n idle 4Mpps 16Mpps Bursts\n=============== ====== ======== ======== ========\nC1-state % 99 85 74 98.6\nC2-state % 0 0 0 0\n% usage 1 15 26 1\nWatt / core 0.04 0.18 0.28 0 04\n=============== ====== ======== ======== ========\n\nmax_sleep 1000 ====== ======== ======== ========\n idle 4Mpps 16Mpps Bursts\n=============== ====== ======== ======== ========\nC1-state % 0 85 74 0.3\nC2-state % 99 0 0 97.6\n% usage 1 15 25 1\nWatt / core 0.02 0.18 0.28 0 02\n=============== ====== ======== ======== ========\n\nOn most cases, the consumption of the cores is greatly improved while\nstill performing zero packet loss.\n\nLatency test has been performed on each tests above. The CPU has a C1\nlatency of 1us and a C2 latency of 400us. On the worst case scenario, Tx\nBurst of thousands packets every seconds, the following latency in us\n(micro seconds) has been observed:\n\n=========== ==== ===== ======\nmax_sleep 0 500 1000\n----------- ---- ----- ------\nmax latency 14 560 1260\nmin latency 5 5 6\nAvg latency 7 305 617\n=========== ==== ===== ======\n\nlink: https://www.github.com/torvalds/linux/tree/master/tools/power/x86/turbostat\nSigned-off-by: Anthony Harivel <aharivel@redhat.com>\n---\n app/test-pmd/cmdline.c | 78 +++++++++++++++++++++\n app/test-pmd/parameters.c | 14 ++++\n app/test-pmd/testpmd.c | 24 ++++++-\n app/test-pmd/testpmd.h | 2 +\n doc/guides/testpmd_app_ug/run_app.rst | 19 +++++\n doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 ++++\n 6 files changed, 149 insertions(+), 1 deletion(-)", "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 02c72d06b768..b89aae1c3414 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -5522,6 +5522,82 @@ static cmdline_parse_inst_t cmd_set_link_check = {\n \t},\n };\n \n+/* *** SET MAX SLEEP *** */\n+struct cmd_max_sleep_result {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t max_sleep;\n+\tuint64_t value;\n+};\n+\n+static void\n+cmd_max_sleep_set_parsed(void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n+{\n+\tstruct cmd_max_sleep_result *res = parsed_result;\n+\tif ((!strcmp(res->set, \"set\"))\n+\t\t&& (!strcmp(res->max_sleep, \"max_sleep\")))\n+\t\tmax_sleep_us = res->value;\n+}\n+\n+static cmdline_parse_token_string_t cmd_max_sleep_set =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_max_sleep_result,\n+\t\t\tset, \"set\");\n+static cmdline_parse_token_string_t cmd_max_sleep =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_max_sleep_result,\n+\t\t\tmax_sleep, \"max_sleep\");\n+static cmdline_parse_token_num_t cmd_max_sleep_value =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_max_sleep_result,\n+\t\t\tvalue, RTE_UINT64);\n+\n+static cmdline_parse_inst_t cmd_set_max_sleep = {\n+\t.f = cmd_max_sleep_set_parsed,\n+\t.data = NULL,\n+\t.help_str = \"set max_sleep <value>: Set the maximum sleep in micro seconds.\",\n+\t.tokens = {\n+\t\t(void *)&cmd_max_sleep_set,\n+\t\t(void *)&cmd_max_sleep,\n+\t\t(void *)&cmd_max_sleep_value,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** SHOW MAX SLEEP *** */\n+struct cmd_max_sleep_show_result {\n+\tcmdline_fixed_string_t show;\n+\tcmdline_fixed_string_t max_sleep;\n+\tuint64_t value;\n+};\n+\n+static void\n+cmd_max_sleep_show_parsed(void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n+{\n+\tstruct cmd_max_sleep_show_result *res = parsed_result;\n+\tif ((!strcmp(res->show, \"show\"))\n+\t\t&& (!strcmp(res->max_sleep, \"max_sleep\")))\n+\t\tprintf(\"max_sleep %\"PRIu64\" us\\n\", max_sleep_us);\n+}\n+\n+static cmdline_parse_token_string_t cmd_show_max_sleep_show =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_max_sleep_show_result,\n+\t\t\tshow, \"show\");\n+static cmdline_parse_token_string_t cmd_max_sleep_show =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_max_sleep_show_result,\n+\t\t\tmax_sleep, \"max_sleep\");\n+\n+static cmdline_parse_inst_t cmd_show_max_sleep = {\n+\t.f = cmd_max_sleep_show_parsed,\n+\t.data = NULL,\n+\t.help_str = \"show max_sleep: Display the maximun sleep in micro seconds.\",\n+\t.tokens = {\n+\t\t(void *)&cmd_show_max_sleep_show,\n+\t\t(void *)&cmd_max_sleep_show,\n+\t\tNULL,\n+\t},\n+};\n+\n /* *** SET FORWARDING MODE *** */\n struct cmd_set_fwd_mode_result {\n \tcmdline_fixed_string_t set;\n@@ -12770,6 +12846,8 @@ static cmdline_parse_ctx_t builtin_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,\n \t(cmdline_parse_inst_t *)&cmd_set_flush_rx,\n \t(cmdline_parse_inst_t *)&cmd_set_link_check,\n+\t(cmdline_parse_inst_t *)&cmd_set_max_sleep,\n+\t(cmdline_parse_inst_t *)&cmd_show_max_sleep,\n \t(cmdline_parse_inst_t *)&cmd_vlan_offload,\n \t(cmdline_parse_inst_t *)&cmd_vlan_tpid,\n \t(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,\ndiff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c\nindex 3b37809baf00..6cb4ce9edb0a 100644\n--- a/app/test-pmd/parameters.c\n+++ b/app/test-pmd/parameters.c\n@@ -201,6 +201,9 @@ usage(char* progname)\n \tprintf(\" --rx-mq-mode=0xX: hexadecimal bitmask of RX mq mode can be \"\n \t \"enabled\\n\");\n \tprintf(\" --record-core-cycles: enable measurement of CPU cycles.\\n\");\n+\tprintf(\" --max-sleep-us: maximum sleep time that will be requested in\\n\"\n+\t \" microseconds per iteration of packet processing which has received zero\\n\"\n+\t \" or a small amount of packets from the Rx queues it is polling.\\n\");\n \tprintf(\" --record-burst-stats: enable display of RX and TX bursts.\\n\");\n \tprintf(\" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\\n\"\n \t \" 0x10 - explicit Tx rule, 0x02 - hairpin ports paired\\n\"\n@@ -707,6 +710,7 @@ launch_args_parse(int argc, char** argv)\n \t\t{ \"no-iova-contig\", 0, 0, 0 },\n \t\t{ \"rx-mq-mode\", 1, 0, 0 },\n \t\t{ \"record-core-cycles\", 0, 0, 0 },\n+\t\t{ \"max-sleep-us\", 1, 0, 0 },\n \t\t{ \"record-burst-stats\", 0, 0, 0 },\n \t\t{ PARAM_NUM_PROCS, 1, 0, 0 },\n \t\t{ PARAM_PROC_ID, 1, 0, 0 },\n@@ -1459,6 +1463,16 @@ launch_args_parse(int argc, char** argv)\n \t\t\t}\n \t\t\tif (!strcmp(lgopts[opt_idx].name, \"record-core-cycles\"))\n \t\t\t\trecord_core_cycles = 1;\n+\t\t\tif (!strcmp(lgopts[opt_idx].name, \"max-sleep-us\")) {\n+\t\t\t\tchar *end = NULL;\n+\t\t\t\terrno = 0;\n+\t\t\t\tunsigned long sleep = strtoul(optarg, &end, 10);\n+\n+\t\t\t\tif (errno != 0 || *optarg == '\\0' || *end != '\\0' || sleep == 0)\n+\t\t\t\t\trte_exit(EXIT_FAILURE, \"max-sleep-us must be > 0\\n\");\n+\n+\t\t\t\tmax_sleep_us = sleep;\n+\t\t\t}\n \t\t\tif (!strcmp(lgopts[opt_idx].name, \"record-burst-stats\"))\n \t\t\t\trecord_burst_stats = 1;\n \t\t\tif (!strcmp(lgopts[opt_idx].name, PARAM_NUM_PROCS))\ndiff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex e25c082387f5..ccd9be175c59 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -524,6 +524,11 @@ uint8_t gro_flush_cycles = GRO_DEFAULT_FLUSH_CYCLES;\n */\n enum rte_eth_rx_mq_mode rx_mq_mode = RTE_ETH_MQ_RX_VMDQ_DCB_RSS;\n \n+/*\n+ * Max sleep time requested in microseconds per iteration\n+ */\n+uint64_t max_sleep_us;\n+\n /*\n * Used to set forced link speed\n */\n@@ -2254,6 +2259,8 @@ static void\n run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)\n {\n \tstruct fwd_stream **fsm;\n+\tuint64_t sleep_us = 0;\n+\tuint64_t sleep_cycles;\n \tuint64_t prev_tsc;\n \tstreamid_t nb_fs;\n \tstreamid_t sm_id;\n@@ -2283,6 +2290,8 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)\n \t\t\tpkts = (*pkt_fwd)(fs);\n \t\t\tif (record_core_cycles && pkts > 0)\n \t\t\t\tfs->busy_cycles += rte_rdtsc() - start_fs_tsc;\n+\t\t\tif (pkts > nb_pkt_per_burst / 2)\n+\t\t\t\tsleep_us = 0;\n \t\t}\n #ifdef RTE_LIB_BITRATESTATS\n \t\tif (bitrate_enabled != 0 &&\n@@ -2302,10 +2311,23 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)\n \t\t\t\tlatencystats_lcore_id == rte_lcore_id())\n \t\t\trte_latencystats_update();\n #endif\n+\t\tsleep_cycles = 0;\n+\t\tif (max_sleep_us) {\n+\t\t\t/* Check if a sleep should happen on this iteration. */\n+\t\t\tif (sleep_us > 0) {\n+\t\t\t\tuint64_t tsc = rte_rdtsc();\n+\n+\t\t\t\trte_delay_us_sleep(sleep_us);\n+\t\t\t\tsleep_cycles = rte_rdtsc() - tsc;\n+\t\t\t}\n+\t\t\tif (sleep_us < max_sleep_us)\n+\t\t\t\t/* Increase sleep time for next iteration. */\n+\t\t\t\tsleep_us += 1;\n+\t\t}\n \t\tif (record_core_cycles) {\n \t\t\tuint64_t tsc = rte_rdtsc();\n \n-\t\t\tfc->total_cycles += tsc - prev_tsc;\n+\t\t\tfc->total_cycles += tsc - prev_tsc - sleep_cycles;\n \t\t\tprev_tsc = tsc;\n \t\t}\n \t} while (! fc->stopped);\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex b399a0dc7f84..63758831d6c9 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -779,6 +779,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;\n \n extern enum rte_eth_rx_mq_mode rx_mq_mode;\n \n+extern uint64_t max_sleep_us;\n+\n extern struct rte_flow_action_conntrack conntrack_context;\n \n extern int proc_id;\ndiff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst\nindex 57b23241cf36..c5afe44e680f 100644\n--- a/doc/guides/testpmd_app_ug/run_app.rst\n+++ b/doc/guides/testpmd_app_ug/run_app.rst\n@@ -555,6 +555,25 @@ The command line options are:\n \n The default value is 0. Hairpin will use single port mode and implicit Tx flow mode.\n \n+* ``--max-sleep-us=N``\n+\n+ Set the maximum sleep in micro seconds. The default value is 0.\n+\n+ When `max-sleep-us` is set, the lcores running the packet forwarding may stop active polling and\n+ go to sleep for an incrementing amount of time. Each time the forwarding engine processes less\n+ than half a burst of packets, the sleep time will be incremented by 1 micro second, up to the\n+ maximum value set by the user.\n+\n+ At any point, if the forwarding engine returns more than half a burst of packets, the sleep time\n+ will be reset to 0.\n+\n+ Sleeping in the packet processing path yields back control to the kernel scheduler. The actual\n+ sleep/wakeup times are not guaranteed and may differ significantly depending on system\n+ configuration, allowed C-states and scheduler timer resolution (on Linux, this is controlled by\n+ ``prctl(PR_SET_TIMERSLACK, nanoseconds)`` and it defaults to 10 micro seconds).\n+\n+ In interactive mode, the maximum sleep time can be set with ``set max_sleep N`` and displayed\n+ with ``show max_sleep``.\n \n Testpmd Multi-Process Command-line Options\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ndiff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\nindex 8f2384785930..53a67f02b702 100644\n--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n@@ -637,6 +637,12 @@ Show fec mode of a port::\n \n testpmd> show port (port_id) fec_mode\n \n+show max_sleep\n+~~~~~~~~~~~~~~\n+\n+Show max_sleep in micro seconds::\n+\n+ testpmd> show max_sleep\n \n Configuration Functions\n -----------------------\n@@ -1802,6 +1808,13 @@ Set fec mode for a specific port::\n \n testpmd> set port (port_id) fec_mode auto|off|rs|baser\n \n+Set max_sleep\n+~~~~~~~~~~~~\n+\n+Set max_sleep in micro seconds::\n+\n+ testpmd> set max_sleep <us>\n+\n Config Sample actions list\n ~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n", "prefixes": [ "2/2" ] }{ "id": 125192, "url": "