From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: David Ahern <dsahern@gmail.com>,
Namhyung Kim <namhyung.kim@lge.com>,
Namhyung Kim <namhyung@gmail.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andi Kleen <andi@firstfloor.org>,
Anshuman Khandual <khandual@linux.vnet.ibm.com>,
Arun Sharma <asharma@fb.com>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jason Wang <jasowang@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
Lin Ming <ming.m.lin@intel.com>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Roberto Agostino Vitillo <ravitillo@lbl.gov>,
Robert Richter <robert.richter@amd.com>,
Stephane Eranian <eranian@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Vince Weaver <vweaver1@eecs.utk.edu>
Subject: Re: [GIT PULL 00/16] perf/core improvements and fixes
Date: Tue, 14 Feb 2012 12:38:53 -0200 [thread overview]
Message-ID: <20120214143853.GC28614@infradead.org> (raw)
In-Reply-To: <20120214131046.GA28614@infradead.org>
Em Tue, Feb 14, 2012 at 11:10:46AM -0200, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Feb 14, 2012 at 11:50:18AM +0100, Joerg Roedel escreveu:
> > On Mon, Feb 13, 2012 at 10:23:07PM -0700, David Ahern wrote:
> > > On 2/13/12 10:10 PM, Namhyung Kim wrote:
> > > >It happened because I used old kernel version that isn't aware of the
> > > >exclude_guest bit. So the check on attr->__reserved_1 in
> > > >core.c::perf_copy_attr() failed and then ended up seeing EINVAL at
> > > >perf_evsel__open().
>
> > > comes back to 1aed2671738785e8f5aea663a6fda91aa7ef59b5 again. See
>
> > > https://lkml.org/lkml/2012/2/8/234
>
> > Grr. I totally forgot that issue. Is there some way to detect the perf
> > kernel-features? Otherwise the only fix seems to be to drop the patch
> > changing the default. The crashes should be fixed by the other patch
> > already.
>
> Well, we need to detect it like we do with sample_id_all. In this case
> we would try with exclude_guest, if it fails with EINVAL, we realise it
> is not available, clean that bit and try again.
The following patch should fix it, still untested tho, booting a machine
with an < 3.1 kernel to check...
- Arnaldo
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 08ed24b..d6c10e8 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -205,6 +205,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:
@@ -218,15 +221,23 @@ try_again:
} 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;
+ }
}
/*
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a88c0d..02e11ff 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -872,6 +872,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:
@@ -883,12 +886,20 @@ try_again:
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
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 03a0456..8b9c436 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -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;
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index 49eb848..7dea891 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -35,6 +35,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;
next prev parent reply other threads:[~2012-02-14 14:39 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 1:52 [GIT PULL 00/16] perf/core improvements and fixes Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 01/16] perf tools: fix endianness detection in perf.data Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 02/16] perf record: No build id option fails Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 03/16] perf tools: Fix build dependency of perf python extension Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 04/16] perf tools: Fix out of tree compiles Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 05/16] perf tools: Allow multiple threads or processes in record, stat, top Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 06/16] perf top: Don't process samples with no valid machine object Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 07/16] perf tools: Change perf_guest default back to false Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 08/16] perf tools: Implement islower/isupper macro into util.h Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 09/16] perf tools: ctype.c only wants util.h Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 10/16] perf tools: Get rid of ctype.h in symbol.c Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 11/16] perf tools: Remove unused functions from debugfs object Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 12/16] perf tools: Add sysfs mountpoint interface Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 13/16] perf tools: Add bitmap_or function into bitmap object Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 14/16] perf tools: Moving code in header.c Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 15/16] perf tools: Factor out feature op to process header sections Arnaldo Carvalho de Melo
2012-02-14 1:52 ` [PATCH 16/16] perf tools: cleanup initialization of attr->size Arnaldo Carvalho de Melo
2012-02-14 2:50 ` [GIT PULL 00/16] perf/core improvements and fixes Namhyung Kim
2012-02-14 3:07 ` Namhyung Kim
2012-02-14 5:10 ` Namhyung Kim
2012-02-14 5:23 ` David Ahern
2012-02-14 5:48 ` Namhyung Kim
2012-02-14 5:52 ` David Ahern
2012-02-14 5:58 ` Namhyung Kim
2012-02-14 10:50 ` Joerg Roedel
2012-02-14 13:10 ` Arnaldo Carvalho de Melo
2012-02-14 14:38 ` Arnaldo Carvalho de Melo [this message]
2012-02-14 15:10 ` Joerg Roedel
2012-02-14 16:11 ` Arnaldo Carvalho de Melo
-- strict thread matches above, loose matches on Subject: below --
2019-01-04 18:33 Arnaldo Carvalho de Melo
2019-01-08 15:32 ` Ingo Molnar
2016-07-05 0:38 Arnaldo Carvalho de Melo
2016-07-05 10:14 ` Ingo Molnar
2016-01-29 21:17 Arnaldo Carvalho de Melo
2016-01-29 21:17 ` Arnaldo Carvalho de Melo
2016-02-03 10:02 ` Ingo Molnar
2016-02-03 10:02 ` Ingo Molnar
2015-12-14 17:44 Arnaldo Carvalho de Melo
2015-10-05 21:03 Arnaldo Carvalho de Melo
2015-10-06 7:09 ` Ingo Molnar
2015-09-30 21:54 Arnaldo Carvalho de Melo
2015-10-01 7:05 ` Ingo Molnar
2015-08-25 16:14 Arnaldo Carvalho de Melo
2015-08-26 13:39 ` Arnaldo Carvalho de Melo
2015-04-07 16:40 Arnaldo Carvalho de Melo
2015-04-07 16:40 ` Arnaldo Carvalho de Melo
2014-11-19 16:03 Arnaldo Carvalho de Melo
2014-11-20 7:33 ` Ingo Molnar
2014-08-22 16:29 Arnaldo Carvalho de Melo
2014-08-24 10:11 ` Ingo Molnar
2014-08-24 11:16 ` Arnaldo Carvalho de Melo
2014-08-24 14:47 ` Ingo Molnar
2014-03-14 21:29 Arnaldo Carvalho de Melo
2014-03-18 8:24 ` Ingo Molnar
2013-11-18 20:27 Arnaldo Carvalho de Melo
2013-10-23 20:57 Arnaldo Carvalho de Melo
2013-10-24 6:52 ` Ingo Molnar
2011-09-29 22:47 Arnaldo Carvalho de Melo
2011-10-04 7:57 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120214143853.GC28614@infradead.org \
--to=arnaldo.melo@gmail.com \
--cc=andi@firstfloor.org \
--cc=asharma@fb.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jasowang@redhat.com \
--cc=joerg.roedel@amd.com \
--cc=jolsa@redhat.com \
--cc=khandual@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.m.lin@intel.com \
--cc=mingo@elte.hu \
--cc=namhyung.kim@lge.com \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=ravitillo@lbl.gov \
--cc=robert.richter@amd.com \
--cc=tglx@linutronix.de \
--cc=vweaver1@eecs.utk.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.