Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349920
b: refs/heads/master
c: c0a5434
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 24, 2013
1 parent 241c96c commit cef3912
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 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: 594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1
refs/heads/master: c0a54341c0e89333ef201fc3f3001176962f6121
23 changes: 3 additions & 20 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ static bool perf_evlist__equal(struct perf_evlist *evlist,

static int perf_record__open(struct perf_record *rec)
{
char msg[128];
struct perf_evsel *pos;
struct perf_evlist *evlist = rec->evlist;
struct perf_session *session = rec->session;
Expand All @@ -249,27 +250,9 @@ static int perf_record__open(struct perf_record *rec)
goto out;
}

/*
* If it's cycles then fall back to hrtimer
* based cpu-clock-tick sw counter, which
* is always available even if no PMU support.
*
* PPC returns ENXIO until 2.6.37 (behavior changed
* with commit b0a873e).
*/
if ((err == ENOENT || err == ENXIO)
&& attr->type == PERF_TYPE_HARDWARE
&& attr->config == PERF_COUNT_HW_CPU_CYCLES) {

if (perf_evsel__fallback(pos, err, msg, sizeof(msg))) {
if (verbose)
ui__warning("The cycles event is not supported, "
"trying to fall back to cpu-clock-ticks\n");
attr->type = PERF_TYPE_SOFTWARE;
attr->config = PERF_COUNT_SW_CPU_CLOCK;
if (pos->name) {
free(pos->name);
pos->name = NULL;
}
ui__warning("%s\n", msg);
goto try_again;
}

Expand Down
20 changes: 3 additions & 17 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ static void perf_top__mmap_read(struct perf_top *top)

static void perf_top__start_counters(struct perf_top *top)
{
char msg[128];
struct perf_evsel *counter;
struct perf_evlist *evlist = top->evlist;
struct perf_record_opts *opts = &top->record_opts;
Expand All @@ -909,25 +910,10 @@ static void perf_top__start_counters(struct perf_top *top)
ui__error_paranoid();
goto out_err;
}
/*
* 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 ((err == ENOENT || err == ENXIO) &&
(attr->type == PERF_TYPE_HARDWARE) &&
(attr->config == PERF_COUNT_HW_CPU_CYCLES)) {

if (perf_evsel__fallback(counter, err, msg, sizeof(msg))) {
if (verbose)
ui__warning("Cycles event not supported,\n"
"trying to fall back to cpu-clock-ticks\n");

attr->type = PERF_TYPE_SOFTWARE;
attr->config = PERF_COUNT_SW_CPU_CLOCK;
if (counter->name) {
free(counter->name);
counter->name = NULL;
}
ui__warning("%s\n", msg);
goto try_again;
}

Expand Down
28 changes: 28 additions & 0 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,3 +1378,31 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
fputc('\n', fp);
return ++printed;
}

bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
char *msg, size_t msgsize)
{
if ((err == ENOENT || err == ENXIO) &&
evsel->attr.type == PERF_TYPE_HARDWARE &&
evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) {
/*
* If it's cycles then fall back to hrtimer based
* cpu-clock-tick sw counter, which is always available even if
* no PMU support.
*
* PPC returns ENXIO until 2.6.37 (behavior changed with commit
* b0a873e).
*/
scnprintf(msg, msgsize, "%s",
"The cycles event is not supported, trying to fall back to cpu-clock-ticks");

evsel->attr.type = PERF_TYPE_SOFTWARE;
evsel->attr.config = PERF_COUNT_SW_CPU_CLOCK;

free(evsel->name);
evsel->name = NULL;
return true;
}

return false;
}
3 changes: 3 additions & 0 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,7 @@ struct perf_attr_details {

int perf_evsel__fprintf(struct perf_evsel *evsel,
struct perf_attr_details *details, FILE *fp);

bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
char *msg, size_t msgsize);
#endif /* __PERF_EVSEL_H */

0 comments on commit cef3912

Please sign in to comment.