[tip:perf/core] perf evsel: Do missing feature fallbacks in just one place

2013-01-25 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1
Gitweb: http://git.kernel.org/tip/594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 13 Dec 2012 13:13:07 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 24 Jan 2013 16:40:08 -0300

perf evsel: Do missing feature fallbacks in just one place

Instead of doing it in stat, top, record or any other tool that opens
event descriptors.

Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/n/tip-vr8hzph83d5t2mdlkf565...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 36 
 tools/perf/builtin-stat.c   | 30 +++---
 tools/perf/builtin-top.c| 20 
 tools/perf/perf.h   |  2 --
 tools/perf/util/evsel.c | 31 ---
 tools/perf/util/top.h   |  2 --
 6 files changed, 31 insertions(+), 90 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 028de72..a4b9726 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -234,25 +234,6 @@ static int perf_record__open(struct perf_record *rec)
 
list_for_each_entry(pos, >entries, node) {
struct perf_event_attr *attr = >attr;
-   /*
-* Check if parse_single_tracepoint_event has already asked for
-* PERF_SAMPLE_TIME.
-*
-* XXX this is kludgy but short term fix for problems 
introduced by
-* eac23d1c that broke 'perf script' by having different 
sample_types
-* when using multiple tracepoint events when we use a perf 
binary
-* that tries to use sample_id_all on an older kernel.
-*
-* We need to move counter creation to perf_session, support
-* different sample_types, etc.
-*/
-   bool time_needed = attr->sample_type & PERF_SAMPLE_TIME;
-
-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_missing ? 0 : 1;
 try_again:
if (perf_evsel__open(pos, evlist->cpus, evlist->threads) < 0) {
int err = errno;
@@ -266,23 +247,6 @@ try_again:
   " an out-of-range profile CPU?\n");
rc = -err;
goto out;
-   } 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_missing) {
-   /*
-* Old kernel, no 
attr->sample_id_type_all field
-*/
-   opts->sample_id_all_missing = true;
-   if (!opts->sample_time && 
!opts->raw_samples && !time_needed)
-   
perf_evsel__reset_sample_bit(pos, TIME);
-
-   goto retry_sample_id;
-   }
}
 
/*
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c12655a..ef067c1 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -132,8 +132,6 @@ static struct stats walltime_nsecs_stats;
 static int create_perf_stat_counter(struct perf_evsel *evsel)
 {
struct perf_event_attr *attr = >attr;
-   bool exclude_guest_missing = false;
-   int ret;
 
if (scale)
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
@@ -141,16 +139,8 @@ static int create_perf_stat_counter(struct perf_evsel 
*evsel)
 
attr->inherit = !no_inherit;
 
-retry:
-   if (exclude_guest_missing)
-   evsel->attr.exclude_guest = evsel->attr.exclude_host = 0;
-
-   if (perf_target__has_cpu()) {
-   ret = perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
-   if (ret)
-   goto check_ret;
-   return 0;
-   }
+   if (perf_target__has_cpu())
+   return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
 
   

[tip:perf/core] perf evsel: Do missing feature fallbacks in just one place

2013-01-25 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1
Gitweb: http://git.kernel.org/tip/594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1
Author: Arnaldo Carvalho de Melo a...@redhat.com
AuthorDate: Thu, 13 Dec 2012 13:13:07 -0300
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Thu, 24 Jan 2013 16:40:08 -0300

perf evsel: Do missing feature fallbacks in just one place

Instead of doing it in stat, top, record or any other tool that opens
event descriptors.

Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Stephane Eranian eran...@google.com
Link: http://lkml.kernel.org/n/tip-vr8hzph83d5t2mdlkf565...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-record.c | 36 
 tools/perf/builtin-stat.c   | 30 +++---
 tools/perf/builtin-top.c| 20 
 tools/perf/perf.h   |  2 --
 tools/perf/util/evsel.c | 31 ---
 tools/perf/util/top.h   |  2 --
 6 files changed, 31 insertions(+), 90 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 028de72..a4b9726 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -234,25 +234,6 @@ static int perf_record__open(struct perf_record *rec)
 
list_for_each_entry(pos, evlist-entries, node) {
struct perf_event_attr *attr = pos-attr;
-   /*
-* Check if parse_single_tracepoint_event has already asked for
-* PERF_SAMPLE_TIME.
-*
-* XXX this is kludgy but short term fix for problems 
introduced by
-* eac23d1c that broke 'perf script' by having different 
sample_types
-* when using multiple tracepoint events when we use a perf 
binary
-* that tries to use sample_id_all on an older kernel.
-*
-* We need to move counter creation to perf_session, support
-* different sample_types, etc.
-*/
-   bool time_needed = attr-sample_type  PERF_SAMPLE_TIME;
-
-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_missing ? 0 : 1;
 try_again:
if (perf_evsel__open(pos, evlist-cpus, evlist-threads)  0) {
int err = errno;
@@ -266,23 +247,6 @@ try_again:
an out-of-range profile CPU?\n);
rc = -err;
goto out;
-   } 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_missing) {
-   /*
-* Old kernel, no 
attr-sample_id_type_all field
-*/
-   opts-sample_id_all_missing = true;
-   if (!opts-sample_time  
!opts-raw_samples  !time_needed)
-   
perf_evsel__reset_sample_bit(pos, TIME);
-
-   goto retry_sample_id;
-   }
}
 
/*
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c12655a..ef067c1 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -132,8 +132,6 @@ static struct stats walltime_nsecs_stats;
 static int create_perf_stat_counter(struct perf_evsel *evsel)
 {
struct perf_event_attr *attr = evsel-attr;
-   bool exclude_guest_missing = false;
-   int ret;
 
if (scale)
attr-read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
@@ -141,16 +139,8 @@ static int create_perf_stat_counter(struct perf_evsel 
*evsel)
 
attr-inherit = !no_inherit;
 
-retry:
-   if (exclude_guest_missing)
-   evsel-attr.exclude_guest = evsel-attr.exclude_host = 0;
-
-   if (perf_target__has_cpu(target)) {
-   ret = perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
-   if (ret)
-   goto