[PATCH 7/9] perf evlist: add stat unique code to open_counters method

2012-10-29 Thread David Ahern
perf-stat continues on some open failures. top and record
opt out to maintain existing behavior.

Signed-off-by: David Ahern 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Peter Zijlstra 
---
 tools/perf/builtin-record.c |2 +-
 tools/perf/builtin-top.c|2 +-
 tools/perf/util/evlist.c|   16 ++--
 tools/perf/util/evlist.h|3 ++-
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index de92d7b..c536310 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -234,7 +234,7 @@ static int perf_record__open(struct perf_record *rec)
if (opts->group)
perf_evlist__set_leader(evlist);
 
-   rc = perf_evlist__open_counters(evlist, opts);
+   rc = perf_evlist__open_counters(evlist, opts, false);
if (rc != 0)
goto out;
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 2ffc32e..2c3b3c7 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -921,7 +921,7 @@ static void perf_top__start_counters(struct perf_top *top)
attr->inherit = !top->opts.no_inherit;
}
 
-   if (perf_evlist__open_counters(evlist, &top->opts) != 0)
+   if (perf_evlist__open_counters(evlist, &top->opts, false) != 0)
goto out_err;
 
if (perf_evlist__mmap(evlist, top->opts.mmap_pages, false) < 0) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b24ebc1..7edb0bd 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -840,7 +840,8 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, 
FILE *fp)
 }
 
 int perf_evlist__open_counters(struct perf_evlist *evlist,
-  struct perf_record_opts *opts)
+  struct perf_record_opts *opts,
+  bool continue_on_fail)
 {
struct perf_evsel *pos;
int rc = 0;
@@ -872,6 +873,16 @@ try_again:
if (perf_evsel__open(pos, evlist->cpus, evlist->threads) < 0) {
int err = errno;
 
+   if (continue_on_fail &&
+   (err == EINVAL || err == ENOSYS || err == ENXIO ||
+err == ENOENT || err == EOPNOTSUPP)) {
+   if (verbose)
+   ui__warning("%s event is not supported 
by the kernel.\n",
+   perf_evsel__name(pos));
+   pos->supported = false;
+   continue;
+   }
+
if (err == EPERM || err == EACCES) {
ui__error_paranoid();
rc = -err;
@@ -962,7 +973,8 @@ try_again:
pr_err("No CONFIG_PERF_EVENTS=y kernel support 
configured?\n");
rc = -err;
goto out;
-   }
+   } else
+   pos->supported = true;
}
 out:
return rc;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 270e546..0747b6f 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -137,5 +137,6 @@ static inline struct perf_evsel *perf_evlist__last(struct 
perf_evlist *evlist)
 size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
 
 int perf_evlist__open_counters(struct perf_evlist *evlist,
-  struct perf_record_opts *opts);
+  struct perf_record_opts *opts,
+  bool continue_on_fail);
 #endif /* __PERF_EVLIST_H */
-- 
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/9] perf evlist: add stat unique code to open_counters method

2012-10-10 Thread David Ahern
Mainly the addition is an argument to keep going for some open
failures.

Signed-off-by: David Ahern 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Peter Zijlstra 
---
 tools/perf/builtin-record.c |2 +-
 tools/perf/builtin-top.c|2 +-
 tools/perf/util/evlist.c|   16 ++--
 tools/perf/util/evlist.h|3 ++-
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b9dcc01..663ccc8 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -234,7 +234,7 @@ static int perf_record__open(struct perf_record *rec)
if (opts->group)
perf_evlist__set_leader(evlist);
 
-   rc = perf_evlist__open_counters(evlist, opts);
+   rc = perf_evlist__open_counters(evlist, opts, false);
if (rc != 0)
goto out;
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 2ffc32e..2c3b3c7 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -921,7 +921,7 @@ static void perf_top__start_counters(struct perf_top *top)
attr->inherit = !top->opts.no_inherit;
}
 
-   if (perf_evlist__open_counters(evlist, &top->opts) != 0)
+   if (perf_evlist__open_counters(evlist, &top->opts, false) != 0)
goto out_err;
 
if (perf_evlist__mmap(evlist, top->opts.mmap_pages, false) < 0) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index bce2f58..fa0daac 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -840,7 +840,8 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, 
FILE *fp)
 }
 
 int perf_evlist__open_counters(struct perf_evlist *evlist,
-  struct perf_record_opts *opts)
+  struct perf_record_opts *opts,
+  bool continue_on_fail)
 {
struct perf_evsel *pos;
int rc = 0;
@@ -872,6 +873,16 @@ try_again:
if (perf_evsel__open(pos, evlist->cpus, evlist->threads) < 0) {
int err = errno;
 
+   if (continue_on_fail &&
+   (err == EINVAL || err == ENOSYS || err == ENXIO ||
+err == ENOENT || err == EOPNOTSUPP)) {
+   if (verbose)
+   ui__warning("%s event is not supported 
by the kernel.\n",
+   perf_evsel__name(pos));
+   pos->supported = false;
+   continue;
+   }
+
if (err == EPERM || err == EACCES) {
ui__error_paranoid();
rc = -err;
@@ -958,7 +969,8 @@ try_again:
pr_err("No CONFIG_PERF_EVENTS=y kernel support 
configured?\n");
rc = -err;
goto out;
-   }
+   } else
+   pos->supported = true;
}
 out:
return rc;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 270e546..0747b6f 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -137,5 +137,6 @@ static inline struct perf_evsel *perf_evlist__last(struct 
perf_evlist *evlist)
 size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
 
 int perf_evlist__open_counters(struct perf_evlist *evlist,
-  struct perf_record_opts *opts);
+  struct perf_record_opts *opts,
+  bool continue_on_fail);
 #endif /* __PERF_EVLIST_H */
-- 
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/