forked from pool/powertop
Accepting request 39708 from Base:System
Copy from Base:System/powertop based on submit request 39708 from user seife OBS-URL: https://build.opensuse.org/request/show/39708 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/powertop?expand=0&rev=16
This commit is contained in:
parent
b5bb34a047
commit
88cda16d3b
788
powertop-1.11-svn_r332.diff
Normal file
788
powertop-1.11-svn_r332.diff
Normal file
@ -0,0 +1,788 @@
|
|||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/cpufreqstats.c powertop-svn_r332/cpufreqstats.c
|
||||||
|
--- powertop-1.11/cpufreqstats.c 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/cpufreqstats.c 2010-05-09 18:43:31.539888915 +0200
|
||||||
|
@@ -62,6 +62,17 @@ int sort_by_freq (const void *av, const
|
||||||
|
return b->frequency - a->frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
+static unsigned long turbo_hz;
|
||||||
|
+
|
||||||
|
+static int is_turbo(unsigned long hz)
|
||||||
|
+{
|
||||||
|
+ if (hz == turbo_hz)
|
||||||
|
+ return 1;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
static char *HzToHuman(unsigned long hz)
|
||||||
|
{
|
||||||
|
static char buffer[1024];
|
||||||
|
@@ -79,6 +90,9 @@ static char *HzToHuman(unsigned long hz)
|
||||||
|
if (Hz>1500000)
|
||||||
|
sprintf(buffer, _("%6.2f Ghz"), (Hz+5000.0)/1000000);
|
||||||
|
|
||||||
|
+ if (is_turbo(hz))
|
||||||
|
+ sprintf(buffer, "%s", _("Turbo Mode"));
|
||||||
|
+
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
@@ -164,6 +178,9 @@ void do_cpufreq_stats(void)
|
||||||
|
maxfreq=4;
|
||||||
|
qsort(&delta, maxfreq+1, sizeof(struct cpufreqdata), sort_by_freq);
|
||||||
|
|
||||||
|
+ if (delta[0].frequency == delta[1].frequency + 1000)
|
||||||
|
+ turbo_hz = delta[0].frequency;
|
||||||
|
+
|
||||||
|
topfreq = -1;
|
||||||
|
for (ret = 0 ; ret<=maxfreq; ret++) {
|
||||||
|
sprintf(cpufreqstrings[ret+1], "%6s %5.1f%%\n", HzToHuman(delta[ret].frequency), delta[ret].count * 100.0 / total_time);
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/display.c powertop-svn_r332/display.c
|
||||||
|
--- powertop-1.11/display.c 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/display.c 2010-05-09 18:43:31.522888881 +0200
|
||||||
|
@@ -143,7 +143,7 @@ void show_title_bar(void)
|
||||||
|
wbkgd(title_bar_window, COLOR_PAIR(PT_COLOR_HEADER_BAR));
|
||||||
|
werase(title_bar_window);
|
||||||
|
|
||||||
|
- print(title_bar_window, 0, 0, " PowerTOP version 1.11 (C) 2007 Intel Corporation");
|
||||||
|
+ print(title_bar_window, 0, 0, " PowerTOP version %s (C) 2007 Intel Corporation", VERSION);
|
||||||
|
|
||||||
|
wrefresh(title_bar_window);
|
||||||
|
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/Makefile powertop-svn_r332/Makefile
|
||||||
|
--- powertop-1.11/Makefile 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/Makefile 2010-05-09 18:43:31.543889009 +0200
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
BINDIR=/usr/bin
|
||||||
|
LOCALESDIR=/usr/share/locale
|
||||||
|
-MANDIR=/usr/share/man/man1
|
||||||
|
+MANDIR=/usr/share/man/man8
|
||||||
|
WARNFLAGS=-Wall -W -Wshadow
|
||||||
|
CFLAGS?=-O1 -g ${WARNFLAGS}
|
||||||
|
CC?=gcc
|
||||||
|
@@ -16,21 +16,21 @@ CC?=gcc
|
||||||
|
#
|
||||||
|
|
||||||
|
OBJS = powertop.o config.o process.o misctips.o bluetooth.o display.o suggestions.o wireless.o cpufreq.o \
|
||||||
|
- sata.o xrandr.o ethernet.o cpufreqstats.o usb.o urbnum.o intelcstates.o
|
||||||
|
+ sata.o xrandr.o ethernet.o cpufreqstats.o usb.o urbnum.o intelcstates.o wifi-new.o
|
||||||
|
|
||||||
|
|
||||||
|
powertop: $(OBJS) Makefile powertop.h
|
||||||
|
$(CC) ${CFLAGS} $(OBJS) -lncursesw -o powertop
|
||||||
|
@(cd po/ && $(MAKE))
|
||||||
|
|
||||||
|
-powertop.1.gz: powertop.1
|
||||||
|
+powertop.8.gz: powertop.8
|
||||||
|
gzip -c $< > $@
|
||||||
|
|
||||||
|
-install: powertop powertop.1.gz
|
||||||
|
+install: powertop powertop.8.gz
|
||||||
|
mkdir -p ${DESTDIR}${BINDIR}
|
||||||
|
cp powertop ${DESTDIR}${BINDIR}
|
||||||
|
mkdir -p ${DESTDIR}${MANDIR}
|
||||||
|
- cp powertop.1.gz ${DESTDIR}${MANDIR}
|
||||||
|
+ cp powertop.8.gz ${DESTDIR}${MANDIR}
|
||||||
|
@(cd po/ && env LOCALESDIR=$(LOCALESDIR) DESTDIR=$(DESTDIR) $(MAKE) $@)
|
||||||
|
|
||||||
|
# This is for translators. To update your po with new strings, do :
|
||||||
|
@@ -40,7 +40,7 @@ uptrans:
|
||||||
|
@(cd po/ && env LG=$(LG) $(MAKE) $@)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
- rm -f *~ powertop powertop.1.gz po/powertop.pot DEADJOE svn-commit* *.o *.orig
|
||||||
|
+ rm -f *~ powertop powertop.8.gz po/powertop.pot DEADJOE svn-commit* *.o *.orig
|
||||||
|
@(cd po/ && $(MAKE) $@)
|
||||||
|
|
||||||
|
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/misctips.c powertop-svn_r332/misctips.c
|
||||||
|
--- powertop-1.11/misctips.c 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/misctips.c 2010-05-09 18:43:31.542889143 +0200
|
||||||
|
@@ -32,56 +32,6 @@
|
||||||
|
|
||||||
|
#include "powertop.h"
|
||||||
|
|
||||||
|
-void set_laptop_mode(void)
|
||||||
|
-{
|
||||||
|
- FILE *file;
|
||||||
|
- file = fopen("/proc/sys/vm/laptop_mode", "w");
|
||||||
|
- if (!file)
|
||||||
|
- return;
|
||||||
|
- fprintf(file,"5\n");
|
||||||
|
- fclose(file);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-void suggest_laptop_mode(void)
|
||||||
|
-{
|
||||||
|
- FILE *file;
|
||||||
|
- int i;
|
||||||
|
- char buffer[1024];
|
||||||
|
- /*
|
||||||
|
- * Check to see if we are on AC - lots of distros have
|
||||||
|
- * annoying scripts to turn laptop mode off when on AC, which
|
||||||
|
- * results in annoying distracting return of set laptop mode
|
||||||
|
- * hint.
|
||||||
|
- */
|
||||||
|
- file = fopen("/proc/acpi/ac_adapter/AC/state", "r");
|
||||||
|
- if (!file)
|
||||||
|
- return;
|
||||||
|
- memset(buffer, 0, 1024);
|
||||||
|
- if (!fgets(buffer, 1023, file)) {
|
||||||
|
- fclose(file);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- fclose(file);
|
||||||
|
- if (strstr(buffer, "on-line") != NULL)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- /* Now check for laptop mode */
|
||||||
|
- file = fopen("/proc/sys/vm/laptop_mode", "r");
|
||||||
|
- if (!file)
|
||||||
|
- return;
|
||||||
|
- memset(buffer, 0, 1024);
|
||||||
|
- if (!fgets(buffer, 1023, file)) {
|
||||||
|
- fclose(file);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- i = strtoul(buffer, NULL, 10);
|
||||||
|
- if (i<1) {
|
||||||
|
- add_suggestion( _("Suggestion: Enable laptop-mode by executing the following command:\n"
|
||||||
|
- " echo 5 > /proc/sys/vm/laptop_mode \n"), 15, 'L', _(" L - enable Laptop mode "), set_laptop_mode);
|
||||||
|
- }
|
||||||
|
- fclose(file);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
void nmi_watchdog_off(void)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
@@ -149,6 +99,7 @@ void ac97_power_on(void)
|
||||||
|
fclose(file);
|
||||||
|
if (access("/dev/dsp", F_OK))
|
||||||
|
return;
|
||||||
|
+ /* kick power mgmt update to the driver */
|
||||||
|
file = fopen("/dev/dsp", "w");
|
||||||
|
if (file) {
|
||||||
|
fprintf(file,"1");
|
||||||
|
@@ -175,6 +126,46 @@ void suggest_ac97_powersave(void)
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void hda_power_on(void)
|
||||||
|
+{
|
||||||
|
+ FILE *file;
|
||||||
|
+
|
||||||
|
+ file = fopen("/sys/module/snd_hda_intel/parameters/power_save", "w");
|
||||||
|
+ if (!file)
|
||||||
|
+ return;
|
||||||
|
+ fprintf(file,"1");
|
||||||
|
+ fclose(file);
|
||||||
|
+ if (access("/dev/dsp", F_OK))
|
||||||
|
+ return;
|
||||||
|
+ /* kick power mgmt update to the driver */
|
||||||
|
+ file = fopen("/dev/dsp", "w");
|
||||||
|
+ if (file) {
|
||||||
|
+ fprintf(file,"1");
|
||||||
|
+ fclose(file);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void suggest_hda_powersave(void)
|
||||||
|
+{
|
||||||
|
+ FILE *file;
|
||||||
|
+ char buffer[1024];
|
||||||
|
+
|
||||||
|
+ file = fopen("/sys/module/snd_hda_intel/parameters/power_save", "r");
|
||||||
|
+ if (!file)
|
||||||
|
+ return;
|
||||||
|
+ memset(buffer, 0, 1024);
|
||||||
|
+ if (!fgets(buffer, 1023, file)) {
|
||||||
|
+ fclose(file);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if (buffer[0]=='0') {
|
||||||
|
+ add_suggestion( _("Suggestion: enable HD audio powersave mode by executing the following command:\n"
|
||||||
|
+ " echo 1 > /sys/module/snd_hda_intel/parameters/power_save \n"
|
||||||
|
+ "or by passing power_save=1 as module parameter."), 25, 'A', _(" A - Turn HD audio powersave on "), hda_power_on);
|
||||||
|
+ }
|
||||||
|
+ fclose(file);
|
||||||
|
+}
|
||||||
|
|
||||||
|
void noatime_on(void)
|
||||||
|
{
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/powertop.1 powertop-svn_r332/powertop.1
|
||||||
|
--- powertop-1.11/powertop.1 2008-12-30 19:52:54.000000000 +0100
|
||||||
|
+++ powertop-svn_r332/powertop.1 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
@@ -1,38 +0,0 @@
|
||||||
|
-.\" Hey, EMACS: -*- nroff -*-
|
||||||
|
-.\" First parameter, NAME, should be all caps
|
||||||
|
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||||
|
-.\" other parameters are allowed: see man(7), man(1)
|
||||||
|
-.TH POWERTOP 1 "May 12, 2007"
|
||||||
|
-.\" Please adjust this date whenever revising the manpage.
|
||||||
|
-.\"
|
||||||
|
-.\" Some roff macros, for reference:
|
||||||
|
-.\" .nh disable hyphenation
|
||||||
|
-.\" .hy enable hyphenation
|
||||||
|
-.\" .ad l left justify
|
||||||
|
-.\" .ad b justify to both left and right margins
|
||||||
|
-.\" .nf disable filling
|
||||||
|
-.\" .fi enable filling
|
||||||
|
-.\" .br insert line break
|
||||||
|
-.\" .sp <n> insert n+1 empty lines
|
||||||
|
-.\" for manpage-specific macros, see man(7)
|
||||||
|
-.SH NAME
|
||||||
|
-powertop \- program to analyze power consumption on Intel-based laptops
|
||||||
|
-.SH SYNOPSIS
|
||||||
|
-.B powertop
|
||||||
|
-.SH DESCRIPTION
|
||||||
|
-This manual page documents briefly the
|
||||||
|
-.B powertop
|
||||||
|
-commands.
|
||||||
|
-.PP
|
||||||
|
-.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||||
|
-.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
|
||||||
|
-.\" respectively.
|
||||||
|
-\fBpowertop\fP is a program that shows the power consumption on Intel-based
|
||||||
|
-laptops and makes suggestions on how to extend battery lifetime.
|
||||||
|
-.br
|
||||||
|
-The program is more fully described at http://www.linuxpowertop.org
|
||||||
|
-.SH AUTHOR
|
||||||
|
-powertop was written by Arjan van de Ven <arjan@linux.intel.com>.
|
||||||
|
-.PP
|
||||||
|
-This manual page was written by Carlo Segre <segre@debian.org>,
|
||||||
|
-for the Debian project (but may be used by others).
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/powertop.8 powertop-svn_r332/powertop.8
|
||||||
|
--- powertop-1.11/powertop.8 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ powertop-svn_r332/powertop.8 2010-05-09 18:43:31.519889352 +0200
|
||||||
|
@@ -0,0 +1,30 @@
|
||||||
|
+.TH POWERTOP 8 "Jan 26, 2009" "Linux" "powertop manual"
|
||||||
|
+.SH NAME
|
||||||
|
+powertop \- program to analyze power consumption on Intel-based laptops
|
||||||
|
+.SH SYNOPSIS
|
||||||
|
+.B powertop
|
||||||
|
+.RB [ \-d ]
|
||||||
|
+.RB [ \-t
|
||||||
|
+.IR DOUBLE
|
||||||
|
+.RB ]
|
||||||
|
+.RB [ \-h ]
|
||||||
|
+.SH DESCRIPTION
|
||||||
|
+.Pp
|
||||||
|
+\fBpowertop\fP is a program that shows the power consumption on Intel-based
|
||||||
|
+aptops and makes suggestions on how to extend battery lifetime.
|
||||||
|
+.SH OPTIONS
|
||||||
|
+.TP
|
||||||
|
+\fB\-d\fR, \fB\-\-dump
|
||||||
|
+ read wakeups once and print list of top offenders.
|
||||||
|
+.TP
|
||||||
|
+\fB\-t\fR, \fB\-\-time\fR=\fIDOUBLE\fR
|
||||||
|
+ default time to gather data in seconds.
|
||||||
|
+.TP
|
||||||
|
+\fB\-h\fR, \fB\-\-help
|
||||||
|
+ show the help message.
|
||||||
|
+.SH BUGS
|
||||||
|
+Send bug reports to <power@bughost.org>
|
||||||
|
+.SH SEE ALSO
|
||||||
|
+The program is more fully described at http://www.linuxpowertop.org/
|
||||||
|
+.SH AUTHOR
|
||||||
|
+powertop was written by Arjan van de Ven <arjan@linux.intel.com>, and is maintained by Auke Kok <auke@linux.intel.com>.
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/powertop.c powertop-svn_r332/powertop.c
|
||||||
|
--- powertop-1.11/powertop.c 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/powertop.c 2010-05-09 18:43:31.539888915 +0200
|
||||||
|
@@ -35,11 +35,11 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <time.h>
|
||||||
|
+#include <limits.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "powertop.h"
|
||||||
|
|
||||||
|
-#define VERSION "1.11"
|
||||||
|
|
||||||
|
uint64_t start_usage[8], start_duration[8];
|
||||||
|
uint64_t last_usage[8], last_duration[8];
|
||||||
|
@@ -171,6 +171,58 @@ int update_irq(int irq, uint64_t count,
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int percpu_hpet_timer(char *name)
|
||||||
|
+{
|
||||||
|
+ static int timer_list_read;
|
||||||
|
+ static int percpu_hpet_start = INT_MAX, percpu_hpet_end = INT_MIN;
|
||||||
|
+ char *c;
|
||||||
|
+ long hpet_chan;
|
||||||
|
+
|
||||||
|
+ if (!timer_list_read) {
|
||||||
|
+ char file_name[20];
|
||||||
|
+ char ln[80];
|
||||||
|
+ FILE *fp;
|
||||||
|
+
|
||||||
|
+ timer_list_read = 1;
|
||||||
|
+ snprintf(file_name, sizeof(file_name), "/proc/timer_list");
|
||||||
|
+ fp = fopen(file_name, "r");
|
||||||
|
+ if (fp == NULL)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ while (fgets(ln, sizeof(ln), fp) != NULL)
|
||||||
|
+ {
|
||||||
|
+ c = strstr(ln, "Clock Event Device: hpet");
|
||||||
|
+ if (!c)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ c += 24;
|
||||||
|
+ if (!isdigit(c[0]))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ hpet_chan = strtol(c, NULL, 10);
|
||||||
|
+ if (hpet_chan < percpu_hpet_start)
|
||||||
|
+ percpu_hpet_start = hpet_chan;
|
||||||
|
+ if (hpet_chan > percpu_hpet_end)
|
||||||
|
+ percpu_hpet_end = hpet_chan;
|
||||||
|
+ }
|
||||||
|
+ fclose(fp);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ c = strstr(name, "hpet");
|
||||||
|
+ if (!c)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ c += 4;
|
||||||
|
+ if (!isdigit(c[0]))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ hpet_chan = strtol(c, NULL, 10);
|
||||||
|
+ if (percpu_hpet_start <= hpet_chan && hpet_chan <= percpu_hpet_end)
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void do_proc_irq(void)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
@@ -253,6 +305,10 @@ static void do_proc_irq(void)
|
||||||
|
else
|
||||||
|
sprintf(line2, _(" <interrupt> : %s"), _("PS/2 keyboard/mouse/touchpad"));
|
||||||
|
|
||||||
|
+ /* skip per CPU timer interrupts */
|
||||||
|
+ if (percpu_hpet_timer(name))
|
||||||
|
+ delta = 0;
|
||||||
|
+
|
||||||
|
if (nr > 0 && delta > 0)
|
||||||
|
push_line(line2, delta);
|
||||||
|
if (nr==0)
|
||||||
|
@@ -729,7 +785,7 @@ void print_battery_sysfs(void)
|
||||||
|
continue;
|
||||||
|
memset(line, 0, 1024);
|
||||||
|
if (fgets(line, 1024, file) != NULL) {
|
||||||
|
- amperes_drawn = strtoull(line, NULL, 10) / 1000000.0;
|
||||||
|
+ watts_drawn = strtoull(line, NULL, 10) / 1000000.0;
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
@@ -764,6 +820,7 @@ void usage()
|
||||||
|
printf(_("Usage: powertop [OPTION...]\n"));
|
||||||
|
printf(_(" -d, --dump read wakeups once and print list of top offenders\n"));
|
||||||
|
printf(_(" -t, --time=DOUBLE default time to gather data in seconds\n"));
|
||||||
|
+ printf(_(" -p, --pids show pids in wakeups list\n"));
|
||||||
|
printf(_(" -h, --help Show this help message\n"));
|
||||||
|
printf(_(" -v, --version Show version information and exit\n"));
|
||||||
|
exit(0);
|
||||||
|
@@ -791,13 +848,14 @@ int main(int argc, char **argv)
|
||||||
|
static struct option opts[] = {
|
||||||
|
{ "dump", 0, NULL, 'd' },
|
||||||
|
{ "time", 1, NULL, 't' },
|
||||||
|
+ { "pids", 0, NULL, 'p' },
|
||||||
|
{ "help", 0, NULL, 'h' },
|
||||||
|
{ "version", 0, NULL, 'v' },
|
||||||
|
{ 0, 0, NULL, 0 }
|
||||||
|
};
|
||||||
|
int index2 = 0, c;
|
||||||
|
|
||||||
|
- c = getopt_long(argc, argv, "dt:hv", opts, &index2);
|
||||||
|
+ c = getopt_long(argc, argv, "dt:phv", opts, &index2);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
switch (c) {
|
||||||
|
@@ -807,6 +865,9 @@ int main(int argc, char **argv)
|
||||||
|
case 't':
|
||||||
|
ticktime = strtod(optarg, NULL);
|
||||||
|
break;
|
||||||
|
+ case 'p':
|
||||||
|
+ showpids = 1;
|
||||||
|
+ break;
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
@@ -858,7 +919,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
|
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
- FD_SET(0, &rfds);
|
||||||
|
+ if (!dump)
|
||||||
|
+ FD_SET(0, &rfds);
|
||||||
|
tv.tv_sec = ticktime;
|
||||||
|
tv.tv_usec = (ticktime - tv.tv_sec) * 1000000;;
|
||||||
|
do_proc_irq();
|
||||||
|
@@ -1129,11 +1191,12 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
|
suggest_bluetooth_off();
|
||||||
|
suggest_nmi_watchdog();
|
||||||
|
- suggest_laptop_mode();
|
||||||
|
if (maxsleep > 15.0)
|
||||||
|
suggest_hpet();
|
||||||
|
suggest_ac97_powersave();
|
||||||
|
+ suggest_hda_powersave();
|
||||||
|
suggest_wireless_powersave();
|
||||||
|
+ suggest_wifi_new_powersave();
|
||||||
|
suggest_ondemand_governor();
|
||||||
|
suggest_noatime();
|
||||||
|
suggest_sata_alpm();
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/powertop.h powertop-svn_r332/powertop.h
|
||||||
|
--- powertop-1.11/powertop.h 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/powertop.h 2010-05-09 18:43:31.540889201 +0200
|
||||||
|
@@ -28,6 +28,8 @@
|
||||||
|
|
||||||
|
#include <libintl.h>
|
||||||
|
|
||||||
|
+#define VERSION "1.12"
|
||||||
|
+
|
||||||
|
struct line {
|
||||||
|
char *string;
|
||||||
|
int count;
|
||||||
|
@@ -45,12 +47,13 @@ extern double displaytime;
|
||||||
|
|
||||||
|
void suggest_process_death(char *process_match, char *process_name, struct line *slines, int linecount, double minwakeups, char *comment, int weight);
|
||||||
|
void suggest_kernel_config(char *string, int onoff, char *comment, int weight);
|
||||||
|
-void suggest_laptop_mode(void);
|
||||||
|
void suggest_bluetooth_off(void);
|
||||||
|
void suggest_nmi_watchdog(void);
|
||||||
|
void suggest_hpet(void);
|
||||||
|
void suggest_ac97_powersave(void);
|
||||||
|
+void suggest_hda_powersave(void);
|
||||||
|
void suggest_wireless_powersave(void);
|
||||||
|
+void suggest_wifi_new_powersave(void);
|
||||||
|
void suggest_ondemand_governor(void);
|
||||||
|
void suggest_noatime(void);
|
||||||
|
void suggest_sata_alpm(void);
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/urbnum.c powertop-svn_r332/urbnum.c
|
||||||
|
--- powertop-1.11/urbnum.c 2010-05-09 18:53:18.774894553 +0200
|
||||||
|
+++ powertop-svn_r332/urbnum.c 2010-05-09 18:43:31.536893016 +0200
|
||||||
|
@@ -136,6 +136,8 @@ void count_usb_urbs(void)
|
||||||
|
char pathname[PATH_MAX];
|
||||||
|
char buffer[4096];
|
||||||
|
struct device_data *dev;
|
||||||
|
+ int len;
|
||||||
|
+ char linkto[PATH_MAX];
|
||||||
|
|
||||||
|
dir = opendir("/sys/bus/usb/devices");
|
||||||
|
if (!dir)
|
||||||
|
@@ -145,11 +147,19 @@ void count_usb_urbs(void)
|
||||||
|
while ((dirent = readdir(dir))) {
|
||||||
|
if (dirent->d_name[0]=='.')
|
||||||
|
continue;
|
||||||
|
+
|
||||||
|
+ /* skip usb input devices */
|
||||||
|
+ sprintf(filename, "/sys/bus/usb/devices/%s/driver", dirent->d_name);
|
||||||
|
+ len = readlink(filename, linkto, sizeof(link) - 1);
|
||||||
|
+ if (strstr(linkto, "usbhid"))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
sprintf(pathname, "/sys/bus/usb/devices/%s", dirent->d_name);
|
||||||
|
sprintf(filename, "%s/urbnum", pathname);
|
||||||
|
file = fopen(filename, "r");
|
||||||
|
if (!file)
|
||||||
|
continue;
|
||||||
|
+
|
||||||
|
memset(buffer, 0, 4096);
|
||||||
|
fgets(buffer, 4095, file);
|
||||||
|
update_urbnum(pathname, strtoull(buffer, NULL, 10), dirent->d_name);
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/usb.c powertop-svn_r332/usb.c
|
||||||
|
--- powertop-1.11/usb.c 2010-05-09 18:53:18.775917957 +0200
|
||||||
|
+++ powertop-svn_r332/usb.c 2010-05-09 18:43:31.542889143 +0200
|
||||||
|
@@ -38,6 +38,8 @@ void activate_usb_autosuspend(void)
|
||||||
|
struct dirent *dirent;
|
||||||
|
FILE *file;
|
||||||
|
char filename[PATH_MAX];
|
||||||
|
+ int len;
|
||||||
|
+ char linkto[PATH_MAX];
|
||||||
|
|
||||||
|
dir = opendir("/sys/bus/usb/devices");
|
||||||
|
if (!dir)
|
||||||
|
@@ -46,12 +48,13 @@ void activate_usb_autosuspend(void)
|
||||||
|
while ((dirent = readdir(dir))) {
|
||||||
|
if (dirent->d_name[0]=='.')
|
||||||
|
continue;
|
||||||
|
- sprintf(filename, "/sys/bus/usb/devices/%s/power/autosuspend", dirent->d_name);
|
||||||
|
- file = fopen(filename, "w");
|
||||||
|
- if (!file)
|
||||||
|
+
|
||||||
|
+ /* skip usb input devices */
|
||||||
|
+ sprintf(filename, "/sys/bus/usb/devices/%s/driver", dirent->d_name);
|
||||||
|
+ len = readlink(filename, linkto, sizeof(link) - 1);
|
||||||
|
+ if (strstr(linkto, "usbhid"))
|
||||||
|
continue;
|
||||||
|
- fprintf(file, "0\n");
|
||||||
|
- fclose(file);
|
||||||
|
+
|
||||||
|
sprintf(filename, "/sys/bus/usb/devices/%s/power/level", dirent->d_name);
|
||||||
|
file = fopen(filename, "w");
|
||||||
|
if (!file)
|
||||||
|
@@ -70,8 +73,9 @@ void suggest_usb_autosuspend(void)
|
||||||
|
FILE *file;
|
||||||
|
char filename[PATH_MAX];
|
||||||
|
char line[1024];
|
||||||
|
- int need_hint = 0;
|
||||||
|
-
|
||||||
|
+ int len;
|
||||||
|
+ char linkto[PATH_MAX];
|
||||||
|
+ int need_hint = 0;
|
||||||
|
|
||||||
|
dir = opendir("/sys/bus/usb/devices");
|
||||||
|
if (!dir)
|
||||||
|
@@ -80,20 +84,12 @@ void suggest_usb_autosuspend(void)
|
||||||
|
while ((dirent = readdir(dir))) {
|
||||||
|
if (dirent->d_name[0]=='.')
|
||||||
|
continue;
|
||||||
|
- sprintf(filename, "/sys/bus/usb/devices/%s/power/autosuspend", dirent->d_name);
|
||||||
|
- file = fopen(filename, "r");
|
||||||
|
- if (!file)
|
||||||
|
- continue;
|
||||||
|
- memset(line, 0, 1024);
|
||||||
|
- if (fgets(line, 1023,file)==NULL) {
|
||||||
|
- fclose(file);
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- if (strtoll(line, NULL,10)<0)
|
||||||
|
- need_hint = 1;
|
||||||
|
-
|
||||||
|
- fclose(file);
|
||||||
|
|
||||||
|
+ /* skip usb input devices */
|
||||||
|
+ sprintf(filename, "/sys/bus/usb/devices/%s/driver", dirent->d_name);
|
||||||
|
+ len = readlink(filename, linkto, sizeof(link) - 1);
|
||||||
|
+ if (strstr(linkto, "usbhid"))
|
||||||
|
+ continue;
|
||||||
|
|
||||||
|
sprintf(filename, "/sys/bus/usb/devices/%s/power/level", dirent->d_name);
|
||||||
|
file = fopen(filename, "r");
|
||||||
|
@@ -115,8 +111,7 @@ void suggest_usb_autosuspend(void)
|
||||||
|
closedir(dir);
|
||||||
|
|
||||||
|
if (need_hint) {
|
||||||
|
- add_suggestion(_("Suggestion: Enable USB autosuspend by pressing the U key or adding \n"
|
||||||
|
- "usbcore.autosuspend=1 to the kernel command line in the grub config"
|
||||||
|
+ add_suggestion(_("Suggestion: Enable USB autosuspend for non-input devices by pressing the U key\n"
|
||||||
|
),
|
||||||
|
45, 'U', _(" U - Enable USB suspend "), activate_usb_autosuspend);
|
||||||
|
}
|
||||||
|
diff -rupN '--exclude=patches' '--exclude=.pc' '--exclude=.svn' powertop-1.11/wifi-new.c powertop-svn_r332/wifi-new.c
|
||||||
|
--- powertop-1.11/wifi-new.c 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ powertop-svn_r332/wifi-new.c 2010-05-09 18:43:31.540889201 +0200
|
||||||
|
@@ -0,0 +1,203 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright 2007, Intel Corporation
|
||||||
|
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
|
||||||
|
+ *
|
||||||
|
+ * This file is part of PowerTOP
|
||||||
|
+ *
|
||||||
|
+ * This program file is free software; you can redistribute it and/or modify it
|
||||||
|
+ * under the terms of the GNU General Public License as published by the
|
||||||
|
+ * Free Software Foundation; version 2 of the License.
|
||||||
|
+ *
|
||||||
|
+ * This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
+ * for more details.
|
||||||
|
+ *
|
||||||
|
+ * You should have received a copy of the GNU General Public License
|
||||||
|
+ * along with this program in a file named COPYING; if not, write to the
|
||||||
|
+ * Free Software Foundation, Inc.,
|
||||||
|
+ * 51 Franklin Street, Fifth Floor,
|
||||||
|
+ * Boston, MA 02110-1301 USA
|
||||||
|
+ *
|
||||||
|
+ * Authors:
|
||||||
|
+ * Arjan van de Ven <arjan@linux.intel.com>
|
||||||
|
+ * Johannes Berg <johannes@sipsolutions.net>
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <unistd.h>
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <stdbool.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdint.h>
|
||||||
|
+#include <sys/types.h>
|
||||||
|
+#include <dirent.h>
|
||||||
|
+#include <linux/types.h>
|
||||||
|
+#include <linux/sockios.h>
|
||||||
|
+#include <sys/ioctl.h>
|
||||||
|
+/* satisfy weird wireless.h include dependencies */
|
||||||
|
+#include <sys/socket.h>
|
||||||
|
+#include <linux/if.h>
|
||||||
|
+#include <linux/wireless.h>
|
||||||
|
+
|
||||||
|
+#include "powertop.h"
|
||||||
|
+
|
||||||
|
+static int wext_sock = -1;
|
||||||
|
+static char wireless_nic[IFNAMSIZ + 1] = {0};
|
||||||
|
+static bool ps_not_working = false;
|
||||||
|
+
|
||||||
|
+static bool check_wireless_unused(void)
|
||||||
|
+{
|
||||||
|
+ struct iwreq wrq;
|
||||||
|
+ char ssid[34] = {0}; /* wext sometimes NUL-terminates */
|
||||||
|
+
|
||||||
|
+ memset(&wrq, 0, sizeof(wrq));
|
||||||
|
+ strncpy(wrq.ifr_name, wireless_nic, sizeof(wrq.ifr_name));
|
||||||
|
+
|
||||||
|
+ /* get mode -- PS only available in STA mode */
|
||||||
|
+ if (ioctl(wext_sock, SIOCGIWMODE, &wrq) < 0)
|
||||||
|
+ return false;
|
||||||
|
+ if (wrq.u.mode != IW_MODE_INFRA)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ wrq.u.essid.pointer = ssid;
|
||||||
|
+ wrq.u.essid.length = sizeof(ssid);
|
||||||
|
+ if (ioctl(wext_sock, SIOCGIWESSID, &wrq) < 0)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ /* no SSID, so can't be connected */
|
||||||
|
+ if (!wrq.u.essid.flags)
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ if (ioctl(wext_sock, SIOCGIWAP, &wrq) < 0)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ /* no AP -- not connected */
|
||||||
|
+ if (memcmp(wrq.u.ap_addr.sa_data, "\0\0\0\0\0\0", 6) == 0)
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void activate_down_suggestion(void)
|
||||||
|
+{
|
||||||
|
+ struct ifreq ifr;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ strncpy(ifr.ifr_name, wireless_nic, sizeof(ifr.ifr_name));
|
||||||
|
+
|
||||||
|
+ /* get flags */
|
||||||
|
+ ret = ioctl(wext_sock, SIOCGIFFLAGS, &ifr);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return;
|
||||||
|
+ ifr.ifr_flags &= ~IFF_UP;
|
||||||
|
+
|
||||||
|
+ ioctl(wext_sock, SIOCSIFFLAGS, &ifr);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int check_wireless_powersave(void)
|
||||||
|
+{
|
||||||
|
+ struct iwreq wrq;
|
||||||
|
+
|
||||||
|
+ if (ps_not_working)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ memset(&wrq, 0, sizeof(wrq));
|
||||||
|
+ strncpy(wrq.ifr_name, wireless_nic, sizeof(wrq.ifr_name));
|
||||||
|
+
|
||||||
|
+ /* get powersave -- if supported */
|
||||||
|
+ if (ioctl(wext_sock, SIOCGIWPOWER, &wrq) < 0)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ return wrq.u.param.disabled;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void activate_wireless_suggestion(void)
|
||||||
|
+{
|
||||||
|
+ struct iwreq wrq;
|
||||||
|
+
|
||||||
|
+ memset(&wrq, 0, sizeof(wrq));
|
||||||
|
+ strncpy(wrq.ifr_name, wireless_nic, sizeof(wrq.ifr_name));
|
||||||
|
+
|
||||||
|
+ wrq.u.param.disabled = false;
|
||||||
|
+ wrq.u.param.flags = IW_POWER_ON | IW_POWER_TIMEOUT;
|
||||||
|
+ wrq.u.param.value = 500*1000; /* 500 ms */
|
||||||
|
+ again:
|
||||||
|
+ /* set powersave -- if supported */
|
||||||
|
+ if (ioctl(wext_sock, SIOCSIWPOWER, &wrq) == 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ /* maybe timeout is not supported? */
|
||||||
|
+ if (wrq.u.param.flags & IW_POWER_TIMEOUT) {
|
||||||
|
+ wrq.u.param.flags = IW_POWER_ON;
|
||||||
|
+ goto again;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ps_not_working = true;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void find_wireless_nic(void)
|
||||||
|
+{
|
||||||
|
+ DIR *net;
|
||||||
|
+ struct dirent *ent;
|
||||||
|
+ struct ifreq ifr;
|
||||||
|
+ struct iwreq wrq;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ memset(&ifr, 0, sizeof(struct ifreq));
|
||||||
|
+ memset(&wrq, 0, sizeof(wrq));
|
||||||
|
+
|
||||||
|
+ net = opendir("/sys/class/net/");
|
||||||
|
+ if (!net)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ while ((ent = readdir(net))) {
|
||||||
|
+ strncpy(ifr.ifr_name, ent->d_name, sizeof(ifr.ifr_name));
|
||||||
|
+ strncpy(wrq.ifr_name, ent->d_name, sizeof(wrq.ifr_name));
|
||||||
|
+
|
||||||
|
+ /* Check if the interface is up */
|
||||||
|
+ ret = ioctl(wext_sock, SIOCGIFFLAGS, &ifr);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ continue;
|
||||||
|
+ if (!(ifr.ifr_flags & (IFF_UP | IFF_RUNNING)))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ /* and a wireless interface (that we handle) */
|
||||||
|
+ ret = ioctl(wext_sock, SIOCGIWNAME, &wrq);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ strcpy(wireless_nic, "wlan0");
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ closedir(net);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void suggest_wifi_new_powersave(void)
|
||||||
|
+{
|
||||||
|
+ char sug[1024];
|
||||||
|
+
|
||||||
|
+ if (wext_sock == -1) {
|
||||||
|
+ wext_sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
+ if (wext_sock < 0)
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (strlen(wireless_nic) == 0)
|
||||||
|
+ find_wireless_nic();
|
||||||
|
+
|
||||||
|
+ if (strlen(wireless_nic) == 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ if (check_wireless_unused()) {
|
||||||
|
+ sprintf(sug, _("Suggestion: Disable the unused WIFI radio by setting the interface down:\n "
|
||||||
|
+ "ifconfig %s down\n"), wireless_nic);
|
||||||
|
+ add_suggestion(sug, 60, 'D', _(" D - disable wireless "), activate_down_suggestion);
|
||||||
|
+ } else if (check_wireless_powersave()) {
|
||||||
|
+ sprintf(sug, _("Suggestion: Enable wireless power saving mode by executing the following command:\n "
|
||||||
|
+ " iwconfig %s power timeout 500ms\n"
|
||||||
|
+ "This will sacrifice network performance slightly to save power."), wireless_nic);
|
||||||
|
+ add_suggestion(sug, 20, 'P', _(" P - Enable wireless power saving "), activate_wireless_suggestion);
|
||||||
|
+ }
|
||||||
|
+}
|
@ -1,3 +1,16 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sun May 9 16:59:41 UTC 2010 - seife@opensuse.org
|
||||||
|
|
||||||
|
- update to SVN rev 332:
|
||||||
|
* fix wifi code for current kernels
|
||||||
|
* show turbo mode explicitly
|
||||||
|
* filter out percpu hpet timer wakeup events
|
||||||
|
* ignore usb input devices, do not set/read suspend delay
|
||||||
|
* add --pids command-line option
|
||||||
|
* add HD audio power save suggestion
|
||||||
|
* removed obsolete laptop_mode suggestion
|
||||||
|
* updated manpage
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Feb 9 01:18:56 CET 2010 - ro@suse.de
|
Tue Feb 9 01:18:56 CET 2010 - ro@suse.de
|
||||||
|
|
||||||
|
@ -21,11 +21,12 @@ Name: powertop
|
|||||||
Url: http://www.linuxpowertop.org
|
Url: http://www.linuxpowertop.org
|
||||||
Summary: PowerTOP is a Linux Tool to Find out What is Using Power on a Laptop
|
Summary: PowerTOP is a Linux Tool to Find out What is Using Power on a Laptop
|
||||||
Version: 1.11
|
Version: 1.11
|
||||||
Release: 2
|
Release: 3
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: System/Monitoring
|
Group: System/Monitoring
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
Patch0: powertop-segfault.diff
|
Patch0: powertop-segfault.diff
|
||||||
|
Patch1: powertop-1.11-svn_r332.diff
|
||||||
BuildRequires: ncurses-devel
|
BuildRequires: ncurses-devel
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
AutoReqProv: on
|
AutoReqProv: on
|
||||||
@ -44,6 +45,7 @@ Authors:
|
|||||||
%prep
|
%prep
|
||||||
%setup
|
%setup
|
||||||
%patch0
|
%patch0
|
||||||
|
%patch1 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make CFLAGS="$RPM_OPT_FLAGS"
|
make CFLAGS="$RPM_OPT_FLAGS"
|
||||||
@ -60,6 +62,6 @@ rm -rf %{_buildroot}
|
|||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%doc COPYING
|
%doc COPYING
|
||||||
%{_bindir}/%{name}
|
%{_bindir}/%{name}
|
||||||
%{_mandir}/man*/%{name}.1.gz
|
%{_mandir}/man*/%{name}.8.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
Loading…
Reference in New Issue
Block a user