diff options
author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2013-09-17 21:36:55 +0300 |
---|---|---|
committer | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2013-09-18 12:20:27 +0300 |
commit | dc67951e80b9b27066c0aac74e5b9975e291e23e (patch) | |
tree | 0f295227011bd54c72e2c3e7a54e56d487830352 | |
parent | 4cbb957605818dc7e4b7932dafac0aad5ed0b87a (diff) |
Introduce --auto-tune mode
Original idea by Mark Boorer <markboo99@gmail.com>
Introduce --auto-tune mode.
Auto tune toggles all existing tunables to GOOD state and finishes
powertop execution.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
-rw-r--r-- | src/main.cpp | 23 | ||||
-rw-r--r-- | src/tuning/tuning.cpp | 8 | ||||
-rw-r--r-- | src/tuning/tuning.h | 4 |
3 files changed, 25 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index e74890f..501a364 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,6 +72,7 @@ static const struct option long_options[] = {"version", no_argument, NULL, 'V'}, {"help",no_argument, NULL, 'u'}, /* u for usage */ {"calibrate",no_argument, NULL, 'c'}, + {"auto-tune",no_argument, NULL, 'a'}, {"html", optional_argument, NULL, 'h'}, {"csv", optional_argument, NULL, 'C'}, {"extech", optional_argument, NULL, 'e'}, @@ -107,6 +108,7 @@ static void print_usage() printf("--debug \t\t %s\n",_("run in \"debug\" mode")); printf("--version \t\t %s\n",_("print version information")); printf("--calibrate \t\t %s\n",_("runs powertop in calibration mode")); + printf("--auto-tune \t\t %s\n",_("Sets all tunable options to their GOOD setting")); printf("--extech%s \t %s\n",_("[=devnode]"),_("uses an Extech Power Analyzer for measurements")); printf("--html%s \t %s\n",_("[=FILENAME]"),_("generate a html report")); printf("--csv%s \t %s\n",_("[=FILENAME]"),_("generate a csv report")); @@ -346,7 +348,7 @@ int main(int argc, char **argv) int c; char filename[4096]; char workload[4096] = {0,}; - int iterations = 1; + int iterations = 1, auto_tune = 0; set_new_handler(out_of_memory); @@ -374,7 +376,10 @@ int main(int argc, char **argv) print_usage(); exit(0); break; - + case 'a': + auto_tune = 1; + leave_powertop = 1; + break; case 'c': powertop_init(); calibrate(); @@ -430,13 +435,17 @@ int main(int argc, char **argv) end_pci_access(); exit(0); } - - /* first one is short to not let the user wait too long */ init_display(); - one_measurement(1, NULL); initialize_tuning(); - tuning_update_display(); - show_tab(0); + /* first one is short to not let the user wait too long */ + one_measurement(1, NULL); + + if (!auto_tune) { + tuning_update_display(); + show_tab(0); + } else { + auto_toggle_tuning(); + } while (!leave_powertop) { show_cur_tab(); diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp index 08d8251..ff3d715 100644 --- a/src/tuning/tuning.cpp +++ b/src/tuning/tuning.cpp @@ -273,3 +273,11 @@ void clear_tuning() } all_untunables.clear(); } + +void auto_toggle_tuning() +{ + for (unsigned int i = 0; i < all_tunables.size(); i++) { + if (all_tunables[i]->good_bad() == TUNE_BAD) + all_tunables[i]->toggle(); + } +} diff --git a/src/tuning/tuning.h b/src/tuning/tuning.h index 7c4921f..f70001b 100644 --- a/src/tuning/tuning.h +++ b/src/tuning/tuning.h @@ -29,7 +29,5 @@ extern void initialize_tuning(void); extern void tuning_update_display(void); extern void report_show_tunables(void); extern void clear_tuning(void); - - - +extern void auto_toggle_tuning(void); #endif |