Skip to contentSkip to conversation

perf/core fixes and improvements

GIT PULL New Arnaldo Carvalho de Melo 2 participants 5 messages Feb 14, 2012 – Feb 15, 2012 perf events

lore
Share & tools
lore
#0 lore raw

The following changes since commit c98fdeaa92731308ed80386261fa2589addefa47:

x86/sched/perf/AMD: Set sched_clock_stable (2012-02-07 13:12:08 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf-core-for-mingo

for you to fetch changes up to 808e122630d45a7f036d25582474d70548a87e2c:

perf tools: Invert the sample_id_all logic (2012-02-14 14:18:57 -0200)

----------------------------------------------------------------
perf core fixes and improvements.

Includes the previous pull request + the exclude_{host,guest} feature test and fallback to handle older kernels.

----------------------------------------------------------------
Arnaldo Carvalho de Melo (2):
perf tools: Handle kernels that don't support attr.exclude_{guest,host} perf tools: Invert the sample_id_all logic

David Ahern (3):
perf record: No build id option fails
perf tools: Fix out of tree compiles
perf tools: Allow multiple threads or processes in record, stat, top

Jiri Olsa (3):
perf tools: Remove unused functions from debugfs object perf tools: Add sysfs mountpoint interface perf tools: Add bitmap_or function into bitmap object

Joerg Roedel (2):
perf top: Don't process samples with no valid machine object perf tools: Change perf_guest default back to false

Namhyung Kim (4):
perf tools: Fix build dependency of perf python extension perf tools: Implement islower/isupper macro into util.h perf tools: ctype.c only wants util.h
perf tools: Get rid of ctype.h in symbol.c

Robert Richter (2):
perf tools: Moving code in header.c
perf tools: Factor out feature op to process header sections

Stephane Eranian (2):
perf tools: fix endianness detection in perf.data perf tools: cleanup initialization of attr->size

 tools/perf/Documentation/perf-record.txt |    4 +-
 tools/perf/Documentation/perf-stat.txt   |    4 +-
 tools/perf/Documentation/perf-top.txt    |    4 +-
 tools/perf/MANIFEST                      |    1 +
 tools/perf/Makefile                      |    7 +-
 tools/perf/builtin-record.c              |   46 ++--
 tools/perf/builtin-stat.c                |   31 ++-
 tools/perf/builtin-test.c                |    3 -
 tools/perf/builtin-top.c                 |   44 ++-
 tools/perf/perf.h                        |    8 +-
 tools/perf/util/bitmap.c                 |   10 +
 tools/perf/util/ctype.c                  |    2 +-
 tools/perf/util/debugfs.c                |  141 ----------
 tools/perf/util/debugfs.h                |    6 -
 tools/perf/util/evlist.c                 |   10 +-
 tools/perf/util/evlist.h                 |    4 +-
 tools/perf/util/evsel.c                  |    6 +-
 tools/perf/util/header.c                 |  421 +++++++++++++++++-------------
 tools/perf/util/hist.h                   |    1 +
 tools/perf/util/include/linux/bitmap.h   |   11 +
 tools/perf/util/python-ext-sources       |   19 ++
 tools/perf/util/session.c                |   10 +
 tools/perf/util/setup.py                 |    8 +-
 tools/perf/util/symbol.c                 |    2 +-
 tools/perf/util/sysfs.c                  |   60 +++++
 tools/perf/util/sysfs.h                  |    6 +
 tools/perf/util/thread_map.c             |  128 +++++++++
 tools/perf/util/thread_map.h             |    4 +
 tools/perf/util/top.c                    |   10 +-
 tools/perf/util/top.h                    |    5 +-
 tools/perf/util/usage.c                  |    6 +-
 tools/perf/util/util.c                   |    4 +-
 tools/perf/util/util.h                   |    6 +-
 33 files changed, 616 insertions(+), 416 deletions(-)
 create mode 100644 tools/perf/util/python-ext-sources
 create mode 100644 tools/perf/util/sysfs.c
 create mode 100644 tools/perf/util/sysfs.h
#1 lore raw

PATCH 1/2 perf tools: Handle kernels that don't support attr.exclude_{guest,host}

From: Arnaldo Carvalho de Melo <[email protected]>

Just fall back to resetting those fields, if set, warning the user that that feature is not available.

If guest samples appear they will just be discarded because no struct machine will be found and thus the event will be accounted as not handled and dropped, see 0c09571.

---
 tools/perf/builtin-record.c |   29 ++++++++++++++++++++---------
 tools/perf/builtin-top.c    |   23 +++++++++++++++++------
 tools/perf/perf.h           |    1 +
 tools/perf/util/top.h       |    1 +
 4 files changed, 39 insertions(+), 15 deletions(-)
tools/perf/builtin-record.c +20 -9
index 08ed24b..d6c10e8 100644
@@ -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;
+				}
 			}
 
 			/*
tools/perf/builtin-top.c +17 -6
index 5a88c0d..02e11ff 100644
@@ -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
tools/perf/perf.h +1 -0
index 03a0456..8b9c436 100644
@@ -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;
tools/perf/util/top.h +1 -0
index 49eb848..7dea891 100644
@@ -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;
Signature · 1 line
1.7.9.123.g65da0
#2 lore raw

PATCH 2/2 perf tools: Invert the sample_id_all logic

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Instead of requiring that users of perf_record_opts set .sample_id_all_avail to true, just invert the logic, using .sample_id_all_missing, that doesn't need to be explicitely initialized since gcc will zero members ommitted in a struct initialization.

Just like the newly introduced .exclude_{guest,host} feature test.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-record.c |    7 +++----
 tools/perf/builtin-test.c   |    1 -
 tools/perf/builtin-top.c    |    7 +++----
 tools/perf/perf.h           |    2 +-
 tools/perf/util/evsel.c     |    4 ++--
 tools/perf/util/top.h       |    2 +-
 6 files changed, 10 insertions(+), 13 deletions(-)
tools/perf/builtin-record.c +3 -4
index d6c10e8..75d230f 100644
@@ -209,7 +209,7 @@ 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;
+		attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
 try_again:
 		if (perf_evsel__open(pos, evlist->cpus, evlist->threads,
 				     opts->group, group_fd) < 0) {
@@ -228,11 +228,11 @@ try_again:
 						 "guest or host samples.\n");
 					opts->exclude_guest_missing = true;
 					goto fallback_missing_features;
-				} else if (opts->sample_id_all_avail) {
+				} else if (!opts->sample_id_all_missing) {
 					/*
 					 * Old kernel, no attr->sample_id_type_all field
 					 */
-					opts->sample_id_all_avail = false;
+					opts->sample_id_all_missing = true;
 					if (!opts->sample_time && !opts->raw_samples && !time_needed)
 						attr->sample_type &= ~PERF_SAMPLE_TIME;
 
@@ -660,7 +660,6 @@ static struct perf_record record = {
 		.user_freq	     = UINT_MAX,
 		.user_interval	     = ULLONG_MAX,
 		.freq		     = 1000,
-		.sample_id_all_avail = true,
 	},
 	.write_mode = WRITE_FORCE,
 	.file_new   = true,
tools/perf/builtin-test.c +0 -1
index 0f15195..3e087ce 100644
@@ -1013,7 +1013,6 @@ static int test__PERF_RECORD(void)
 		.no_delay   = true,
 		.freq	    = 10,
 		.mmap_pages = 256,
-		.sample_id_all_avail = true,
 	};
 	cpu_set_t *cpu_mask = NULL;
 	size_t cpu_mask_size = 0;
tools/perf/builtin-top.c +3 -4
index 02e11ff..e3c63ae 100644
@@ -876,7 +876,7 @@ 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;
+		attr->sample_id_all = top->sample_id_all_missing ? 0 : 1;
 try_again:
 		if (perf_evsel__open(counter, top->evlist->cpus,
 				     top->evlist->threads, top->group,
@@ -893,11 +893,11 @@ try_again:
 						 "guest or host samples.\n");
 					top->exclude_guest_missing = true;
 					goto fallback_missing_features;
-				} else if (top->sample_id_all_avail) {
+				} else if (!top->sample_id_all_missing) {
 					/*
 					 * Old kernel, no attr->sample_id_type_all field
 					 */
-					top->sample_id_all_avail = false;
+					top->sample_id_all_missing = true;
 					goto retry_sample_id;
 				}
 			}
@@ -1122,7 +1122,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
 		.delay_secs	     = 2,
 		.uid		     = UINT_MAX,
 		.freq		     = 1000, /* 1 KHz */
-		.sample_id_all_avail = true,
 		.mmap_pages	     = 128,
 		.sym_pcnt_filter     = 5,
 	};
tools/perf/perf.h +1 -1
index 8b9c436..f0227e9 100644
@@ -198,7 +198,7 @@ struct perf_record_opts {
 	bool	     raw_samples;
 	bool	     sample_address;
 	bool	     sample_time;
-	bool	     sample_id_all_avail;
+	bool	     sample_id_all_missing;
 	bool	     exclude_guest_missing;
 	bool	     system_wide;
 	bool	     period;
tools/perf/util/evsel.c +2 -2
index f910f50..302d49a 100644
@@ -68,7 +68,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
 	struct perf_event_attr *attr = &evsel->attr;
 	int track = !evsel->idx; /* only the first counter needs these */
 
-	attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0;
+	attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
 	attr->inherit	    = !opts->no_inherit;
 	attr->read_format   = PERF_FORMAT_TOTAL_TIME_ENABLED |
 			      PERF_FORMAT_TOTAL_TIME_RUNNING |
@@ -111,7 +111,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
 	if (opts->period)
 		attr->sample_type	|= PERF_SAMPLE_PERIOD;
 
-	if (opts->sample_id_all_avail &&
+	if (!opts->sample_id_all_missing &&
 	    (opts->sample_time || opts->system_wide ||
 	     !opts->no_inherit || opts->cpu_list))
 		attr->sample_type	|= PERF_SAMPLE_TIME;
tools/perf/util/top.h +1 -1
index 7dea891..ce61cb2 100644
@@ -34,7 +34,7 @@ struct perf_top {
 	bool		   vmlinux_warned;
 	bool		   inherit;
 	bool		   group;
-	bool		   sample_id_all_avail;
+	bool		   sample_id_all_missing;
 	bool		   exclude_guest_missing;
 	bool		   dump_symtab;
 	const char	   *cpu_list;
Signature · 1 line
1.7.9.123.g65da0
#3 lore raw
In reply to Arnaldo Carvalho de Melo

Hello, Arnaldo

Quoted 12 lines · Arnaldo Carvalho de Melo

The following changes since commit c98fdeaa92731308ed80386261fa2589addefa47:

   x86/sched/perf/AMD: Set sched_clock_stable (2012-02-07 13:12:08 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux perf-core-for-mingo

for you to fetch changes up to 808e122630d45a7f036d25582474d70548a87e2c:

   perf tools: Invert the sample_id_all logic (2012-02-14 14:18:57 -0200)
Quoted 8 lines

----------------------------------------------------------------
perf core fixes and improvements.

Includes the previous pull request + the exclude_{host,guest} feature test and fallback to handle older kernels.

I've just found that you missed my previous two patches which can be found at:

https://lkml.org/lkml/2012/1/30/576

Do they have any problem?

Thanks,
Namhyung

Quoted 70 lines

----------------------------------------------------------------
Arnaldo Carvalho de Melo (2):
perf tools: Handle kernels that don't support attr.exclude_{guest,host} perf tools: Invert the sample_id_all logic

David Ahern (3):
perf record: No build id option fails
perf tools: Fix out of tree compiles
perf tools: Allow multiple threads or processes in record, stat, top

Jiri Olsa (3):
perf tools: Remove unused functions from debugfs object perf tools: Add sysfs mountpoint interface perf tools: Add bitmap_or function into bitmap object

Joerg Roedel (2):
perf top: Don't process samples with no valid machine object perf tools: Change perf_guest default back to false

Namhyung Kim (4):
perf tools: Fix build dependency of perf python extension perf tools: Implement islower/isupper macro into util.h perf tools: ctype.c only wants util.h
perf tools: Get rid of ctype.h in symbol.c

Robert Richter (2):
perf tools: Moving code in header.c
perf tools: Factor out feature op to process header sections

Stephane Eranian (2):
perf tools: fix endianness detection in perf.data perf tools: cleanup initialization of attr->size

  tools/perf/Documentation/perf-record.txt |    4 +-
  tools/perf/Documentation/perf-stat.txt   |    4 +-
  tools/perf/Documentation/perf-top.txt    |    4 +-
  tools/perf/MANIFEST                      |    1 +
  tools/perf/Makefile                      |    7 +-
  tools/perf/builtin-record.c              |   46 ++--
  tools/perf/builtin-stat.c                |   31 ++-
  tools/perf/builtin-test.c                |    3 -
  tools/perf/builtin-top.c                 |   44 ++-
  tools/perf/perf.h                        |    8 +-
  tools/perf/util/bitmap.c                 |   10 +
  tools/perf/util/ctype.c                  |    2 +-
  tools/perf/util/debugfs.c                |  141 ----------
  tools/perf/util/debugfs.h                |    6 -
  tools/perf/util/evlist.c                 |   10 +-
  tools/perf/util/evlist.h                 |    4 +-
  tools/perf/util/evsel.c                  |    6 +-
  tools/perf/util/header.c                 |  421 +++++++++++++++++-------------
  tools/perf/util/hist.h                   |    1 +
  tools/perf/util/include/linux/bitmap.h   |   11 +
  tools/perf/util/python-ext-sources       |   19 ++
  tools/perf/util/session.c                |   10 +
  tools/perf/util/setup.py                 |    8 +-
  tools/perf/util/symbol.c                 |    2 +-
  tools/perf/util/sysfs.c                  |   60 +++++
  tools/perf/util/sysfs.h                  |    6 +
  tools/perf/util/thread_map.c             |  128 +++++++++
  tools/perf/util/thread_map.h             |    4 +
  tools/perf/util/top.c                    |   10 +-
  tools/perf/util/top.h                    |    5 +-
  tools/perf/util/usage.c                  |    6 +-
  tools/perf/util/util.c                   |    4 +-
  tools/perf/util/util.h                   |    6 +-
  33 files changed, 616 insertions(+), 416 deletions(-)

create mode 100644 tools/perf/util/python-ext-sources create mode 100644 tools/perf/util/sysfs.c create mode 100644 tools/perf/util/sysfs.h