On Fri, Jul 30, 2010 at 4:45 PM, Vishwanath Sripathy
<vishwanath.sripathy(a)linaro.org> wrote:
> Amit,
> I tried to compile it for OMAP, but it failed to compile. Little digging
> showed that Make file does not seem to have entries for ARM tool chains. So
> I think you need to have a config file kind of thing to get powertop cross
> compiled for arm based platforms.
Yes, but it may not be as simple. PowerTOP uses libncursesw library to
link with. Hence for cross compilation we need to make sure that this
(or a non-wide char ncurses library, i.e. libncurses) should also be
cross compiled for target ARM. And then we should have some option in
Makefile (LIBPATH & INCPATH) to point to it.
Will it make sense to have a "readme.ARM" or some other file in
powertop which describes this step ? Any suggestions on how best to do
this ?
Thanks!
--
Regards,
Amit Arora
> Vishwa
Here is the initial draft of the instructions to bring
up a Versatile Express platform.
https://wiki.linaro.org/Boards/Vexpress
I still need to add sections detailing where to find (and
build) the various parts like the bootloader and the kernel.
--Matt
What tools and libraries should I use when writing
infrastructure-style projects? Do we have a preferred technology
list? Is there a style guide or standard templates that I can use?
This came about in writing a little web application for tracking the
changes in Linaro GCC vs upstream:
http://ex.seabright.co.nz/patchtrack/
The code is at https://code.launchpad.net/~michaelh1/+junk/patchtrack.
It uses web.py for the app engine, web.py's built-in template engine,
and a hacked up version of the wiki template. I'd love to use tools
that somebody else knows as well though :)
Canonical have a preferred technology list but it's a bit heavy - zope
or django are an overkill for something like this.
Any thoughts?
-- Michael
The weekly report for the Linaro Infrastructure team may be found at:-
https://wiki.linaro.org/Releases/InfrastructureStatus
Summary:
Three LexBuilder <https://wiki.linaro.org/LexBuilder> bugs awaiting
review.
Work ongoing for hosting a public location where we can have live
production/demo of the dashboard.
There is a concern that the changes to LexBuilder are behind schedule.
The first licence request submitted to the TSC was approved. Two
more requests have been submitted to the TSC to cover the test environment.
Progress:
A lot of tasks remain outstanding for the 10.10 beta. This is being
investigated to establish of this is realistic. An update will be
provided in the next report.
This patch gets the available C-states from cpuidle framework (sysfs) and gets the P-states information from the cpufreq (again, from sysfs). Thus it removes the hardcoded values for c and p states, and makes it generic enough to run on all the systems which plugin to cpuidle and cpufreq kernel framework.
Signed-off-by: Amit Arora <amit.arora(a)linaro.org>
---
Makefile | 2 +-
cpufreqstats.c | 3 +-
display.c | 15 ++++++---
generic_cstates.c | 63 ++++++++++++++++++++++++++++++++++++++++
omapcstates.c | 64 -----------------------------------------
powertop.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++-----
powertop.h | 23 +++-----------
7 files changed, 154 insertions(+), 98 deletions(-)
create mode 100644 generic_cstates.c
delete mode 100644 omapcstates.c
diff --git a/Makefile b/Makefile
index 0b41dc4..d9e4883 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ 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 wifi-new.o perf.o \
- alsa-power.o ahci-alpm.o dmesg.o devicepm.o omapcstates.o
+ alsa-power.o ahci-alpm.o dmesg.o devicepm.o generic_cstates.o
powertop: $(OBJS) Makefile powertop.h
diff --git a/cpufreqstats.c b/cpufreqstats.c
index b250407..6cd36ee 100644
--- a/cpufreqstats.c
+++ b/cpufreqstats.c
@@ -42,7 +42,7 @@ struct cpufreqdata oldfreqs[16];
struct cpufreqdata delta[16];
-char cpufreqstrings[MAX_NUM_PSTATES+1][80];
+char **cpufreqstrings;
int topfreq = -1;
static void zap(void)
@@ -111,7 +111,6 @@ void do_cpufreq_stats(void)
uint64_t total_time = 0;
memcpy(&oldfreqs, &freqs, sizeof(freqs));
- memset(&cpufreqstrings, 0, sizeof(cpufreqstrings));
sprintf(cpufreqstrings[0], _("P-states (frequencies)\n"));
for (ret = 0; ret<16; ret++)
diff --git a/display.c b/display.c
index cc81efe..de9146b 100644
--- a/display.c
+++ b/display.c
@@ -91,7 +91,12 @@ int maxwidth = 200;
void setup_windows(void)
{
- int yline = MAX_NUM_CSTATES;
+ int yline;
+
+ if (max_num_cstates > max_num_pstates)
+ yline = max_num_cstates;
+ else
+ yline = max_num_pstates;
getmaxyx(stdscr, maxy, maxx);
@@ -152,7 +157,7 @@ void show_title_bar(void)
werase(status_bar_window);
x = 0;
- for (i=0; i < MAX_CSTATE_LINES; i++) {
+ for (i=0; i < max_cstate_lines; i++) {
if (strlen(status_bar_slots[i])==0)
continue;
wattron(status_bar_window, A_REVERSE);
@@ -168,18 +173,18 @@ void show_cstates(void)
int i, count = 0;
werase(cstate_window);
- for (i=0; i < MAX_CSTATE_LINES; i++) {
+ for (i=0; i < max_cstate_lines; i++) {
if (i == topcstate+1)
wattron(cstate_window, A_BOLD);
else
wattroff(cstate_window, A_BOLD);
- if (strlen(cstate_lines[i]) && count <= MAX_CSTATE_LINES) {
+ if (strlen(cstate_lines[i]) && count <= max_cstate_lines) {
print(cstate_window, count, 0, "%s", cstate_lines[i]);
count++;
}
}
- for (i=0; i <= MAX_NUM_PSTATES; i++) {
+ for (i=0; i <= max_num_pstates; i++) {
if (i == topfreq+1)
wattron(cstate_window, A_BOLD);
else
diff --git a/generic_cstates.c b/generic_cstates.c
new file mode 100644
index 0000000..dbee3c1
--- /dev/null
+++ b/generic_cstates.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2008, Texas Instruments Incorporated.
+ * Copyright 2010, IBM Corporation
+ *
+ * This file prints the C states supported by any processor.
+ * (Based on intelcstates.c)
+ *
+ * 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
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <ctype.h>
+
+#include "powertop.h"
+
+
+/**
+ * print_generic_cstates() - Prints the list of supported C-states.
+ *
+ * This functions uses standard sysfs interface of the cpuidle framework
+ * to extract the information of the C-states supported by the Linux
+ * kernel.
+ **/
+void print_generic_cstates(void)
+{
+ DIR *dir;
+ struct dirent *entry;
+
+ dir = opendir("/sys/devices/system/cpu/cpu0/cpuidle");
+
+ if (dir) {
+ printf(_("Supported C-states : "));
+
+ while ((entry = readdir(dir))) {
+ if (strlen(entry->d_name) < 3)
+ continue;
+
+ printf("C%s ", entry->d_name);
+ }
+ printf("\n");
+
+ closedir(dir);
+ }
+}
diff --git a/omapcstates.c b/omapcstates.c
deleted file mode 100644
index 9d1da4f..0000000
--- a/omapcstates.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2008, Texas Instruments Incorporated.
- *
- * This file prints the C states supported by the OMAP processor.
- * (Based on intelcstates.c)
- *
- * 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
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <ctype.h>
-
-#include "powertop.h"
-
-
-#if defined(OMAP3)
-/**
- * print_omap3_cstates() - Prints the list of supported C-states.
- *
- * This functions uses standard sysfs interface of the cpuidle framework
- * to extract the information of the C-states supported by the Linux
- * kernel.
- **/
-void print_omap3_cstates(void)
-{
- DIR *dir;
- struct dirent *entry;
-
- dir = opendir("/sys/devices/system/cpu/cpu0/cpuidle");
-
- if (dir) {
- printf(_("Supported C-states : "));
-
- while ((entry = readdir(dir))) {
- if (strlen(entry->d_name) < 3)
- continue;
-
- printf("C%s ", entry->d_name);
- }
- printf("\n");
-
- closedir(dir);
- }
-}
-#endif
diff --git a/powertop.c b/powertop.c
index 7a32623..6fd3efe 100644
--- a/powertop.c
+++ b/powertop.c
@@ -40,6 +40,7 @@
#include "powertop.h"
+extern void print_generic_cstates(void);
uint64_t start_usage[8], start_duration[8];
uint64_t last_usage[8], last_duration[8];
@@ -85,6 +86,70 @@ time_t prev_bat_time = 0;
double displaytime = 0.0;
+char **cstate_lines;
+
+void init_numstates(void)
+{
+ DIR *dir;
+ FILE *fp;
+ struct dirent *entry;
+ int i, count = 0;
+ char line[1024];
+
+ dir = opendir("/sys/devices/system/cpu/cpu0/cpuidle");
+ if (dir) {
+ while ((entry = readdir(dir))) {
+ if (strlen(entry->d_name) < 3)
+ continue;
+ count++;
+ }
+ closedir(dir);
+ }
+ max_num_cstates = count;
+ count = 0;
+
+ fp = fopen("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state",
+ "r");
+ if (fp) {
+ while (fgets(line, sizeof(line), fp)!=NULL)
+ count++;
+ fclose(fp);
+ }
+ max_num_pstates = count;
+
+ if (max_num_cstates > max_num_pstates)
+ max_cstate_lines = max_num_cstates + 3;
+ else
+ max_cstate_lines = max_num_pstates + 3;
+
+ /* Now, allocate memory */
+
+ cpufreqstrings = (char **)calloc((max_num_pstates+1), sizeof(char *));
+ assert(cpufreqstrings!=0);
+ for (i=0; i<max_num_pstates+1; i++) {
+ cpufreqstrings[i] = (char *)calloc(80, sizeof(char));
+ assert(cpufreqstrings[i]!=0);
+ }
+
+ cstate_lines = (char **)calloc(max_cstate_lines, sizeof(char *));
+ assert(cstate_lines!=0);
+ for (i=0; i<max_cstate_lines; i++) {
+ cstate_lines[i] = (char *)calloc(200, sizeof(char));
+ assert(cstate_lines[i]!=0);
+ }
+
+}
+
+void free_numstates(void)
+{
+ int i;
+
+ for (i=0; i<max_num_pstates+1; i++)
+ free(cpufreqstrings[i]);
+ free(cpufreqstrings);
+ cpufreqstrings = NULL;
+}
+
void push_line(char *string, int count)
{
int i;
@@ -824,8 +889,6 @@ void print_battery_sysfs(void)
show_acpi_power_line(rate, cap, prev_bat_cap - cap, time(NULL) - prev_bat_time);
}
-char cstate_lines[MAX_CSTATE_LINES][200];
-
void usage()
{
printf(_("Usage: powertop [OPTION...]\n"));
@@ -902,6 +965,8 @@ int main(int argc, char **argv)
memcpy(last_usage, start_usage, sizeof(last_usage));
memcpy(last_duration, start_duration, sizeof(last_duration));
+ init_numstates();
+
do_proc_irq();
do_proc_irq();
do_cpufreq_stats();
@@ -924,8 +989,8 @@ int main(int argc, char **argv)
printf("\n\n");
#if defined (__I386__)
print_intel_cstates();
-#elif defined (OMAP3)
- print_omap3_cstates();
+#else
+ print_generic_cstates();
#endif
stop_timerstats();
@@ -963,7 +1028,7 @@ int main(int argc, char **argv)
totalticks = 0;
totalevents = 0;
- for (i = 0; i < MAX_NUM_CSTATES; i++)
+ for (i = 0; i < max_num_cstates; i++)
if (cur_usage[i]) {
totalticks += cur_duration[i] - last_duration[i];
totalevents += cur_usage[i] - last_usage[i];
@@ -978,8 +1043,7 @@ int main(int argc, char **argv)
show_title_bar();
}
- memset(&cstate_lines, 0, sizeof(cstate_lines));
- topcstate = -(MAX_NUM_CSTATES);
+ topcstate = -(max_num_cstates);
if (totalevents == 0 && maxcstate <= 1) {
sprintf(cstate_lines[5],_("< Detailed C-state information is not available.>\n"));
} else {
@@ -993,7 +1057,7 @@ int main(int argc, char **argv)
sprintf(cstate_lines[1], _("C0 (cpu running) (%4.1f%%)\n"), percentage);
if (percentage > 50)
topcstate = 0;
- for (i = 0; i < MAX_NUM_CSTATES; i++)
+ for (i = 0; i < max_num_cstates; i++)
if (cur_usage[i]) {
sleept = (cur_duration[i] - last_duration[i]) / (cur_usage[i] - last_usage[i]
+ 0.1) / FREQ;
@@ -1300,5 +1364,7 @@ int main(int argc, char **argv)
}
end_data_dirty_capture();
+
+ free_numstates();
return 0;
}
diff --git a/powertop.h b/powertop.h
index 21f5538..4017cfe 100644
--- a/powertop.h
+++ b/powertop.h
@@ -30,19 +30,9 @@
#define VERSION "1.12"
-#if defined(__i386__)
-#define MAX_NUM_CSTATES 4
-#define MAX_NUM_PSTATES 5
-
-#elif defined(OMAP3)
-#define MAX_NUM_CSTATES 7
-#define MAX_NUM_PSTATES 5
-
-#else
-#error "No valid architecture is defined."
-#endif
-
-#define MAX_CSTATE_LINES (MAX_NUM_CSTATES + 3)
+int max_num_cstates;
+int max_num_pstates;
+int max_cstate_lines;
struct line {
char *string;
@@ -83,11 +73,8 @@ void usb_activity_hint(void);
void devicepm_activity_hint(void);
-
-
-
-extern char cstate_lines[MAX_CSTATE_LINES][200];
-extern char cpufreqstrings[MAX_NUM_PSTATES+1][80];
+extern char **cpufreqstrings;
+extern char **cstate_lines;
extern int topcstate;
extern int topfreq;
--
1.7.0.4
Currently the PowerTOP tool is x86 centric and does not work on other architectures, unless some changes are made.
This patchset removes the hardcoded values for the P and C states. It does that in two steps
1) Implements the OMAP3 support in PowerTOP.
2) Makes the code generic enough for all boards
I have tested this only on my desktop. I am yet to receive an ARM based board, and hence couldn't test it there. So, any kind of testing and/or feedback are most welcome! Thanks!
Amit Arora (2):
Add OMAP3 support to PowerTOP
Remove hardcoded c and p states
Makefile | 2 +-
cpufreqstats.c | 3 +-
display.c | 23 +++++++++-----
generic_cstates.c | 63 ++++++++++++++++++++++++++++++++++++++++
powertop.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++----
powertop.h | 11 ++++---
6 files changed, 162 insertions(+), 22 deletions(-)
create mode 100644 generic_cstates.c
--
Regards,
Amit Arora
Hi,
These are some very rough instructions for getting Maverick running on
an IGEPv2 board. Maybe they should go on the wiki somewhere, but I
wasn't sure where.
Running Maverick over NFS on an IGEPv2 board
============================================
I have the Ubuntu 9.04 "demo" image on a microSD card, and wanted to try running Maverick. To reproduce this recipe, you'll need the following:
* microSD card reader
* An installed Maverick rootfs (mine was created with qemu-debootstrap) on a system running an NFS server.
* An IGEPv2 serial cable might be handy too.
Part 1, new kernel with existing Jaunty installation
----------------------------------------------------
The kernel which comes with the demo image, 2.6.28.10 (with IGEPv2 patches), has a few problems which prevent its use with Maverick. You need to use a newer version.
Grab a precompiled kernel (I used uImage-2.6.33.5-0-igep0020.bin) from:
http://labs.igep.es/index.php/The_Linux_kernel
Now we need to make a ".ini" file which will boot this kernel. To use the existing (Jaunty) distribution on the SD card, use a config file like this:
--- cut ---
mmc init 0
echo "===== Setup boot settings ====="
setenv bootargs-base 'mem=512M console=ttyS2,115200n8 console=tty0 omapfb.mode=dvi:1024x768MR-16@60'
setenv mmc-bootargs 'setenv bootargs ${bootargs-base} root=/dev/mmcblk0p2 rw rootwait '
echo "===== Load uImage from mmc ====="
run mmc-bootargs
fatls mmc 0:1
fatload mmc 0 80200000 uImage-2.6.33.5-0-igep0020.bin
bootm 80200000
--- cut ---
Call this file "setup-ini.source". Now install the package "uboot-mkimage" on your host system and run:
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Boot setup script' -d \
setup-ini.source setup.ini
Copy setup.ini to the boot partition of the microSD card (backing up the original).
Now: you may find this is not sufficient to make the IGEPv2 boot. The problem is apparently bugs in the FAT support in the supplied version of uboot. This can be seen over the serial line in the output of "fatls": your kernel image should appear in the list.
If it does not, you might be able to work around it by doing the following:
* Copy all files off the boot partition.
* Reformat the boot partition (with the microSD card connected via a card reader to a Linux host) with:
mkdosfs /dev/sdX1
(note, adding "-F 32" did *not* work).
* Copy all files back to the boot partition.
* Don't forget to unmount!
Now, reinsert the card and Jaunty should boot with the new kernel (check with "uname -a").
Part 2, new kernel with Maverick over NFS root
----------------------------------------------
To boot with an NFS root, you will need a new setup.ini. Use the following source file:
== cut ==
mmc init 0
echo "===== Setup boot settings ====="
setenv bootargs-base 'mem=512M console=ttyS2,115200n8 console=tty0 omapfb.mode=dvi:1024x768MR-16@60'
setenv mmc-bootargs 'setenv bootargs ${bootargs-base} ip=dhcp root=/dev/nfs nfsroot=192.168.1.64:/mnt/bitbucket/jules/linaro/m-armel rw rootwait'
echo "===== Load uImage from mmc ====="
run mmc-bootargs
fatls mmc 0:1
fatload mmc 0 80200000 uImage-2.6.33.5-0-igep0020.bin
bootm 80200000
== cut ==
Substitute your NFS server for the "nfsroot" IP address, and the path on that server for the subsequent path. Use the instructions above to turn this into setup.ini, and copy to the microSD card (noting that the issue about FAT bugs still applies).
On the server, use a line like the following in /etc/exports (making local changes as necessary):
/mnt/bitbucket/jules/linaro/m-armel *.config(rw,no_root_squash,no_subtree_check,sync)
Note that "portmap" should be installed rather than "rpcbind", if your distribution offers a choice between the two (at least my board wouldn't boot, at least with the default configuration of the latter). Use "nfs-kernel-server" rather than "nfs-user-server", again if your distro offers the choice.
It's probably possible to use tftp/bootp to load a kernel instead: I
haven't experimented with that so far.