git.openpandora.org
/
pandora-kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perf tools: Add the ability to specify list of cpus to monitor
[pandora-kernel.git]
/
tools
/
perf
/
builtin-stat.c
diff --git
a/tools/perf/builtin-stat.c
b/tools/perf/builtin-stat.c
index
ff8c413
..
a6b4d44
100644
(file)
--- a/
tools/perf/builtin-stat.c
+++ b/
tools/perf/builtin-stat.c
@@
-50,6
+50,7
@@
#include <sys/prctl.h>
#include <math.h>
#include <sys/prctl.h>
#include <math.h>
+#include <locale.h>
static struct perf_event_attr default_attrs[] = {
static struct perf_event_attr default_attrs[] = {
@@
-68,7
+69,7
@@
static struct perf_event_attr default_attrs[] = {
};
static bool system_wide = false;
};
static bool system_wide = false;
-static
unsigned int
nr_cpus = 0;
+static
int
nr_cpus = 0;
static int run_idx = 0;
static int run_count = 1;
static int run_idx = 0;
static int run_count = 1;
@@
-80,6
+81,9
@@
static pid_t *all_tids = NULL;
static int thread_num = 0;
static pid_t child_pid = -1;
static bool null_run = false;
static int thread_num = 0;
static pid_t child_pid = -1;
static bool null_run = false;
+static bool big_num = false;
+static const char *cpu_list;
+
static int *fd[MAX_NR_CPUS][MAX_COUNTERS];
static int *fd[MAX_NR_CPUS][MAX_COUNTERS];
@@
-155,7
+159,7
@@
static int create_perf_stat_counter(int counter)
PERF_FORMAT_TOTAL_TIME_RUNNING;
if (system_wide) {
PERF_FORMAT_TOTAL_TIME_RUNNING;
if (system_wide) {
-
unsigned
int cpu;
+ int cpu;
for (cpu = 0; cpu < nr_cpus; cpu++) {
fd[cpu][counter][0] = sys_perf_event_open(attr,
for (cpu = 0; cpu < nr_cpus; cpu++) {
fd[cpu][counter][0] = sys_perf_event_open(attr,
@@
-205,7
+209,7
@@
static inline int nsec_counter(int counter)
static void read_counter(int counter)
{
u64 count[3], single_count[3];
static void read_counter(int counter)
{
u64 count[3], single_count[3];
-
unsigned
int cpu;
+ int cpu;
size_t res, nv;
int scaled;
int i, thread;
size_t res, nv;
int scaled;
int i, thread;
@@
-377,7
+381,7
@@
static void nsec_printout(int counter, double avg)
{
double msecs = avg / 1e6;
{
double msecs = avg / 1e6;
- fprintf(stderr, " %1
4
.6f %-24s", msecs, event_name(counter));
+ fprintf(stderr, " %1
8
.6f %-24s", msecs, event_name(counter));
if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter)) {
fprintf(stderr, " # %10.3f CPUs ",
if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter)) {
fprintf(stderr, " # %10.3f CPUs ",
@@
-389,7
+393,10
@@
static void abs_printout(int counter, double avg)
{
double total, ratio = 0.0;
{
double total, ratio = 0.0;
- fprintf(stderr, " %14.0f %-24s", avg, event_name(counter));
+ if (big_num)
+ fprintf(stderr, " %'18.0f %-24s", avg, event_name(counter));
+ else
+ fprintf(stderr, " %18.0f %-24s", avg, event_name(counter));
if (MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) {
total = avg_stats(&runtime_cycles_stats);
if (MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) {
total = avg_stats(&runtime_cycles_stats);
@@
-426,7
+433,7
@@
static void print_counter(int counter)
int scaled = event_scaled[counter];
if (scaled == -1) {
int scaled = event_scaled[counter];
if (scaled == -1) {
- fprintf(stderr, " %1
4
s %-24s\n",
+ fprintf(stderr, " %1
8
s %-24s\n",
"<not counted>", event_name(counter));
return;
}
"<not counted>", event_name(counter));
return;
}
@@
-477,7
+484,7
@@
static void print_stat(int argc, const char **argv)
print_counter(counter);
fprintf(stderr, "\n");
print_counter(counter);
fprintf(stderr, "\n");
- fprintf(stderr, " %1
4
.9f seconds time elapsed",
+ fprintf(stderr, " %1
8
.9f seconds time elapsed",
avg_stats(&walltime_nsecs_stats)/1e9);
if (run_count > 1) {
fprintf(stderr, " ( +- %7.3f%% )",
avg_stats(&walltime_nsecs_stats)/1e9);
if (run_count > 1) {
fprintf(stderr, " ( +- %7.3f%% )",
@@
-534,6
+541,10
@@
static const struct option options[] = {
"repeat command and print average + stddev (max: 100)"),
OPT_BOOLEAN('n', "null", &null_run,
"null run - dont start any counters"),
"repeat command and print average + stddev (max: 100)"),
OPT_BOOLEAN('n', "null", &null_run,
"null run - dont start any counters"),
+ OPT_BOOLEAN('B', "big-num", &big_num,
+ "print large numbers with thousands\' separators"),
+ OPT_STRING('C', "cpu", &cpu_list, "cpu",
+ "list of cpus to monitor in system-wide"),
OPT_END()
};
OPT_END()
};
@@
-542,6
+553,8
@@
int cmd_stat(int argc, const char **argv, const char *prefix __used)
int status;
int i,j;
int status;
int i,j;
+ setlocale(LC_ALL, "");
+
argc = parse_options(argc, argv, options, stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && target_pid == -1 && target_tid == -1)
argc = parse_options(argc, argv, options, stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && target_pid == -1 && target_tid == -1)
@@
-556,10
+569,13
@@
int cmd_stat(int argc, const char **argv, const char *prefix __used)
}
if (system_wide)
}
if (system_wide)
- nr_cpus = read_cpu_map();
+ nr_cpus = read_cpu_map(
cpu_list
);
else
nr_cpus = 1;
else
nr_cpus = 1;
+ if (nr_cpus < 1)
+ usage_with_options(stat_usage, options);
+
if (target_pid != -1) {
target_tid = target_pid;
thread_num = find_all_tid(target_pid, &all_tids);
if (target_pid != -1) {
target_tid = target_pid;
thread_num = find_all_tid(target_pid, &all_tids);