From patchwork Tue Jul 14 16:01:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sexton, Rory" X-Patchwork-Id: 74014 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 88381A0540; Tue, 14 Jul 2020 18:02:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1ABA81D182; Tue, 14 Jul 2020 18:02:20 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id D36A91D165 for ; Tue, 14 Jul 2020 18:02:16 +0200 (CEST) IronPort-SDR: yOpQmFU1PHTbJ/6TVwq+CQnbqg4Cpgv2vW0tL1Go8bGKTMK8lf2n6pNi1DlDwS0PEsY8t0fHgc M4SMfoG4524A== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="146446380" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="146446380" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 09:02:02 -0700 IronPort-SDR: kqciJCiIpUqUEqtz9gb/Es4vnPmFy9n88JTj0zgF+7/B515jXqQDznVx5/TCtE/nie5Gdph9Z5 ah+TPO6R9xPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="285799812" Received: from silpixa00399913.ir.intel.com ([10.237.213.189]) by orsmga006.jf.intel.com with ESMTP; 14 Jul 2020 09:02:01 -0700 From: Rory Sexton To: dev@dpdk.org, david.hunt@intel.com Date: Tue, 14 Jul 2020 17:01:58 +0100 Message-Id: <20200714160200.1727417-1-rory.sexton@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dpdk-dev] [v4 1/3] examples/vm_power_manager: Make branch ratio threshold per core 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" This modification allows for the branch ratio threshold to be set per core rather than system wide. This gives greater flexibility to the branch ration monitoring allowing it to manage different workloads with different characteristics on the same system. Signed-off-by: Rory Sexton Reviewed-by: David Hunt Acked-by: Reshma Pattan --- v4: adding upper limit of 100.0 to branch ratio --- examples/vm_power_manager/main.c | 41 +++++++++++--------- examples/vm_power_manager/oob_monitor_x86.c | 2 +- examples/vm_power_manager/parse.c | 42 ++++++++++++++++++++- examples/vm_power_manager/parse.h | 3 ++ examples/vm_power_manager/power_manager.c | 2 +- examples/vm_power_manager/power_manager.h | 2 +- 6 files changed, 69 insertions(+), 23 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index 273bfec29..77797b1e1 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -165,15 +165,14 @@ parse_args(int argc, char **argv) static struct option lgopts[] = { { "mac-updating", no_argument, 0, 1}, { "no-mac-updating", no_argument, 0, 0}, - { "core-list", optional_argument, 0, 'l'}, + { "core-branch-ratio", optional_argument, 0, 'b'}, { "port-list", optional_argument, 0, 'p'}, - { "branch-ratio", optional_argument, 0, 'b'}, {NULL, 0, 0, 0} }; argvopt = argv; ci = get_core_info(); - while ((opt = getopt_long(argc, argvopt, "l:p:q:T:b:", + while ((opt = getopt_long(argc, argvopt, "p:q:T:b:", lgopts, &option_index)) != EOF) { switch (opt) { @@ -185,7 +184,8 @@ parse_args(int argc, char **argv) return -1; } break; - case 'l': + case 'b': + branch_ratio = BRANCH_RATIO_THRESHOLD; oob_enable = malloc(ci->core_count * sizeof(uint16_t)); if (oob_enable == NULL) { printf("Error - Unable to allocate memory\n"); @@ -193,32 +193,37 @@ parse_args(int argc, char **argv) } cnt = parse_set(optarg, oob_enable, ci->core_count); if (cnt < 0) { - printf("Invalid core-list - [%s]\n", + printf("Invalid core-list section in " + "core-branch-ratio matrix - [%s]\n", optarg); free(oob_enable); break; } + cnt = parse_branch_ratio(optarg, &branch_ratio); + if (cnt < 0) { + printf("Invalid branch-ratio section in " + "core-branch-ratio matrix - [%s]\n", + optarg); + free(oob_enable); + break; + } + if (branch_ratio <= 0.0 || branch_ratio > 100.0) { + printf("invalid branch ratio specified\n"); + return -1; + } for (i = 0; i < ci->core_count; i++) { if (oob_enable[i]) { - printf("***Using core %d\n", i); + printf("***Using core %d " + "with branch ratio %f\n", + i, branch_ratio); ci->cd[i].oob_enabled = 1; ci->cd[i].global_enabled_cpus = 1; + ci->cd[i].branch_ratio_threshold = + branch_ratio; } } free(oob_enable); break; - case 'b': - branch_ratio = 0.0; - if (strlen(optarg)) - branch_ratio = atof(optarg); - if (branch_ratio <= 0.0) { - printf("invalid branch ratio specified\n"); - return -1; - } - ci->branch_ratio_threshold = branch_ratio; - printf("***Setting branch ratio to %f\n", - branch_ratio); - break; /* long options */ case 0: break; diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_power_manager/oob_monitor_x86.c index aecfcb2eb..3c514475f 100644 --- a/examples/vm_power_manager/oob_monitor_x86.c +++ b/examples/vm_power_manager/oob_monitor_x86.c @@ -109,7 +109,7 @@ apply_policy(int core) * down. Each core_details struct has it's own array. */ freq_window_idx = ci->cd[core].freq_window_idx; - if (ratio > ci->branch_ratio_threshold) + if (ratio > ci->cd[core].branch_ratio_threshold) ci->cd[core].freq_directions[freq_window_idx] = 1; else ci->cd[core].freq_directions[freq_window_idx] = 0; diff --git a/examples/vm_power_manager/parse.c b/examples/vm_power_manager/parse.c index 8231533b6..8a8dcf05f 100644 --- a/examples/vm_power_manager/parse.c +++ b/examples/vm_power_manager/parse.c @@ -60,7 +60,7 @@ parse_set(const char *input, uint16_t set[], unsigned int num) min = idx; else /* avoid continuous '-' */ return -1; - } else if ((*end == ',') || (*end == '\0')) { + } else if ((*end == ',') || (*end == ':') || (*end == '\0')) { max = idx; if (min == num) @@ -75,7 +75,45 @@ parse_set(const char *input, uint16_t set[], unsigned int num) return -1; str = end + 1; - } while (*end != '\0'); + } while ((*end != '\0') && (*end != ':')); + + return str - input; +} + +int +parse_branch_ratio(const char *input, float *branch_ratio) +{ + const char *str = input; + char *end = NULL; + + while (isblank(*str)) + str++; + + if (*str == '\0') + return -1; + + /* Go straight to the ':' separator if present */ + while ((*str != '\0') && (*str != ':')) + str++; + + /* Branch ratio not specified in args so leave it at default setting */ + if (*str == '\0') + return 0; + + /* Confirm ':' separator present */ + if (*str != ':') + return -1; + + str++; + errno = 0; + *branch_ratio = strtof(str, &end); + if (errno || end == NULL) + return -1; + + if (*end != '\0') + return -1; + + str = end + 1; return str - input; } diff --git a/examples/vm_power_manager/parse.h b/examples/vm_power_manager/parse.h index a5971e9a2..892dee449 100644 --- a/examples/vm_power_manager/parse.h +++ b/examples/vm_power_manager/parse.h @@ -12,6 +12,9 @@ extern "C" { int parse_set(const char *, uint16_t [], unsigned int); +int +parse_branch_ratio(const char *input, float *branch_ratio); + #ifdef __cplusplus } #endif diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c index cd51d4741..c5cf6bffa 100644 --- a/examples/vm_power_manager/power_manager.c +++ b/examples/vm_power_manager/power_manager.c @@ -59,7 +59,6 @@ core_info_init(void) ci = get_core_info(); ci->core_count = get_nprocs_conf(); - ci->branch_ratio_threshold = BRANCH_RATIO_THRESHOLD; ci->cd = malloc(ci->core_count * sizeof(struct core_details)); memset(ci->cd, 0, ci->core_count * sizeof(struct core_details)); if (!ci->cd) { @@ -68,6 +67,7 @@ core_info_init(void) } for (i = 0; i < ci->core_count; i++) { ci->cd[i].global_enabled_cpus = 1; + ci->cd[i].branch_ratio_threshold = BRANCH_RATIO_THRESHOLD; } printf("%d cores in system\n", ci->core_count); return 0; diff --git a/examples/vm_power_manager/power_manager.h b/examples/vm_power_manager/power_manager.h index e324766b6..d35f8cbe0 100644 --- a/examples/vm_power_manager/power_manager.h +++ b/examples/vm_power_manager/power_manager.h @@ -26,12 +26,12 @@ struct core_details { uint16_t freq_directions[FREQ_WINDOW_SIZE]; uint16_t freq_window_idx; uint16_t freq_state; + float branch_ratio_threshold; }; struct core_info { uint16_t core_count; struct core_details *cd; - float branch_ratio_threshold; }; #define BRANCH_RATIO_THRESHOLD 0.1 From patchwork Tue Jul 14 16:01:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sexton, Rory" X-Patchwork-Id: 74013 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 C0E87A0540; Tue, 14 Jul 2020 18:02:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9A6911D168; Tue, 14 Jul 2020 18:02:17 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 374A51D165 for ; Tue, 14 Jul 2020 18:02:16 +0200 (CEST) IronPort-SDR: cDQoaC4UFdxPeufiYAZ4vSbHWm8XE/EkomiqGnjXSMclbTusxC/5DwSfd8yfr5jkaD6fnJ7W2n mQHFnEYAldBQ== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="146446384" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="146446384" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 09:02:03 -0700 IronPort-SDR: n9yf2JAVXQ7h4QYPgkU9qktUJFznk50gYKLpPMGmm5CBmYQGpA4w2Yz/tX4OdG4Xx+RBiYKYZd UcaypxEuY0uQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="285799820" Received: from silpixa00399913.ir.intel.com ([10.237.213.189]) by orsmga006.jf.intel.com with ESMTP; 14 Jul 2020 09:02:02 -0700 From: Rory Sexton To: dev@dpdk.org, david.hunt@intel.com Date: Tue, 14 Jul 2020 17:01:59 +0100 Message-Id: <20200714160200.1727417-2-rory.sexton@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714160200.1727417-1-rory.sexton@intel.com> References: <20200714160200.1727417-1-rory.sexton@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [v4 2/3] examples/vm_power_manager: Allowing power managing of idle cores 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" This change is required to allow the branch ratio algorithm to power manage cores with no workload running on them. This is useful both when idle cores don't use C-states and for a number of hyperthreading scenarios. Signed-off-by: Rory Sexton Reviewed-by: David Hunt Acked-by: Reshma pattan --- v4: no changes --- examples/vm_power_manager/oob_monitor_x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_power_manager/oob_monitor_x86.c index 3c514475f..a5b1c168c 100644 --- a/examples/vm_power_manager/oob_monitor_x86.c +++ b/examples/vm_power_manager/oob_monitor_x86.c @@ -96,12 +96,12 @@ apply_policy(int core) g_branch_misses = miss_diff; if (hits_diff < (INTERVAL*100)) { - /* Likely no workload running on this core. Skip. */ - return -1.0; + /* Likely no workload running on this core. */ + ratio = 0.0; + } else { + ratio = (float)miss_diff * (float)100 / (float)hits_diff; } - ratio = (float)miss_diff * (float)100 / (float)hits_diff; - /* * Store the last few directions that the ratio indicates * we should take. If there's on 'up', then we scale up From patchwork Tue Jul 14 16:02:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sexton, Rory" X-Patchwork-Id: 74015 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 239E8A0540; Tue, 14 Jul 2020 18:02:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB1A21D409; Tue, 14 Jul 2020 18:02:21 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7357E1D166 for ; Tue, 14 Jul 2020 18:02:17 +0200 (CEST) IronPort-SDR: MM2wpKFVHEYY/T+16Qvb3JgBJuqHi9RWGWhHbfTT1FTUMirvmCfBiBDViUDeYAZsP8Hy86HSVe aSYug+/XZ9bg== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="146446392" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="146446392" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 09:02:03 -0700 IronPort-SDR: mfrDlVYVu7fgqFyzc/3WntC23cZYgP8O6iyy2Mn/osVksXrPqepLr17DX/LirqRbHR3eJU70gJ Mn9jwpp8PpnA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="285799828" Received: from silpixa00399913.ir.intel.com ([10.237.213.189]) by orsmga006.jf.intel.com with ESMTP; 14 Jul 2020 09:02:03 -0700 From: Rory Sexton To: dev@dpdk.org, david.hunt@intel.com Date: Tue, 14 Jul 2020 17:02:00 +0100 Message-Id: <20200714160200.1727417-3-rory.sexton@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714160200.1727417-1-rory.sexton@intel.com> References: <20200714160200.1727417-1-rory.sexton@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [v4 3/3] doc: update vm_power_manager cmdline options in doc 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" Updating the vm_power_manager docs to reflect changes made in previous patches in set. Signed-off-by: Rory Sexton Reviewed-by: David Hunt Acked-by: Reshma Pattan --- v4: no changes --- doc/guides/sample_app_ug/vm_power_management.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/guides/sample_app_ug/vm_power_management.rst b/doc/guides/sample_app_ug/vm_power_management.rst index e98277ccb..1b6de8e93 100644 --- a/doc/guides/sample_app_ug/vm_power_management.rst +++ b/doc/guides/sample_app_ug/vm_power_management.rst @@ -410,19 +410,21 @@ There are a couple of command line parameters for enabling the out-of-band monitoring of branch ratios on cores doing busy polling using PMDs as described below: -``--core-list {list of cores}`` +``--core-branch-ratio {list of cores}:{branch ratio for listed cores}`` Specify the list of cores to monitor the ratio of branch misses to branch hits. A tightly-polling PMD thread has a very low branch ratio, therefore the core frequency scales down to the minimum allowed value. On receiving packets, the code path changes, causing the branch ratio to increase. When the ratio goes above the ratio threshold, the core frequency scales up to the maximum - allowed value. - -``--branch-ratio {ratio}`` - Specify a floating-point number that identifies the threshold at which - to scale up or down for the given workload. The default branch ratio - is 0.01 and needs adjustment for different workloads. + allowed value. The specified branch-ratio is a floating point number + that identifies the threshold at which to scale up or down for the + elements of the core-list. If not included the default branch ratio of + 0.01 but will need adjustment for different workloads + + This parameter can be used multiple times for different sets of cores. + The branch ratio mechanism can also be useful for non-PMD cores and + hyper-threaded environments where C-States are disabled. Compiling and Running the Guest Applications