summaryrefslogtreecommitdiff
path: root/examples/vm_power_manager
diff options
context:
space:
mode:
authorDavid Hunt <david.hunt@intel.com>2018-07-13 15:23:02 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-07-21 00:00:43 +0200
commit711f43ba568acadf6cbccb9f8a29abf0fb3baa25 (patch)
treeaaff58f4dac8274089f33ee15f57bd24cbc10509 /examples/vm_power_manager
parent59287933a0bb7101cdf9df8ba5dba0ae944e1ee3 (diff)
downloaddpdk-711f43ba568acadf6cbccb9f8a29abf0fb3baa25.zip
dpdk-711f43ba568acadf6cbccb9f8a29abf0fb3baa25.tar.gz
dpdk-711f43ba568acadf6cbccb9f8a29abf0fb3baa25.tar.xz
examples/vm_power: make branch ratio configurable
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 <david.hunt@intel.com> Acked-by: Radu Nicolau <radu.nicolau@intel.com>
Diffstat (limited to 'examples/vm_power_manager')
-rw-r--r--examples/vm_power_manager/main.c16
-rw-r--r--examples/vm_power_manager/oob_monitor_x86.c3
-rw-r--r--examples/vm_power_manager/power_manager.c1
-rw-r--r--examples/vm_power_manager/power_manager.h3
4 files changed, 20 insertions, 3 deletions
diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index f9990f1..58c5fa4 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -141,17 +141,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) {
@@ -184,6 +186,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 62d503c..589c604 100644
--- a/examples/vm_power_manager/oob_monitor_x86.c
+++ b/examples/vm_power_manager/oob_monitor_x86.c
@@ -22,7 +22,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
@@ -89,7 +88,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 4bdde23..b7769c3 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 45385de..605b3c8 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);