Confirmed users
507
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Adding ''oprofile'' to CyanogenMod 7 = | = oprofile = | ||
== Adding ''oprofile'' to CyanogenMod 7 == | |||
CyanogenMod 7 is used here, but these steps will probably work similarly for other ROMs. | CyanogenMod 7 is used here, but these steps will probably work similarly for other ROMs. | ||
Line 10: | Line 12: | ||
* oprofile profiles happily there after | * oprofile profiles happily there after | ||
== Recompile kernel with oprofile == | === Recompile kernel with oprofile === | ||
Root and flash a standard CyanogenMod 7 ROM. Make sure the ROM runs. | Root and flash a standard CyanogenMod 7 ROM. Make sure the ROM runs. | ||
Line 65: | Line 67: | ||
After the smoke settles, the kernel should be at arch/arm/boot/zImage | After the smoke settles, the kernel should be at arch/arm/boot/zImage | ||
== Flash kernel to phone == | === Flash kernel to phone === | ||
Extract a copy of of boot.img from the CyanogenMod zip used to flash the phone: | Extract a copy of of boot.img from the CyanogenMod zip used to flash the phone: | ||
Line 111: | Line 113: | ||
adb shell mount -o remount,ro /system | adb shell mount -o remount,ro /system | ||
== Patch and build opcontrol == | === Patch and build opcontrol === | ||
There's a prebuilt opcontrol here [http://people.mozilla.com/~alexp/android/oprofile/opcontrol-oprofiled.zip], otherwise: | There's a prebuilt opcontrol here [http://people.mozilla.com/~alexp/android/oprofile/opcontrol-oprofiled.zip], otherwise: | ||
Line 119: | Line 121: | ||
Before you start building, you want to edit external/oprofile/opcontrol/opcontrol.cpp and find calls to mkdir and add a 0 in front of the permissions. | Before you start building, you want to edit external/oprofile/opcontrol/opcontrol.cpp and find calls to mkdir and add a 0 in front of the permissions. | ||
== Set up oprofile == | === Set up oprofile === | ||
adb shell mount -o remount,rw /system | adb shell mount -o remount,rw /system | ||
Line 146: | Line 148: | ||
The sample rate is (CPU freuqency in MHz) / (CPU_CYCLES count) / 64. For the HTC G2, it's 800MHz / 100000 / 64 = 125 samples per second. | The sample rate is (CPU freuqency in MHz) / (CPU_CYCLES count) / 64. For the HTC G2, it's 800MHz / 100000 / 64 = 125 samples per second. | ||
= Using ''oprofile'' on CyanogenMod 7 = | == Using ''oprofile'' on CyanogenMod 7 == | ||
adb shell opsetup > /dev/null 2>&1 & # start up oprofile | adb shell opsetup > /dev/null 2>&1 & # start up oprofile | ||
Line 173: | Line 175: | ||
opreport --session-dir=oprofile -l -t 1 -p ~+/oplibs 2>/dev/null | opreport --session-dir=oprofile -l -t 1 -p ~+/oplibs 2>/dev/null | ||
= Custom kernel for Nexus One = | == Custom kernel for Nexus One == | ||
== Background information == | === Background information === | ||
''oprofile'' is disabled in Nexus One kernel, so the kernel needs to be rebuilt to include it. These links have instructions on how to build a custom kernel:<br> | ''oprofile'' is disabled in Nexus One kernel, so the kernel needs to be rebuilt to include it. These links have instructions on how to build a custom kernel:<br> | ||
Line 189: | Line 191: | ||
CONFIG_HAVE_OPROFILE=y | CONFIG_HAVE_OPROFILE=y | ||
== Nexus One specifics == | === Nexus One specifics === | ||
''oprofile'' code included in the kernel needs to be fixed to work on Nexus One. The known fixes are for kernel version 2.6.32, branch "2.6.32-nexusonec". They are mentioned in the following posts:<br> | ''oprofile'' code included in the kernel needs to be fixed to work on Nexus One. The known fixes are for kernel version 2.6.32, branch "2.6.32-nexusonec". They are mentioned in the following posts:<br> | ||
Line 241: | Line 243: | ||
The patches above are still compatible with this branch, though enabling ''oprofile'' in this version of kernel has to be done carefully, as it's very easy to make the kernel unbootable. | The patches above are still compatible with this branch, though enabling ''oprofile'' in this version of kernel has to be done carefully, as it's very easy to make the kernel unbootable. | ||
== Prerequisites == | === Prerequisites === | ||
* Linux (the steps below were used on Ubuntu 10.04) | * Linux (the steps below were used on Ubuntu 10.04) | ||
Line 249: | Line 251: | ||
You can find information on how to unlock and root your device [http://wiki.cyanogenmod.com/index.php?title=Nexus_One here] and on Google. | You can find information on how to unlock and root your device [http://wiki.cyanogenmod.com/index.php?title=Nexus_One here] and on Google. | ||
== How to build a kernel with working ''oprofile'' for Nexus One == | === How to build a kernel with working ''oprofile'' for Nexus One === | ||
''(These steps are based on the links mentioned above)'' | ''(These steps are based on the links mentioned above)'' | ||
Line 322: | Line 324: | ||
Congratulations! You've got a working system with ''oprofile''! | Congratulations! You've got a working system with ''oprofile''! | ||
== Ready to use ROM with ''oprofile'' == | === Ready to use ROM with ''oprofile'' === | ||
Due to the legal issues, the ROM is not available publicly. If you have Intranet access, you can find it [https://intranet.mozilla.org/Mobile/Android_Profiling#Ready_to_use_ROM_with_oprofile here]. | Due to the legal issues, the ROM is not available publicly. If you have Intranet access, you can find it [https://intranet.mozilla.org/Mobile/Android_Profiling#Ready_to_use_ROM_with_oprofile here]. | ||
= Adding ''oprofile'' to CyanogenMod ROM for Nexus One = | == Adding ''oprofile'' to CyanogenMod ROM for Nexus One == | ||
<span style="color:red">'''Note: Currently it doesn't seem possible to use CyanogenMod ROMs, as they are based on the newer kernels, where oprofile code was changed, so the Nexus One specific patches cannot be applied "as is". But this approach could be still used if the solution could be found to that.'''</span> | <span style="color:red">'''Note: Currently it doesn't seem possible to use CyanogenMod ROMs, as they are based on the newer kernels, where oprofile code was changed, so the Nexus One specific patches cannot be applied "as is". But this approach could be still used if the solution could be found to that.'''</span> | ||
Line 348: | Line 350: | ||
out/target/product/passion/obj/kernel/.config) | out/target/product/passion/obj/kernel/.config) | ||
==Issues== | === Issues === | ||
The main issue currently is that though the initial setup with "opcontrol --setup" seems to succeed, the oprofile counter configuration fails: | The main issue currently is that though the initial setup with "opcontrol --setup" seems to succeed, the oprofile counter configuration fails: | ||
Line 366: | Line 368: | ||
=Using ''oprofile''= | == Using ''oprofile'' == | ||
After the new ROM is flashed to the device, oprofile can be controlled with opcontrol. | After the new ROM is flashed to the device, oprofile can be controlled with opcontrol. | ||
Line 373: | Line 375: | ||
Some Android-specific instructions can be found here:<br> | Some Android-specific instructions can be found here:<br> | ||
http://www.omappedia.org/wiki/Android_Debugging#OProfile_on_OMAP3 <br> | http://www.omappedia.org/wiki/Android_Debugging#OProfile_on_OMAP3 <br> | ||
= PowerTOP = | |||
== Compiling PowerTOP == | |||
Using NDK5, make a cross-compiling toolchain: | |||
cd /PATH/TO/NDK | |||
build/tools/make-standalone-toolchain.sh --platform=android-5 --install-dir=../ndk5-toolchain | |||
export PATH=$PATH:~+/ndk5-toolchain/bin | |||
Download and extract the latest version of ncurses (5.9 here) and PowerTOP (1.13 here): | |||
cd ~ | |||
wget http://www.lesswatts.org/projects/powertop/download/powertop-1.13.tar.gz | |||
tar -xzf powertop-1.13.tar.gz | |||
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz | |||
tar -xzf ncurses-5.9.tar.gz | |||
Patch ncurses using this patch: | |||
diff --git a/ncurses-5.9/configure b/ncurses-5.9/configure | |||
index 639b790..d8b8c53 100755 | |||
--- a/ncurses-5.9/configure | |||
+++ b/Downloads/ncurses-5.9/configure | |||
@@ -13370,17 +13370,16 @@ EOF | |||
EOF | |||
;; | |||
esac | |||
for ac_header in \ | |||
fcntl.h \ | |||
getopt.h \ | |||
limits.h \ | |||
-locale.h \ | |||
math.h \ | |||
poll.h \ | |||
sys/bsdtypes.h \ | |||
sys/ioctl.h \ | |||
sys/param.h \ | |||
sys/poll.h \ | |||
sys/select.h \ | |||
sys/time.h \ | |||
Patch PowerTOP using this patch: | |||
diff --git a/powertop-1.13/Makefile b/powertop-1.13/Makefile | |||
index fe3bc94..c327105 100644 | |||
--- a/powertop-1.13/Makefile | |||
+++ b/powertop-1.13/Makefile | |||
@@ -13,23 +13,23 @@ CFLAGS+=-D VERSION=\"$(VERSION)\" | |||
# The w in -lncursesw is not a typo; it is the wide-character version | |||
# of the ncurses library, needed for multi-byte character languages | |||
# such as Japanese and Chinese etc. | |||
# | |||
# On Debian/Ubuntu distros, this can be found in the | |||
# libncursesw5-dev package. | |||
# | |||
-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 wifi-new.o perf.o \ | |||
+OBJS = powertop.o config.o process.o misctips.o bluetooth.o display.o suggestions.o cpufreq.o \ | |||
+ sata.o xrandr.o cpufreqstats.o usb.o urbnum.o intelcstates.o wifi-new.o \ | |||
alsa-power.o ahci-alpm.o dmesg.o devicepm.o | |||
powertop: $(OBJS) Makefile powertop.h | |||
- $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -lncursesw -o powertop | |||
+ $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -lncurses -o powertop | |||
@(cd po/ && $(MAKE)) | |||
powertop.8.gz: powertop.8 | |||
gzip -c $< > $@ | |||
install: powertop powertop.8.gz | |||
mkdir -p ${DESTDIR}${BINDIR} | |||
cp powertop ${DESTDIR}${BINDIR} | |||
diff --git a/powertop-1.13/powertop.c b/powertop-1.13/powertop.c | |||
index 74eb328..6370e0d 100644 | |||
--- a/powertop-1.13/powertop.c | |||
+++ b/powertop-1.13/powertop.c | |||
@@ -25,17 +25,16 @@ | |||
#include <getopt.h> | |||
#include <unistd.h> | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#include <stdint.h> | |||
#include <sys/types.h> | |||
#include <dirent.h> | |||
-#include <libintl.h> | |||
#include <ctype.h> | |||
#include <assert.h> | |||
#include <locale.h> | |||
#include <time.h> | |||
#include <limits.h> | |||
#include <sys/stat.h> | |||
#include "powertop.h" | |||
@@ -846,22 +845,16 @@ void version() | |||
int main(int argc, char **argv) | |||
{ | |||
char line[1024]; | |||
int ncursesinited=0; | |||
FILE *file = NULL; | |||
uint64_t cur_usage[8], cur_duration[8]; | |||
double wakeups_per_second = 0; | |||
- setlocale (LC_ALL, ""); | |||
- bindtextdomain ("powertop", "/usr/share/locale"); | |||
- textdomain ("powertop"); | |||
- | |||
- start_data_dirty_capture(); | |||
- | |||
while (1) { | |||
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 } | |||
@@ -1089,18 +1082,16 @@ int main(int argc, char **argv) | |||
push_line_pid(line2, cnt, 0, pid); | |||
} | |||
if (file) | |||
pclose(file); | |||
reset_suggestions(); | |||
- parse_data_dirty_buffer(); | |||
- | |||
if (strstr(line, "total events")) { | |||
int d; | |||
d = strtoull(line, NULL, 10) / sysconf(_SC_NPROCESSORS_ONLN); | |||
if (totalevents == 0) { /* No c-state info available, use timerstats instead */ | |||
totalevents = d * sysconf(_SC_NPROCESSORS_ONLN) + total_interrupt; | |||
if (d < interrupt_0) | |||
totalevents += interrupt_0 - d; | |||
} | |||
@@ -1243,24 +1234,22 @@ int main(int argc, char **argv) | |||
10); | |||
suggest_bluetooth_off(); | |||
suggest_nmi_watchdog(); | |||
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(); | |||
suggest_powersched(); | |||
suggest_xrandr_TV_off(); | |||
- suggest_WOL_off(); | |||
suggest_writeback_time(); | |||
suggest_usb_autosuspend(); | |||
suggest_runtime_suspend(); | |||
usb_activity_hint(); | |||
void devicepm_activity_hint(); | |||
alsa_activity_hint(); | |||
ahci_activity_hint(); | |||
diff --git a/powertop-1.13/powertop.h b/powertop-1.13/powertop.h | |||
index d8f8182..3b5f4e7 100644 | |||
--- a/powertop-1.13/powertop.h | |||
+++ b/powertop-1.13/powertop.h | |||
@@ -21,18 +21,16 @@ | |||
* Authors: | |||
* Arjan van de Ven <arjan@linux.intel.com> | |||
*/ | |||
#ifndef __INCLUDE_GUARD_POWERTOP_H_ | |||
#define __INCLUDE_GUARD_POWERTOP_H_ | |||
-#include <libintl.h> | |||
- | |||
struct line { | |||
char *string; | |||
int count; | |||
int disk_count; | |||
char pid[12]; | |||
}; | |||
typedef void (suggestion_func)(void); | |||
@@ -87,17 +85,17 @@ extern suggestion_func *suggestion_activate; | |||
/* min definition borrowed from the Linux kernel */ | |||
#define min(x,y) ({ \ | |||
typeof(x) _x = (x); \ | |||
typeof(y) _y = (y); \ | |||
(void) (&_x == &_y); \ | |||
_x < _y ? _x : _y; }) | |||
-#define _(STRING) gettext(STRING) | |||
+#define _(STRING) (STRING) | |||
#define PT_COLOR_DEFAULT 1 | |||
#define PT_COLOR_HEADER_BAR 2 | |||
#define PT_COLOR_ERROR 3 | |||
#define PT_COLOR_RED 4 | |||
#define PT_COLOR_YELLOW 5 | |||
#define PT_COLOR_GREEN 6 | |||
Configure, compile, and install ncurses: |