Advertisement
Guest User

powertop patch

a guest
Jul 3rd, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. --- powertop_orig/src/main.cpp  2013-07-04 13:03:22.338968093 +1000
  2. +++ powertop/src/main.cpp   2013-07-04 11:06:33.062885598 +1000
  3. @@ -53,6 +53,7 @@
  4.  
  5.  
  6.  #include "tuning/tuning.h"
  7. +#include "tuning/tunable.h"
  8.  
  9.  #include "display.h"
  10.  #include "devlist.h"
  11. @@ -71,6 +72,7 @@
  12.     {"version", no_argument, NULL, 'V'},
  13.     {"help",no_argument, NULL, 'u'}, /* u for usage */
  14.     {"calibrate",no_argument, NULL, 'c'},
  15. +   {"tune-all",no_argument, NULL, 'a'}, /* a for all */
  16.     {"html", optional_argument, NULL, 'h'},
  17.     {"csv", optional_argument, NULL, 'C'},
  18.     {"extech", optional_argument, NULL, 'e'},
  19. @@ -106,6 +108,7 @@
  20.     printf("--debug \t\t %s\n",_("run in \"debug\" mode"));
  21.     printf("--version \t\t %s\n",_("print version information"));
  22.     printf("--calibrate \t\t %s\n",_("runs powertop in calibration mode"));
  23. +   printf("--tune-all \t\t %s\n",_("Sets all tunable options to their GOOD setting"));
  24.     printf("--extech%s \t %s\n",_("[=devnode]"),_("uses an Extech Power Analyzer for measurements"));
  25.     printf("--html%s \t %s\n",_("[=FILENAME]"),_("generate a html report"));
  26.     printf("--csv%s \t %s\n",_("[=FILENAME]"),_("generate a csv report"));
  27. @@ -332,6 +335,55 @@
  28.     initialized = 1;
  29.  }
  30.  
  31. +void cleanup(void)
  32. +{
  33. +   end_process_data();
  34. +   clear_process_data();
  35. +   end_cpu_data();
  36. +   clear_cpu_data();
  37. +
  38. +   save_all_results("saved_results.powertop");
  39. +   save_parameters("saved_parameters.powertop");
  40. +   learn_parameters(500, 0);
  41. +   save_parameters("saved_parameters.powertop");
  42. +   end_pci_access();
  43. +   clear_tuning();
  44. +
  45. +   clear_all_devices();
  46. +   clear_all_cpus();
  47. +}
  48. +
  49. +void set_tunables(void)
  50. +{
  51. +   learn_parameters(250, 0);
  52. +   one_measurement(1, NULL);
  53. +   initialize_tuning();
  54. +
  55. +   std::cout << "Attempting to tune all settings to GOOD..." << std::endl;
  56. +
  57. +   std::vector<tunable *>::iterator it;
  58. +   for(it=all_tunables.begin(); it != all_tunables.end(); it++)
  59. +   {
  60. +       tunable *t = *it;
  61. +       switch(t->good_bad())
  62. +       {
  63. +       case TUNE_GOOD:
  64. +           break;
  65. +       case TUNE_BAD:
  66. +           t->toggle();
  67. +           break;
  68. +       case TUNE_UNFIXABLE:
  69. +           break;
  70. +       default:
  71. +           break;
  72. +       }
  73. +
  74. +       std::cout   << t->result_string() << " "
  75. +                   << t->description() << std::endl;
  76. +   }
  77. +
  78. +   cleanup();
  79. +}
  80.  
  81.  int main(int argc, char **argv)
  82.  {
  83. @@ -348,7 +400,7 @@
  84.     textdomain (PACKAGE);
  85.  
  86.     while (1) { /* parse commandline options */
  87. -       c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index);
  88. +       c = getopt_long (argc, argv, "ch:C:i:t:uVaw:q", long_options, &option_index);
  89.         /* Detect the end of the options. */
  90.         if (c == -1)
  91.             break;
  92. @@ -367,6 +419,12 @@
  93.                 print_usage();
  94.                 exit(0);
  95.                 break;
  96. +      
  97. +           case 'a': /* set all tunables */
  98. +               powertop_init();
  99. +               set_tunables();
  100. +               exit(0);
  101. +               break;
  102.  
  103.             case 'c':
  104.                 powertop_init();
  105. @@ -439,21 +497,8 @@
  106.     endwin();
  107.     printf("%s\n", _("Leaving PowerTOP"));
  108.  
  109. -   end_process_data();
  110. -   clear_process_data();
  111. -   end_cpu_data();
  112. -   clear_cpu_data();
  113. -
  114. -   save_all_results("saved_results.powertop");
  115. -   save_parameters("saved_parameters.powertop");
  116. -   learn_parameters(500, 0);
  117. -   save_parameters("saved_parameters.powertop");
  118. -   end_pci_access();
  119. -   clear_tuning();
  120. +   cleanup();
  121.     reset_display();
  122.  
  123. -   clear_all_devices();
  124. -   clear_all_cpus();
  125. -
  126.     return 0;
  127.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement