Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/acme/linux into perf/urgent

Cherry picked fixes from perf/core, together with the kernel fix (1018faa),
the sampling tools (top, record) are back working on AMD systems.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed Mar 5, 2012
2 parents 1018faa + bc76efe commit b7c9242
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
33 changes: 22 additions & 11 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ static void perf_record__open(struct perf_record *rec)

if (opts->group && pos != first)
group_fd = first->fd;
fallback_missing_features:
if (opts->exclude_guest_missing)
attr->exclude_guest = attr->exclude_host = 0;
retry_sample_id:
attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0;
try_again:
Expand All @@ -217,15 +220,23 @@ static void perf_record__open(struct perf_record *rec)
} else if (err == ENODEV && opts->cpu_list) {
die("No such device - did you specify"
" an out-of-range profile CPU?\n");
} else if (err == EINVAL && opts->sample_id_all_avail) {
/*
* Old kernel, no attr->sample_id_type_all field
*/
opts->sample_id_all_avail = false;
if (!opts->sample_time && !opts->raw_samples && !time_needed)
attr->sample_type &= ~PERF_SAMPLE_TIME;

goto retry_sample_id;
} else if (err == EINVAL) {
if (!opts->exclude_guest_missing &&
(attr->exclude_guest || attr->exclude_host)) {
pr_debug("Old kernel, cannot exclude "
"guest or host samples.\n");
opts->exclude_guest_missing = true;
goto fallback_missing_features;
} else if (opts->sample_id_all_avail) {
/*
* Old kernel, no attr->sample_id_type_all field
*/
opts->sample_id_all_avail = false;
if (!opts->sample_time && !opts->raw_samples && !time_needed)
attr->sample_type &= ~PERF_SAMPLE_TIME;

goto retry_sample_id;
}
}

/*
Expand Down Expand Up @@ -503,9 +514,9 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
return err;
}

if (!!rec->no_buildid
if (!rec->no_buildid
&& !perf_header__has_feat(&session->header, HEADER_BUILD_ID)) {
pr_err("Couldn't generating buildids. "
pr_err("Couldn't generate buildids. "
"Use --no-buildid to profile anyway.\n");
return -1;
}
Expand Down
23 changes: 17 additions & 6 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,9 @@ static void perf_top__start_counters(struct perf_top *top)
attr->mmap = 1;
attr->comm = 1;
attr->inherit = top->inherit;
fallback_missing_features:
if (top->exclude_guest_missing)
attr->exclude_guest = attr->exclude_host = 0;
retry_sample_id:
attr->sample_id_all = top->sample_id_all_avail ? 1 : 0;
try_again:
Expand All @@ -868,12 +871,20 @@ static void perf_top__start_counters(struct perf_top *top)
if (err == EPERM || err == EACCES) {
ui__error_paranoid();
goto out_err;
} else if (err == EINVAL && top->sample_id_all_avail) {
/*
* Old kernel, no attr->sample_id_type_all field
*/
top->sample_id_all_avail = false;
goto retry_sample_id;
} else if (err == EINVAL) {
if (!top->exclude_guest_missing &&
(attr->exclude_guest || attr->exclude_host)) {
pr_debug("Old kernel, cannot exclude "
"guest or host samples.\n");
top->exclude_guest_missing = true;
goto fallback_missing_features;
} else if (top->sample_id_all_avail) {
/*
* Old kernel, no attr->sample_id_type_all field
*/
top->sample_id_all_avail = false;
goto retry_sample_id;
}
}
/*
* If it's cycles then fall back to hrtimer
Expand Down
1 change: 1 addition & 0 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ struct perf_record_opts {
bool sample_address;
bool sample_time;
bool sample_id_all_avail;
bool exclude_guest_missing;
bool system_wide;
bool period;
unsigned int freq;
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/top.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct perf_top {
bool inherit;
bool group;
bool sample_id_all_avail;
bool exclude_guest_missing;
bool dump_symtab;
const char *cpu_list;
struct hist_entry *sym_filter_entry;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* XXX We need to find a better place for these things...
*/
bool perf_host = true;
bool perf_guest = true;
bool perf_guest = false;

void event_attr_init(struct perf_event_attr *attr)
{
Expand Down

0 comments on commit b7c9242

Please sign in to comment.