Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147698
b: refs/heads/master
c: 3da297a
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Jun 7, 2009
1 parent 14be542 commit 1287196
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 716c69fecacd42f2a304a97158e04af2786a3f65
refs/heads/master: 3da297a60f7e8840f79f7d0b343af078890939ea
25 changes: 23 additions & 2 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static pid_t target_pid = -1;
static int inherit = 1;
static int force = 0;
static int append_file = 0;
static int verbose = 0;

static long samples;
static struct timeval last_read;
Expand Down Expand Up @@ -349,17 +350,35 @@ static void create_counter(int counter, int cpu, pid_t pid)

track = 0; /* only the first counter needs these */

try_again:
fd[nr_cpu][counter] = sys_perf_counter_open(attr, pid, cpu, group_fd, 0);

if (fd[nr_cpu][counter] < 0) {
int err = errno;

error("syscall returned with %d (%s)\n",
if (verbose)
error("sys_perf_counter_open() syscall returned with %d (%s)\n",
fd[nr_cpu][counter], strerror(err));
if (err == EPERM)
printf("Are you root?\n");
die("Permission error - are you root?\n");

/*
* If it's cycles then fall back to hrtimer
* based cpu-clock-tick sw counter, which
* is always available even if no PMU support:
*/
if (attr->type == PERF_TYPE_HARDWARE
&& attr->config == PERF_COUNT_CPU_CYCLES) {

if (verbose)
warning(" ... trying to fall back to cpu-clock-ticks\n");
attr->type = PERF_TYPE_SOFTWARE;
attr->config = PERF_COUNT_CPU_CLOCK;
goto try_again;
}
exit(-1);
}

assert(fd[nr_cpu][counter] >= 0);
fcntl(fd[nr_cpu][counter], F_SETFL, O_NONBLOCK);

Expand Down Expand Up @@ -519,6 +538,8 @@ static const struct option options[] = {
"profile at this frequency"),
OPT_INTEGER('m', "mmap-pages", &mmap_pages,
"number of mmap data pages"),
OPT_BOOLEAN('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
OPT_END()
};

Expand Down
14 changes: 10 additions & 4 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static int group = 0;
static unsigned int page_size;
static unsigned int mmap_pages = 16;
static int freq = 0;
static int verbose = 0;

static char *sym_filter;
static unsigned long filter_start;
Expand Down Expand Up @@ -550,11 +551,12 @@ static void start_counter(int i, int counter)
if (fd[i][counter] < 0) {
int err = errno;

error("sys_perf_counter_open() syscall returned with %d (%s)\n",
fd[i][counter], strerror(err));
if (verbose)
error("sys_perf_counter_open() syscall returned with %d (%s)\n",
fd[i][counter], strerror(err));

if (err == EPERM)
die(" No permission - are you root?\n");
die("No permission - are you root?\n");
/*
* If it's cycles then fall back to hrtimer
* based cpu-clock-tick sw counter, which
Expand All @@ -563,7 +565,9 @@ static void start_counter(int i, int counter)
if (attr->type == PERF_TYPE_HARDWARE
&& attr->config == PERF_COUNT_CPU_CYCLES) {

warning(" ... trying to fall back to cpu-clock-ticks\n");
if (verbose)
warning(" ... trying to fall back to cpu-clock-ticks\n");

attr->type = PERF_TYPE_SOFTWARE;
attr->config = PERF_COUNT_CPU_CLOCK;
goto try_again;
Expand Down Expand Up @@ -673,6 +677,8 @@ static const struct option options[] = {
"profile at this frequency"),
OPT_INTEGER('E', "entries", &print_entries,
"display this many functions"),
OPT_BOOLEAN('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
OPT_END()
};

Expand Down

0 comments on commit 1287196

Please sign in to comment.