From patchwork Tue Jun 26 09:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 41549 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C61C21B4FC; Tue, 26 Jun 2018 11:23:56 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A99F81B4BE for ; Tue, 26 Jun 2018 11:23:38 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 02:23:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,274,1526367600"; d="scan'208";a="67785398" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by orsmga001.jf.intel.com with ESMTP; 26 Jun 2018 02:23:37 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com Date: Tue, 26 Jun 2018 10:23:17 +0100 Message-Id: <20180626092317.11031-10-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626092317.11031-1-david.hunt@intel.com> References: <20180621132414.39047-2-david.hunt@intel.com> <20180626092317.11031-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v3 9/9] examples/vm_power: make branch ratio configurable 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" For different workloads and poll loops, the theshold may be different for when you want to scale up and down. This patch allows changing of the default branch ratio by using the -b command line argument (or --branch-ratio=) Signed-off-by: David Hunt Acked-by: Radu Nicolau --- examples/vm_power_manager/main.c | 16 +++++++++++++++- examples/vm_power_manager/oob_monitor_x86.c | 3 +-- examples/vm_power_manager/power_manager.c | 1 + examples/vm_power_manager/power_manager.h | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index 4088861f1..784d928bd 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -143,17 +143,19 @@ parse_args(int argc, char **argv) int option_index; char *prgname = argv[0]; struct core_info *ci; + float branch_ratio; static struct option lgopts[] = { { "mac-updating", no_argument, 0, 1}, { "no-mac-updating", no_argument, 0, 0}, { "core-list", optional_argument, 0, 'l'}, { "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:", + while ((opt = getopt_long(argc, argvopt, "l:p:q:T:b:", lgopts, &option_index)) != EOF) { switch (opt) { @@ -186,6 +188,18 @@ parse_args(int argc, char **argv) } 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 485ec5e3f..ea327b819 100644 --- a/examples/vm_power_manager/oob_monitor_x86.c +++ b/examples/vm_power_manager/oob_monitor_x86.c @@ -45,7 +45,6 @@ void branch_monitor_exit(void) /* Number of microseconds between each poll */ #define INTERVAL 100 #define PRINT_LOOP_COUNT (1000000/INTERVAL) -#define RATIO_THRESHOLD 0.03 #define IA32_PERFEVTSEL0 0x186 #define IA32_PERFEVTSEL1 0x187 #define IA32_PERFCTR0 0xc1 @@ -112,7 +111,7 @@ apply_policy(int core) ratio = (float)miss_diff * (float)100 / (float)hits_diff; - if (ratio < RATIO_THRESHOLD) + if (ratio < ci->branch_ratio_threshold) power_manager_scale_core_min(core); else power_manager_scale_core_max(core); diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c index 4bdde23da..b7769c3c3 100644 --- a/examples/vm_power_manager/power_manager.c +++ b/examples/vm_power_manager/power_manager.c @@ -74,6 +74,7 @@ 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)); if (!ci->cd) { RTE_LOG(ERR, POWER_MANAGER, "Failed to allocate memory for core info."); diff --git a/examples/vm_power_manager/power_manager.h b/examples/vm_power_manager/power_manager.h index 45385de37..605b3c8f6 100644 --- a/examples/vm_power_manager/power_manager.h +++ b/examples/vm_power_manager/power_manager.h @@ -19,8 +19,11 @@ struct core_details { struct core_info { uint16_t core_count; struct core_details *cd; + float branch_ratio_threshold; }; +#define BRANCH_RATIO_THRESHOLD 0.1 + struct core_info * get_core_info(void);