This patch gets rid of a major annoyance:  it stops the "use NO_HZ!"
suggestions on x86_64 and other platforms which can't support it.

This lets the other messages -- the ones which could actually do some
good on this system!! -- be seen.  Else, it seems like the impossible
NO_HZ suggestion is the only one ever visible.

Signed-off-by: David Brownell <[EMAIL PROTECTED]>

--- config.c    (revision 254)
+++ config.c    (working copy)
@@ -82,6 +82,27 @@
        fclose(file);
 }
 
+int has_kernel_config(char *string, int onoff)
+{
+       int i;
+       char searchon[100];
+       char searchoff[100];
+
+
+       read_kernel_config();
+
+       sprintf(searchon, "%s=", string);
+       sprintf(searchoff, "# %s is not set", string);
+
+       for (i = 0; i < configcount; i++) {
+               if (onoff && strstr(configlines[i], searchon))
+                       return 1;
+               if (onoff==0 && strstr(configlines[i], searchoff))
+                       return 0;
+       }
+       return 0;
+}
+
 /*
  * Suggest the user to turn on/off a kernel config option.
  * "comment" gets displayed if it's not already set to the right value 
--- powertop.c  (revision 254)
+++ powertop.c  (working copy)
@@ -665,7 +665,12 @@
                suggest_kernel_config("CONFIG_CPU_FREQ_GOV_ONDEMAND", 1,
                                    _("Suggestion: Enable the 
CONFIG_CPU_FREQ_GOV_ONDEMAND kernel configuration option.\n"
                                      "The 'ondemand' CPU speed governor will 
minimize the CPU power usage while\n" "giving you performance when it is 
needed."), 5);
-               suggest_kernel_config("CONFIG_NO_HZ", 1, _("Suggestion: Enable 
the CONFIG_NO_HZ kernel configuration option.\nThis option is required to get 
any kind of longer sleep times in the CPU."), 50);
+               if (has_kernel_config("CONFIG_TICK_ONESHOT", 1))
+                       suggest_kernel_config("CONFIG_NO_HZ", 1,
+                               _("Suggestion: Enable the CONFIG_NO_HZ kernel "
+                               "configuration option.\nThis option is "
+                               "required to get any kind of longer sleep "
+                               "times in the CPU."), 50);
                suggest_kernel_config("CONFIG_ACPI_BATTERY", 1, _("Suggestion: 
Enable the CONFIG_ACPI_BATTERY kernel configuration option.\n "
                                      "This option is required to get power 
estimages from PowerTOP"), 5);
                suggest_kernel_config("CONFIG_HPET_TIMER", 1,
--- powertop.h  (revision 254)
+++ powertop.h  (working copy)
@@ -43,6 +43,7 @@
 extern double displaytime;
 
 void suggest_process_death(char *process_match, char *process_name, struct 
line *slines, int linecount, double minwakeups, char *comment, int weight);
+int has_kernel_config(char *string, int onoff);
 void suggest_kernel_config(char *string, int onoff, char *comment, int weight);
 void suggest_laptop_mode(void);
 void suggest_bluetooth_off(void);

_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power

Reply via email to