diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2010-12-23 15:18:30 -0800 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2010-12-23 15:18:30 -0800 |
commit | 49b51ce1787084bf55409a731ac6b9b9f6f38ad0 (patch) | |
tree | 4734163aabaf52f833f016cf21f2211c362b3ec5 | |
parent | 0352650628172031a9f575d3010af29098e2031e (diff) | |
download | powertop-49b51ce1787084bf55409a731ac6b9b9f6f38ad0.tar.gz |
add powerunsave also to the wifi power estimate for a better modelv1.95
get ready for the alpha release
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | calibrate/calibrate.cpp | 10 | ||||
-rw-r--r-- | devices/network.cpp | 21 | ||||
-rw-r--r-- | devices/network.h | 3 | ||||
-rw-r--r-- | tuning/iw.c | 4 | ||||
-rw-r--r-- | tuning/iw.h | 4 |
6 files changed, 45 insertions, 5 deletions
@@ -1,5 +1,7 @@ all: powertop +VERSION := 1.95 + CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer CXXFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat @@ -87,3 +89,9 @@ css.h: csstoh powertop.css uptrans: @(cd po/ && env LG=$(LG) $(MAKE) $@) + + +dist: + git tag v$(VERSION) + git archive --format=tar --prefix="powertop-$(VERSION)/" v$(VERSION) | \ + gzip > powertop-$(VERSION).tar.gz diff --git a/calibrate/calibrate.cpp b/calibrate/calibrate.cpp index 0a04626..9acff67 100644 --- a/calibrate/calibrate.cpp +++ b/calibrate/calibrate.cpp @@ -36,6 +36,9 @@ #include <dirent.h> #include "../parameters/parameters.h" +extern "C" { +#include "../tuning/iw.h" +} #include <map> #include <vector> @@ -55,6 +58,8 @@ static map<string, string> saved_sysfs; static volatile int stop_measurement; +static int wireless_PS; + static void save_sysfs(const char *filename) { @@ -76,6 +81,8 @@ static void restore_all_sysfs(void) for (it = saved_sysfs.begin(); it != saved_sysfs.end(); it++) write_sysfs(it->first, it->second); + + set_wifi_power_saving("wlan0", wireless_PS); } static void find_all_usb(void) @@ -443,6 +450,7 @@ void calibrate(void) find_all_rfkill(); find_backlight(); find_scsi_link(); + wireless_PS = get_wifi_power_saving("wlan0"); save_sysfs("/sys/modules/snd_hda_intel/parameters/power_save"); @@ -450,6 +458,7 @@ void calibrate(void) suspend_all_usb_devices(); rfkill_all_radios(); lower_backlight(); + set_wifi_power_saving("wlan0", 1); sleep(4); @@ -464,6 +473,7 @@ void calibrate(void) wakeup_calibration(10000); wakeup_calibration(100000); wakeup_calibration(1000000); + set_wifi_power_saving("wlan0", 0); usb_calibration(); rfkill_calibration(); diff --git a/devices/network.cpp b/devices/network.cpp index 32e5f08..812408f 100644 --- a/devices/network.cpp +++ b/devices/network.cpp @@ -42,6 +42,9 @@ using namespace std; #include "network.h" #include "../parameters/parameters.h" #include "../process/process.h" +extern "C" { +#include "../tuning/iw.h" +} #include <string.h> #include <net/if.h> @@ -119,6 +122,7 @@ network::network(char *_name, char *path) valid_100 = -1; valid_1000 = -1; valid_high = -1; + valid_powerunsave = -1; strncpy(sysfs_path, path, sizeof(sysfs_path)); sprintf(devname, "%s", _name); @@ -129,6 +133,10 @@ network::network(char *_name, char *path) index_up = get_param_index(devname); rindex_up = get_result_index(devname); + sprintf(devname, "%s-powerunsave", _name); + index_powerunsave = get_param_index(devname); + rindex_powerunsave = get_result_index(devname); + sprintf(devname, "%s-link-100", _name); index_link_100 = get_param_index(devname); rindex_link_100 = get_result_index(devname); @@ -264,7 +272,7 @@ void network::start_measurement(void) void network::end_measurement(void) { - int u_100, u_1000, u_high; + int u_100, u_1000, u_high, u_powerunsave; gettimeofday(&after, NULL); @@ -295,11 +303,14 @@ void network::end_measurement(void) if (start_pkts > end_pkts) end_pkts = start_pkts; + u_powerunsave = 100 - 100 * get_wifi_power_saving(name); + report_utilization(rindex_link_100, u_100); report_utilization(rindex_link_1000, u_1000); report_utilization(rindex_link_high, u_high); report_utilization(rindex_up, (start_up+end_up) / 2.0); report_utilization(rindex_pkts, (end_pkts - start_pkts)/(duration + 0.001)); + report_utilization(rindex_powerunsave, u_powerunsave); } @@ -356,10 +367,12 @@ double network::power_usage(struct result_bundle *result, struct parameter_bundl power += util * factor; + if (valid_100 == -1) { valid_100 = utilization_power_valid(rindex_link_100); valid_1000 = utilization_power_valid(rindex_link_1000); valid_high = utilization_power_valid(rindex_link_high); + valid_powerunsave = utilization_power_valid(rindex_powerunsave); } if (valid_100 > 0) { @@ -381,6 +394,12 @@ double network::power_usage(struct result_bundle *result, struct parameter_bundl power += util * factor / 100; } + if (valid_powerunsave > 0) { + factor = get_parameter_value(index_powerunsave, bundle); + util = get_result_value(rindex_powerunsave, result); + power += util * factor / 100; + } + factor = get_parameter_value(index_pkts, bundle); util = get_result_value(rindex_pkts, result); if (util > 5000) diff --git a/devices/network.h b/devices/network.h index d4701b5..8f94df4 100644 --- a/devices/network.h +++ b/devices/network.h @@ -51,10 +51,13 @@ class network: public device { int rindex_link_high; int index_pkts; int rindex_pkts; + int index_powerunsave; + int rindex_powerunsave; int valid_100; int valid_1000; int valid_high; + int valid_powerunsave; public: uint64_t pkts; double duration; diff --git a/tuning/iw.c b/tuning/iw.c index 62814b0..d49b5fc 100644 --- a/tuning/iw.c +++ b/tuning/iw.c @@ -264,7 +264,7 @@ static int __handle_cmd(struct nl80211_state *state, const char *iface, int get) } -int set_wifi_power_saving(char *iface, int state) +int set_wifi_power_saving(const char *iface, int state) { struct nl80211_state nlstate; int err; @@ -282,7 +282,7 @@ int set_wifi_power_saving(char *iface, int state) } -int get_wifi_power_saving(char *iface) +int get_wifi_power_saving(const char *iface) { struct nl80211_state nlstate; int err; diff --git a/tuning/iw.h b/tuning/iw.h index 70430dc..ea2b660 100644 --- a/tuning/iw.h +++ b/tuning/iw.h @@ -66,8 +66,8 @@ enum id_input { II_PHY_IDX, }; -int get_wifi_power_saving(char *iface); -int set_wifi_power_saving(char *iface, int state); +int get_wifi_power_saving(const char *iface); +int set_wifi_power_saving(const char *iface, int state); #endif /* __IW_H */ |