perf stat: Fix verbose for perf stat
Error message should use stderr for verbose (-v), otherwise message will be lost for: $ ./perf stat -v <cmd> > /dev/null For example on AMD bus-cycles event is not available so now it looks like: $ ./perf stat -v -e bus-cycles ls > /dev/null Error: counter 0, sys_perf_counter_open() syscall returned with -1 (Invalid argument) Performance counter stats for 'ls': <not counted> bus-cycles 0.006765877 seconds time elapsed. Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <1245757369.3776.1.camel@localhost.localdomain> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
b0a28589b2
commit
cca03c0aeb
@@ -109,6 +109,10 @@ static u64 walltime_nsecs_noise;
|
|||||||
static u64 runtime_cycles_avg;
|
static u64 runtime_cycles_avg;
|
||||||
static u64 runtime_cycles_noise;
|
static u64 runtime_cycles_noise;
|
||||||
|
|
||||||
|
|
||||||
|
#define ERR_PERF_OPEN \
|
||||||
|
"Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n"
|
||||||
|
|
||||||
static void create_perf_stat_counter(int counter)
|
static void create_perf_stat_counter(int counter)
|
||||||
{
|
{
|
||||||
struct perf_counter_attr *attr = attrs + counter;
|
struct perf_counter_attr *attr = attrs + counter;
|
||||||
@@ -121,18 +125,18 @@ static void create_perf_stat_counter(int counter)
|
|||||||
int cpu;
|
int cpu;
|
||||||
for (cpu = 0; cpu < nr_cpus; cpu++) {
|
for (cpu = 0; cpu < nr_cpus; cpu++) {
|
||||||
fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0);
|
fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0);
|
||||||
if (fd[cpu][counter] < 0 && verbose) {
|
if (fd[cpu][counter] < 0 && verbose)
|
||||||
printf("Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n", counter, fd[cpu][counter], strerror(errno));
|
fprintf(stderr, ERR_PERF_OPEN, counter,
|
||||||
}
|
fd[cpu][counter], strerror(errno));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attr->inherit = inherit;
|
attr->inherit = inherit;
|
||||||
attr->disabled = 1;
|
attr->disabled = 1;
|
||||||
|
|
||||||
fd[0][counter] = sys_perf_counter_open(attr, 0, -1, -1, 0);
|
fd[0][counter] = sys_perf_counter_open(attr, 0, -1, -1, 0);
|
||||||
if (fd[0][counter] < 0 && verbose) {
|
if (fd[0][counter] < 0 && verbose)
|
||||||
printf("Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n", counter, fd[0][counter], strerror(errno));
|
fprintf(stderr, ERR_PERF_OPEN, counter,
|
||||||
}
|
fd[0][counter], strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user