From patchwork Fri Jun 19 10:53:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71795 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F5D1A0518; Fri, 19 Jun 2020 12:54:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF7751BE83; Fri, 19 Jun 2020 12:54:00 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 39E7D1B9B7 for ; Fri, 19 Jun 2020 12:53:58 +0200 (CEST) IronPort-SDR: h3tTqbzJfjVJhI64P040YgYqjhHoHC33vnuwIyqvlmkmXGrLw6AzpE9F8z8/dEQ4uY2ZBlAxkR N3otrLHHrGlA== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318767" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318767" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:53:57 -0700 IronPort-SDR: 8pKPJ6pUX1b8dCKaueSBJsK38j+lQugsYBS5KoIPcjnmUqr8Ai5B7FoCHhnL4AkBSMVjEcYPCs T0d5G8TwGorg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263346641" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:53:55 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:49 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 1/7] l3fwd-power: disable interrupts by default 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" Currently, interrupts are enabled in telemetry and empty poll modes, but they are not used. Switch to disabling interrupts by default, and only enable interrupts for modes that require them. Signed-off-by: Anatoly Burakov Tested-by: Yinan Wang --- examples/l3fwd-power/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 9db94ce044..2cc5d7b121 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -256,10 +256,7 @@ static struct rte_eth_conf port_conf = { }, .txmode = { .mq_mode = ETH_MQ_TX_NONE, - }, - .intr_conf = { - .rxq = 1, - }, + } }; static struct rte_mempool * pktmbuf_pool[NB_SOCKETS]; @@ -2270,6 +2267,8 @@ main(int argc, char **argv) /* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) { struct rte_eth_conf local_port_conf = port_conf; + /* not all app modes need interrupts */ + bool need_intr = app_mode == APP_MODE_LEGACY; /* skip ports that are not enabled */ if ((enabled_port_mask & (1 << portid)) == 0) { @@ -2303,7 +2302,10 @@ main(int argc, char **argv) nb_rx_queue, (unsigned)n_tx_queue ); /* If number of Rx queue is 0, no need to enable Rx interrupt */ if (nb_rx_queue == 0) - local_port_conf.intr_conf.rxq = 0; + need_intr = false; + + if (need_intr) + local_port_conf.intr_conf.rxq = 1; ret = rte_eth_dev_info_get(portid, &dev_info); if (ret != 0) From patchwork Fri Jun 19 10:53:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71797 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DFCF2A0518; Fri, 19 Jun 2020 12:54:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3E1CC1BEA7; Fri, 19 Jun 2020 12:54:04 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 48D1B1BE83 for ; Fri, 19 Jun 2020 12:53:59 +0200 (CEST) IronPort-SDR: T9x8duxbuomPb5YeDHK+Yb3JH5poSEg1UGV1uVRsTokOptowP18ldCZR2lwxXHu3/JYBjVlSY7 mNKwGAbDW6bw== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318771" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318771" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:53:58 -0700 IronPort-SDR: 7X0JePQ5vaWv6eVhFmbBkjfRvT4+mF65CYo6FZ4KqIdbgFm0rKRhPaokKmnbJVzdwuyU/bfZIG sqHWAPmzh7wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263346869" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:53:56 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:50 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 2/7] l3fwd-power: only allow supported power library envs 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" Currently, l3fwd-power will attempt to run even if the power env is set to KVM, which is not supported. Fix this by preventing the app from initializing unless the env is set to one of the supported modes. Signed-off-by: Anatoly Burakov Tested-by: Yinan Wang --- examples/l3fwd-power/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 2cc5d7b121..5cee9d5387 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -2043,6 +2043,7 @@ static int check_ptype(uint16_t portid) static int init_power_library(void) { + enum power_management_env env; unsigned int lcore_id; int ret = 0; @@ -2055,6 +2056,14 @@ init_power_library(void) lcore_id); return ret; } + /* we're not supporting the VM channel mode */ + env = rte_power_get_env(); + if (env != PM_ENV_ACPI_CPUFREQ && + env != PM_ENV_PSTATE_CPUFREQ) { + RTE_LOG(ERR, POWER, + "Only ACPI and PSTATE mode are supported\n"); + return -1; + } } return ret; } From patchwork Fri Jun 19 10:53:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71798 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CB6E7A0518; Fri, 19 Jun 2020 12:54:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C6C61BEB1; Fri, 19 Jun 2020 12:54:06 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4081D1BE8E for ; Fri, 19 Jun 2020 12:54:01 +0200 (CEST) IronPort-SDR: P9yutfvFzMIX85PTvX3IvX34BEZ8q/931wdRKtn2GruYgKm9/k6IaJ2sUO7wEXFTplRmQdu9Ol BUaKn6B2lSxQ== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318774" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318774" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:54:00 -0700 IronPort-SDR: B255WC5WdiGzIl1bzxFVGrnv7tmQyoNGL0kLwEMRHGBS58mk9Z0Fke/n2TffzavnPTzr9H8XqF HC5uxsuHfFHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263347074" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:53:58 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:51 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 3/7] l3fwd-power: code style and flow fixes 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" Make the coding style more consistent, and the init logic control flow more explicit. Signed-off-by: Anatoly Burakov --- examples/l3fwd-power/main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 5cee9d5387..c70611bb7f 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1126,7 +1126,7 @@ main_empty_poll_loop(__rte_unused void *dummy) } /* main processing loop */ static int -main_loop(__rte_unused void *dummy) +main_legacy_loop(__rte_unused void *dummy) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; unsigned lcore_id; @@ -1581,6 +1581,7 @@ parse_ep_config(const char *q_arg) } #define CMD_LINE_OPT_PARSE_PTYPE "parse-ptype" +#define CMD_LINE_OPT_EMPTY_POLL "empty-poll" #define CMD_LINE_OPT_TELEMETRY "telemetry" /* Parse the argument given in the command line of the application */ @@ -1598,7 +1599,7 @@ parse_args(int argc, char **argv) {"high-perf-cores", 1, 0, 0}, {"no-numa", 0, 0, 0}, {"enable-jumbo", 0, 0, 0}, - {"empty-poll", 1, 0, 0}, + {CMD_LINE_OPT_EMPTY_POLL, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_TELEMETRY, 0, 0, 0}, {NULL, 0, 0, 0} @@ -1673,7 +1674,7 @@ parse_args(int argc, char **argv) } if (!strncmp(lgopts[option_index].name, - "empty-poll", 10)) { + CMD_LINE_OPT_EMPTY_POLL, 10)) { if (app_mode == APP_MODE_TELEMETRY) { printf(" empty-poll cannot be enabled as telemetry mode is enabled\n"); return -1; @@ -2253,7 +2254,9 @@ main(int argc, char **argv) if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n"); - if (app_mode != APP_MODE_TELEMETRY && init_power_library()) + /* only legacy and empty poll mode rely on power library */ + if ((app_mode == APP_MODE_LEGACY || app_mode == APP_MODE_EMPTY_POLL) && + init_power_library()) rte_exit(EXIT_FAILURE, "init_power_library failed\n"); if (update_lcore_params() < 0) @@ -2526,12 +2529,12 @@ main(int argc, char **argv) /* launch per-lcore init on every lcore */ if (app_mode == APP_MODE_LEGACY) { - rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER); + rte_eal_mp_remote_launch(main_legacy_loop, NULL, CALL_MASTER); } else if (app_mode == APP_MODE_EMPTY_POLL) { empty_poll_stop = false; rte_eal_mp_remote_launch(main_empty_poll_loop, NULL, SKIP_MASTER); - } else { + } else if (app_mode == APP_MODE_TELEMETRY) { unsigned int i; /* Init metrics library */ @@ -2577,7 +2580,8 @@ main(int argc, char **argv) if (app_mode == APP_MODE_EMPTY_POLL) rte_power_empty_poll_stat_free(); - if (app_mode != APP_MODE_TELEMETRY && deinit_power_library()) + if ((app_mode == APP_MODE_LEGACY || app_mode == APP_MODE_EMPTY_POLL) && + deinit_power_library()) rte_exit(EXIT_FAILURE, "deinit_power_library failed\n"); if (rte_eal_cleanup() < 0) From patchwork Fri Jun 19 10:53:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71799 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 107F5A0518; Fri, 19 Jun 2020 12:54:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 770AB1BEC3; Fri, 19 Jun 2020 12:54:07 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 7D2EA1BE99 for ; Fri, 19 Jun 2020 12:54:02 +0200 (CEST) IronPort-SDR: UHDUF8akzT0rMmlfQcEuu0JxdlcQT3i2pkHL4++4kHqjlR/NPFUun6miNwGz44dTzPFssNLZ1f ZWeJBX0I98Yw== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318777" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318777" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:54:02 -0700 IronPort-SDR: 96dnHXVGOn3ea5vTQowu08DRQ+XAoUDSBaS9FGL2U+OuhcqDkDf2PexqgN4Dorw+xI2WipEt18 TMgJFiP5HP5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263347315" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:54:00 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:52 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 4/7] l3fwd-power: add support for requesting legacy mode 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" Currently, legacy mode is the implicit default, but it is not possible to directly request using legacy mode. Add the argument to enable requesting legacy mode, and also make it the default. Signed-off-by: Anatoly Burakov --- examples/l3fwd-power/main.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index c70611bb7f..c02b0a3574 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -195,7 +195,8 @@ static int parse_ptype; /**< Parse packet type using rx callback, and */ /**< disabled by default */ enum appmode { - APP_MODE_LEGACY = 0, + APP_MODE_DEFAULT = 0, + APP_MODE_LEGACY, APP_MODE_EMPTY_POLL, APP_MODE_TELEMETRY }; @@ -1435,6 +1436,7 @@ print_usage(const char *prgname) " --enable-jumbo: enable jumbo frame" " which max packet len is PKTLEN in decimal (64-9600)\n" " --parse-ptype: parse packet type by software\n" + " --legacy: use legacy interrupt-based scaling\n" " --empty-poll: enable empty poll detection" " follow (training_flag, high_threshold, med_threshold)\n" " --telemetry: enable telemetry mode, to update" @@ -1581,6 +1583,7 @@ parse_ep_config(const char *q_arg) } #define CMD_LINE_OPT_PARSE_PTYPE "parse-ptype" +#define CMD_LINE_OPT_LEGACY "legacy" #define CMD_LINE_OPT_EMPTY_POLL "empty-poll" #define CMD_LINE_OPT_TELEMETRY "telemetry" @@ -1601,6 +1604,7 @@ parse_args(int argc, char **argv) {"enable-jumbo", 0, 0, 0}, {CMD_LINE_OPT_EMPTY_POLL, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, + {CMD_LINE_OPT_LEGACY, 0, 0, 0}, {CMD_LINE_OPT_TELEMETRY, 0, 0, 0}, {NULL, 0, 0, 0} }; @@ -1673,10 +1677,21 @@ parse_args(int argc, char **argv) numa_on = 0; } + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_LEGACY, + sizeof(CMD_LINE_OPT_LEGACY))) { + if (app_mode != APP_MODE_DEFAULT) { + printf(" legacy mode is mutually exclusive with other modes\n"); + return -1; + } + app_mode = APP_MODE_LEGACY; + printf("legacy mode is enabled\n"); + } + if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_EMPTY_POLL, 10)) { - if (app_mode == APP_MODE_TELEMETRY) { - printf(" empty-poll cannot be enabled as telemetry mode is enabled\n"); + if (app_mode != APP_MODE_DEFAULT) { + printf(" empty-poll mode is mutually exclusive with other modes\n"); return -1; } app_mode = APP_MODE_EMPTY_POLL; @@ -1693,8 +1708,8 @@ parse_args(int argc, char **argv) if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_TELEMETRY, sizeof(CMD_LINE_OPT_TELEMETRY))) { - if (app_mode == APP_MODE_EMPTY_POLL) { - printf("telemetry mode cannot be enabled as empty poll mode is enabled\n"); + if (app_mode != APP_MODE_DEFAULT) { + printf(" telemetry mode is mutually exclusive with other modes\n"); return -1; } app_mode = APP_MODE_TELEMETRY; @@ -2254,6 +2269,9 @@ main(int argc, char **argv) if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n"); + if (app_mode == APP_MODE_DEFAULT) + app_mode = APP_MODE_LEGACY; + /* only legacy and empty poll mode rely on power library */ if ((app_mode == APP_MODE_LEGACY || app_mode == APP_MODE_EMPTY_POLL) && init_power_library()) From patchwork Fri Jun 19 10:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71800 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F1167A0518; Fri, 19 Jun 2020 12:54:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4BE641BED9; Fri, 19 Jun 2020 12:54:09 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4FA4A1BEA9 for ; Fri, 19 Jun 2020 12:54:04 +0200 (CEST) IronPort-SDR: dQf/XH59Pg2cln5l27cikqyIcGw3IOu/Vn9Imdf4yUhTsOIAjG3xLPb+MKxNsTgPXImpryLcg8 idJ+FL2cQc0g== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318780" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318780" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:54:04 -0700 IronPort-SDR: GQoiXgZd0PRx1i+EZG9sBiAO9p0JqRrKSnohx28xm9HPaBgHMG1Y+enYYjYuHTR2spGIabpwgU OYoglu6Kjz/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263347545" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:54:02 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:53 +0100 Message-Id: <8db5cf85a95de3157b53f754715cabc8c9dbdad1.1592563994.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 5/7] l3fwd-power: add interrupt-only mode 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" In addition to existing modes, add a mode which is very similar to legacy mode, but does not do frequency scaling, and thus does not depend on the power library. Signed-off-by: Anatoly Burakov Tested-by: Yinan Wang --- examples/l3fwd-power/main.c | 188 +++++++++++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 3 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index c02b0a3574..51acbfd87d 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -198,7 +198,8 @@ enum appmode { APP_MODE_DEFAULT = 0, APP_MODE_LEGACY, APP_MODE_EMPTY_POLL, - APP_MODE_TELEMETRY + APP_MODE_TELEMETRY, + APP_MODE_INTERRUPT }; enum appmode app_mode; @@ -901,6 +902,170 @@ static int event_register(struct lcore_conf *qconf) return 0; } + +/* main processing loop */ +static int main_intr_loop(__rte_unused void *dummy) +{ + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; + unsigned int lcore_id; + uint64_t prev_tsc, diff_tsc, cur_tsc; + int i, j, nb_rx; + uint8_t queueid; + uint16_t portid; + struct lcore_conf *qconf; + struct lcore_rx_queue *rx_queue; + uint32_t lcore_rx_idle_count = 0; + uint32_t lcore_idle_hint = 0; + int intr_en = 0; + + const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / + US_PER_S * BURST_TX_DRAIN_US; + + prev_tsc = 0; + + lcore_id = rte_lcore_id(); + qconf = &lcore_conf[lcore_id]; + + if (qconf->n_rx_queue == 0) { + RTE_LOG(INFO, L3FWD_POWER, "lcore %u has nothing to do\n", + lcore_id); + return 0; + } + + RTE_LOG(INFO, L3FWD_POWER, "entering main interrupt loop on lcore %u\n", + lcore_id); + + for (i = 0; i < qconf->n_rx_queue; i++) { + portid = qconf->rx_queue_list[i].port_id; + queueid = qconf->rx_queue_list[i].queue_id; + RTE_LOG(INFO, L3FWD_POWER, + " -- lcoreid=%u portid=%u rxqueueid=%hhu\n", + lcore_id, portid, queueid); + } + + /* add into event wait list */ + if (event_register(qconf) == 0) + intr_en = 1; + else + RTE_LOG(INFO, L3FWD_POWER, "RX interrupt won't enable.\n"); + + while (!is_done()) { + stats[lcore_id].nb_iteration_looped++; + + cur_tsc = rte_rdtsc(); + + /* + * TX burst queue drain + */ + diff_tsc = cur_tsc - prev_tsc; + if (unlikely(diff_tsc > drain_tsc)) { + for (i = 0; i < qconf->n_tx_port; ++i) { + portid = qconf->tx_port_id[i]; + rte_eth_tx_buffer_flush(portid, + qconf->tx_queue_id[portid], + qconf->tx_buffer[portid]); + } + prev_tsc = cur_tsc; + } + +start_rx: + /* + * Read packet from RX queues + */ + lcore_rx_idle_count = 0; + for (i = 0; i < qconf->n_rx_queue; ++i) { + rx_queue = &(qconf->rx_queue_list[i]); + rx_queue->idle_hint = 0; + portid = rx_queue->port_id; + queueid = rx_queue->queue_id; + + nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst, + MAX_PKT_BURST); + + stats[lcore_id].nb_rx_processed += nb_rx; + if (unlikely(nb_rx == 0)) { + /** + * no packet received from rx queue, try to + * sleep for a while forcing CPU enter deeper + * C states. + */ + rx_queue->zero_rx_packet_count++; + + if (rx_queue->zero_rx_packet_count <= + MIN_ZERO_POLL_COUNT) + continue; + + rx_queue->idle_hint = power_idle_heuristic( + rx_queue->zero_rx_packet_count); + lcore_rx_idle_count++; + } else { + rx_queue->zero_rx_packet_count = 0; + } + + /* Prefetch first packets */ + for (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++) { + rte_prefetch0(rte_pktmbuf_mtod( + pkts_burst[j], void *)); + } + + /* Prefetch and forward already prefetched packets */ + for (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) { + rte_prefetch0(rte_pktmbuf_mtod( + pkts_burst[j + PREFETCH_OFFSET], + void *)); + l3fwd_simple_forward( + pkts_burst[j], portid, qconf); + } + + /* Forward remaining prefetched packets */ + for (; j < nb_rx; j++) { + l3fwd_simple_forward( + pkts_burst[j], portid, qconf); + } + } + + if (unlikely(lcore_rx_idle_count == qconf->n_rx_queue)) { + /** + * All Rx queues empty in recent consecutive polls, + * sleep in a conservative manner, meaning sleep as + * less as possible. + */ + for (i = 1, + lcore_idle_hint = qconf->rx_queue_list[0].idle_hint; + i < qconf->n_rx_queue; ++i) { + rx_queue = &(qconf->rx_queue_list[i]); + if (rx_queue->idle_hint < lcore_idle_hint) + lcore_idle_hint = rx_queue->idle_hint; + } + + if (lcore_idle_hint < SUSPEND_THRESHOLD) + /** + * execute "pause" instruction to avoid context + * switch which generally take hundred of + * microseconds for short sleep. + */ + rte_delay_us(lcore_idle_hint); + else { + /* suspend until rx interrupt triggers */ + if (intr_en) { + turn_on_off_intr(qconf, 1); + sleep_until_rx_interrupt( + qconf->n_rx_queue); + turn_on_off_intr(qconf, 0); + /** + * start receiving packets immediately + */ + if (likely(!is_done())) + goto start_rx; + } + } + stats[lcore_id].sleep_time += lcore_idle_hint; + } + } + + return 0; +} + /* main processing loop */ static int main_telemetry_loop(__rte_unused void *dummy) @@ -1440,7 +1605,8 @@ print_usage(const char *prgname) " --empty-poll: enable empty poll detection" " follow (training_flag, high_threshold, med_threshold)\n" " --telemetry: enable telemetry mode, to update" - " empty polls, full polls, and core busyness to telemetry\n", + " empty polls, full polls, and core busyness to telemetry\n" + " --interrupt-only: enable interrupt-only mode\n", prgname); } @@ -1585,6 +1751,7 @@ parse_ep_config(const char *q_arg) #define CMD_LINE_OPT_PARSE_PTYPE "parse-ptype" #define CMD_LINE_OPT_LEGACY "legacy" #define CMD_LINE_OPT_EMPTY_POLL "empty-poll" +#define CMD_LINE_OPT_INTERRUPT_ONLY "interrupt-only" #define CMD_LINE_OPT_TELEMETRY "telemetry" /* Parse the argument given in the command line of the application */ @@ -1606,6 +1773,7 @@ parse_args(int argc, char **argv) {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_LEGACY, 0, 0, 0}, {CMD_LINE_OPT_TELEMETRY, 0, 0, 0}, + {CMD_LINE_OPT_INTERRUPT_ONLY, 0, 0, 0}, {NULL, 0, 0, 0} }; @@ -1716,6 +1884,17 @@ parse_args(int argc, char **argv) printf("telemetry mode is enabled\n"); } + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_INTERRUPT_ONLY, + sizeof(CMD_LINE_OPT_INTERRUPT_ONLY))) { + if (app_mode != APP_MODE_DEFAULT) { + printf(" interrupt-only mode is mutually exclusive with other modes\n"); + return -1; + } + app_mode = APP_MODE_INTERRUPT; + printf("interrupt-only mode is enabled\n"); + } + if (!strncmp(lgopts[option_index].name, "enable-jumbo", 12)) { struct option lenopts = @@ -2298,7 +2477,8 @@ main(int argc, char **argv) RTE_ETH_FOREACH_DEV(portid) { struct rte_eth_conf local_port_conf = port_conf; /* not all app modes need interrupts */ - bool need_intr = app_mode == APP_MODE_LEGACY; + bool need_intr = app_mode == APP_MODE_LEGACY || + app_mode == APP_MODE_INTERRUPT; /* skip ports that are not enabled */ if ((enabled_port_mask & (1 << portid)) == 0) { @@ -2576,6 +2756,8 @@ main(int argc, char **argv) "Returns global power stats. Parameters: None"); rte_eal_mp_remote_launch(main_telemetry_loop, NULL, SKIP_MASTER); + } else if (app_mode == APP_MODE_INTERRUPT) { + rte_eal_mp_remote_launch(main_intr_loop, NULL, CALL_MASTER); } if (app_mode == APP_MODE_EMPTY_POLL || app_mode == APP_MODE_TELEMETRY) From patchwork Fri Jun 19 10:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71801 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DED92A0518; Fri, 19 Jun 2020 12:54:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97CA81BEDF; Fri, 19 Jun 2020 12:54:10 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 9CB731BEB4 for ; Fri, 19 Jun 2020 12:54:06 +0200 (CEST) IronPort-SDR: VpIhlnnKHDjFPwueBLx45kXtVVCpX9jE4Ub+5jBuhvmgAz+6SOb0buQaKTymupUTfZ+EmjxqDw Wxg3ICIMGN8w== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318784" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318784" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:54:06 -0700 IronPort-SDR: +fa7NOy5vIhlzQXc06Ie07ZZRY5KghYrmKo7GV0sMy5DXev7h/yZm5Cic6kW9CMVDKWzLFYVNv 12CTRbsSCNMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263347832" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:54:04 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , Ray Kinsella , Neil Horman , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:54 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 6/7] power: add API to probe support for a specific env 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" Currently, there is no way to know if the power management env is supported without trying to initialize it. The init API also does not distinguish between failure due to some error and failure due to power management not being available on the platform in the first place. Thus, add an API that provides capability of probing support for a specific power management API. Signed-off-by: Anatoly Burakov Suggested-by: Jerin Jacob --- lib/librte_power/Makefile | 1 + lib/librte_power/guest_channel.c | 26 +++++++++++++ lib/librte_power/guest_channel.h | 12 ++++++ lib/librte_power/meson.build | 3 +- lib/librte_power/power_acpi_cpufreq.c | 7 ++++ lib/librte_power/power_acpi_cpufreq.h | 10 +++++ lib/librte_power/power_common.c | 52 +++++++++++++++++++++++++ lib/librte_power/power_common.h | 3 ++ lib/librte_power/power_kvm_vm.c | 5 +++ lib/librte_power/power_kvm_vm.h | 10 +++++ lib/librte_power/power_pstate_cpufreq.c | 7 ++++ lib/librte_power/power_pstate_cpufreq.h | 10 +++++ lib/librte_power/rte_power.c | 17 ++++++++ lib/librte_power/rte_power.h | 18 +++++++++ lib/librte_power/rte_power_version.map | 1 + 15 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 lib/librte_power/power_common.c diff --git a/lib/librte_power/Makefile b/lib/librte_power/Makefile index 087d643ee5..3b067b615f 100644 --- a/lib/librte_power/Makefile +++ b/lib/librte_power/Makefile @@ -16,6 +16,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c power_acpi_cpufreq.c SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_kvm_vm.c guest_channel.c SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_empty_poll.c SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_pstate_cpufreq.c +SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_common.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h rte_power_empty_poll.h diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c index b984d55bc8..7b5926e5c4 100644 --- a/lib/librte_power/guest_channel.c +++ b/lib/librte_power/guest_channel.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include #include @@ -25,6 +26,31 @@ static int global_fds[RTE_MAX_LCORE] = { [0 ... RTE_MAX_LCORE-1] = -1 }; +int +guest_channel_host_check_exists(const char *path) +{ + char glob_path[PATH_MAX]; + glob_t g; + int ret; + + /* we cannot know in advance which cores have VM channels, so glob */ + snprintf(glob_path, PATH_MAX, "%s.*", path); + + ret = glob(glob_path, GLOB_NOSORT, NULL, &g); + if (ret != 0) { + /* couldn't read anything */ + ret = 0; + goto out; + } + + /* do we have at least one match? */ + ret = g.gl_pathc > 0; + +out: + globfree(&g); + return ret; +} + int guest_channel_host_connect(const char *path, unsigned int lcore_id) { diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h index 025961606c..e15db46fc7 100644 --- a/lib/librte_power/guest_channel.h +++ b/lib/librte_power/guest_channel.h @@ -10,6 +10,18 @@ extern "C" { #include +/** + * Check if any Virtio-Serial VM end-points exist in path. + * + * @param path + * The path to the serial device on the filesystem + * + * @return + * - 1 if at least one potential end-point found. + * - 0 if no end-points found. + */ +int guest_channel_host_check_exists(const char *path); + /** * Connect to the Virtio-Serial VM end-point located in path. It is * thread safe for unique lcore_ids. This function must be only called once from diff --git a/lib/librte_power/meson.build b/lib/librte_power/meson.build index cdf08f6df3..78c031c943 100644 --- a/lib/librte_power/meson.build +++ b/lib/librte_power/meson.build @@ -8,6 +8,7 @@ endif sources = files('rte_power.c', 'power_acpi_cpufreq.c', 'power_kvm_vm.c', 'guest_channel.c', 'rte_power_empty_poll.c', - 'power_pstate_cpufreq.c') + 'power_pstate_cpufreq.c', + 'power_common.c') headers = files('rte_power.h','rte_power_empty_poll.h') deps += ['timer'] diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index f443fce69f..583815a07e 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -59,6 +59,7 @@ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_available_frequencies" #define POWER_SYSFILE_SETSPEED \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_setspeed" +#define POWER_ACPI_DRIVER "acpi-cpufreq" /* * MSR related @@ -289,6 +290,12 @@ power_init_for_setting_freq(struct rte_power_info *pi) return -1; } +int +power_acpi_cpufreq_check_supported(void) +{ + return cpufreq_check_scaling_driver(POWER_ACPI_DRIVER); +} + int power_acpi_cpufreq_init(unsigned int lcore_id) { diff --git a/lib/librte_power/power_acpi_cpufreq.h b/lib/librte_power/power_acpi_cpufreq.h index 1af7416073..038857b3a6 100644 --- a/lib/librte_power/power_acpi_cpufreq.h +++ b/lib/librte_power/power_acpi_cpufreq.h @@ -20,6 +20,16 @@ extern "C" { #endif +/** + * Check if ACPI power management is supported. + * + * @return + * - 1 if supported + * - 0 if unsupported + * - -1 if error, with rte_errno indicating reason for error. + */ +int power_acpi_cpufreq_check_supported(void); + /** * Initialize power management for a specific lcore. It will check and set the * governor to userspace for the lcore, get the available frequencies, and diff --git a/lib/librte_power/power_common.c b/lib/librte_power/power_common.c new file mode 100644 index 0000000000..59023d986b --- /dev/null +++ b/lib/librte_power/power_common.c @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2020 Intel Corporation + */ + +#include +#include +#include + +#include "power_common.h" + +#define POWER_SYSFILE_SCALING_DRIVER \ + "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver" + +int +cpufreq_check_scaling_driver(const char *driver_name) +{ + unsigned int lcore_id = 0; /* always check core 0 */ + char fullpath[PATH_MAX]; + char readbuf[PATH_MAX]; + char *s; + FILE *f; + + /* + * Check if scaling driver matches what we expect. + */ + snprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_SCALING_DRIVER, + lcore_id); + f = fopen(fullpath, "r"); + + /* if there's no driver at all, bail out */ + if (f == NULL) + return 0; + + s = fgets(readbuf, sizeof(readbuf), f); + /* don't need it any more */ + fclose(f); + + /* if we can't read it, consider unsupported */ + if (s == NULL) + return 0; + + /* does the driver name match? */ + if (strncmp(readbuf, driver_name, sizeof(readbuf)) != 0) + return 0; + + /* + * We might have a situation where the driver is supported, but we don't + * have permissions to do frequency scaling. This error should not be + * handled here, so consider the system to support scaling for now. + */ + return 1; +} diff --git a/lib/librte_power/power_common.h b/lib/librte_power/power_common.h index feeb5777b7..fab3ca995a 100644 --- a/lib/librte_power/power_common.h +++ b/lib/librte_power/power_common.h @@ -7,4 +7,7 @@ #define RTE_POWER_INVALID_FREQ_INDEX (~0) +/* check if scaling driver matches one we want */ +int cpufreq_check_scaling_driver(const char *driver); + #endif /* _POWER_COMMON_H_ */ diff --git a/lib/librte_power/power_kvm_vm.c b/lib/librte_power/power_kvm_vm.c index 2bb17beb17..409c3e03ab 100644 --- a/lib/librte_power/power_kvm_vm.c +++ b/lib/librte_power/power_kvm_vm.c @@ -15,6 +15,11 @@ static struct channel_packet pkt[RTE_MAX_LCORE]; +int +power_kvm_vm_check_supported(void) +{ + return guest_channel_host_check_exists(FD_PATH); +} int power_kvm_vm_init(unsigned int lcore_id) diff --git a/lib/librte_power/power_kvm_vm.h b/lib/librte_power/power_kvm_vm.h index 94d4aa1213..73b4c82e57 100644 --- a/lib/librte_power/power_kvm_vm.h +++ b/lib/librte_power/power_kvm_vm.h @@ -20,6 +20,16 @@ extern "C" { #endif +/** + * Check if KVM power management is supported. + * + * @return + * - 1 if supported + * - 0 if unsupported + * - -1 if error, with rte_errno indicating reason for error. + */ +int power_kvm_vm_check_supported(void); + /** * Initialize power management for a specific lcore. * diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 2d8a9499dc..2526441a4c 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -71,6 +71,7 @@ "/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_min_freq" #define POWER_SYSFILE_BASE_FREQ \ "/sys/devices/system/cpu/cpu%u/cpufreq/base_frequency" +#define POWER_PSTATE_DRIVER "intel_pstate" #define POWER_MSR_PATH "/dev/cpu/%u/msr" /* @@ -531,6 +532,12 @@ power_get_available_freqs(struct pstate_power_info *pi) return ret; } +int +power_pstate_cpufreq_check_supported(void) +{ + return cpufreq_check_scaling_driver(POWER_PSTATE_DRIVER); +} + int power_pstate_cpufreq_init(unsigned int lcore_id) { diff --git a/lib/librte_power/power_pstate_cpufreq.h b/lib/librte_power/power_pstate_cpufreq.h index 6fd801881f..0be0bd6b81 100644 --- a/lib/librte_power/power_pstate_cpufreq.h +++ b/lib/librte_power/power_pstate_cpufreq.h @@ -20,6 +20,16 @@ extern "C" { #endif +/** + * Check if pstate power management is supported. + * + * @return + * - 1 if supported + * - 0 if unsupported + * - -1 if error, with rte_errno indicating reason for error. + */ +int power_pstate_cpufreq_check_supported(void); + /** * Initialize power management for a specific lcore. It will check and set the * governor to performance for the lcore, get the available frequencies, and diff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c index 6b77227275..98eaba9154 100644 --- a/lib/librte_power/rte_power.c +++ b/lib/librte_power/rte_power.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include "rte_power.h" @@ -43,6 +44,22 @@ reset_power_function_ptrs(void) rte_power_get_capabilities = NULL; } +int +rte_power_check_env_supported(enum power_management_env env) +{ + switch (env) { + case PM_ENV_ACPI_CPUFREQ: + return power_acpi_cpufreq_check_supported(); + case PM_ENV_PSTATE_CPUFREQ: + return power_pstate_cpufreq_check_supported(); + case PM_ENV_KVM_VM: + return power_kvm_vm_check_supported(); + default: + rte_errno = EINVAL; + return -1; + } +} + int rte_power_set_env(enum power_management_env env) { diff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h index 427058b811..bbbde4dfb4 100644 --- a/lib/librte_power/rte_power.h +++ b/lib/librte_power/rte_power.h @@ -23,6 +23,24 @@ extern "C" { enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM, PM_ENV_PSTATE_CPUFREQ}; +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * Check if a specific power management environment type is supported on a + * currently running system. + * + * @param env + * The environment type to check support for. + * + * @return + * - 1 if supported + * - 0 if unsupported + * - -1 if error, with rte_errno indicating reason for error. + */ +__rte_experimental +int rte_power_check_env_supported(enum power_management_env env); + /** * Set the default power management implementation. If this is not called prior * to rte_power_init(), then auto-detect of the environment will take place. diff --git a/lib/librte_power/rte_power_version.map b/lib/librte_power/rte_power_version.map index 55a168f56e..00ee5753e2 100644 --- a/lib/librte_power/rte_power_version.map +++ b/lib/librte_power/rte_power_version.map @@ -26,6 +26,7 @@ EXPERIMENTAL { global: rte_empty_poll_detection; + rte_power_check_env_supported; rte_power_empty_poll_stat_fetch; rte_power_empty_poll_stat_free; rte_power_empty_poll_stat_init; From patchwork Fri Jun 19 10:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 71802 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 286C8A0518; Fri, 19 Jun 2020 12:54:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF74A1BEE7; Fri, 19 Jun 2020 12:54:11 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 626811B9B7 for ; Fri, 19 Jun 2020 12:54:08 +0200 (CEST) IronPort-SDR: Iv2vVOtrdUjXrJM/AWRznsEE2PFGSePlGZY34yrVBGuGsDUQoT1rrwo1vNw2ucEapjYnEXbSiv zBv4Yotm+V1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318786" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318786" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:54:08 -0700 IronPort-SDR: Y9EWuaK74sifGX8mU9JY0gj+9aZvOWDRvrVc9+hI61/q1P57L4COp3ctNPLIwLfJVDY0oiHOI/ AL09/3tz+GWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263347993" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:54:06 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:55 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 7/7] l3fwd-power: add auto-selection of default mode 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" Currently, the application does support running without the power library being initialized, but it has to be specifically requested. On platforms without support for frequency scaling using the power library, we can just enable interrupt-only mode by default. Signed-off-by: Anatoly Burakov Suggested-by: Jerin Jacob Tested-by: Harman Kalra --- examples/l3fwd-power/main.c | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 51acbfd87d..6a4a27984b 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -2412,6 +2412,42 @@ launch_timer(unsigned int lcore_id) return 0; } +static int +autodetect_mode(void) +{ + RTE_LOG(NOTICE, L3FWD_POWER, "Operating mode not specified, probing frequency scaling support...\n"); + + /* + * Empty poll and telemetry modes have to be specifically requested to + * be enabled, but we can auto-detect between interrupt mode with or + * without frequency scaling. Both ACPI and pstate can be used. + */ + if (rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ)) + return APP_MODE_LEGACY; + if (rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) + return APP_MODE_LEGACY; + + RTE_LOG(NOTICE, L3FWD_POWER, "Frequency scaling not supported, selecting interrupt-only mode\n"); + + return APP_MODE_INTERRUPT; +} + +static const char * +mode_to_str(enum appmode mode) +{ + switch (mode) { + case APP_MODE_LEGACY: + return "legacy"; + case APP_MODE_EMPTY_POLL: + return "empty poll"; + case APP_MODE_TELEMETRY: + return "telemetry"; + case APP_MODE_INTERRUPT: + return "interrupt-only"; + default: + return "invalid"; + } +} int main(int argc, char **argv) @@ -2449,7 +2485,10 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n"); if (app_mode == APP_MODE_DEFAULT) - app_mode = APP_MODE_LEGACY; + app_mode = autodetect_mode(); + + RTE_LOG(INFO, L3FWD_POWER, "Selected operation mode: %s\n", + mode_to_str(app_mode)); /* only legacy and empty poll mode rely on power library */ if ((app_mode == APP_MODE_LEGACY || app_mode == APP_MODE_EMPTY_POLL) &&