linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 00/22] perf/core improvements and fixes
@ 2014-05-21 13:12 Jiri Olsa
  2014-05-21 13:12 ` [PATCH 01/22] perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt Jiri Olsa
                   ` (22 more replies)
  0 siblings, 23 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Frederic Weisbecker, Michael Lentine, Namhyung Kim,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian, Jiri Olsa

hi Ingo,
please consider pulling

thanks,
jirka


The following changes since commit 6480c56130ba073df84d57d61062ec4118b10bbe:

  Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/core (2014-05-20 08:36:09 +0200)

are available in the git repository at:


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

for you to fetch changes up to eca8183699964579ca8a0b8d116bd1f4da0136f7:

  perf tools: Add automatic remapping of Android libraries (2014-05-21 15:03:25 +0200)

----------------------------------------------------------------
perf/core improvements and fixes:

. Android related fixes for pager and map dso resolving (Michael Lentine)

. Add -F option for specifying output fields (Namhyung Kim)

Signed-off-by: Jiri Olsa <jolsa@kernel.org>

----------------------------------------------------------------
Michael Lentine (2):
      perf tools: Add cat as fallback pager
      perf tools: Add automatic remapping of Android libraries

Namhyung Kim (20):
      perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt
      perf tools: Convert sort entries to hpp formats
      perf tools: Use hpp formats to sort hist entries
      perf tools: Support event grouping in hpp ->sort()
      perf tools: Use hpp formats to sort final output
      perf tools: Consolidate output field handling to hpp format routines
      perf ui: Get rid of callback from __hpp__fmt()
      perf tools: Allow hpp fields to be sort keys
      perf tools: Consolidate management of default sort orders
      perf tools: Call perf_hpp__init() before setting up GUI browsers
      perf report: Add -F option to specify output fields
      perf tools: Add ->sort() member to struct sort_entry
      perf report/tui: Fix a bug when --fields/sort is given
      perf top: Add --fields option to specify output fields
      perf tools: Skip elided sort entries
      perf hists: Reset width of output fields with header length
      perf tools: Get rid of obsolete hist_entry__sort_list
      perf tools: Introduce reset_output_field()
      perf tests: Factor out print_hists_*()
      perf tests: Add a testcase for histogram output sorting

 tools/perf/Documentation/perf-diff.txt   |   5 +-
 tools/perf/Documentation/perf-report.txt |  19 +
 tools/perf/Documentation/perf-top.txt    |  14 +-
 tools/perf/Makefile.perf                 |   1 +
 tools/perf/builtin-diff.c                |   7 +-
 tools/perf/builtin-report.c              |  41 +-
 tools/perf/builtin-top.c                 |  20 +-
 tools/perf/tests/builtin-test.c          |   4 +
 tools/perf/tests/hists_common.c          |  57 +++
 tools/perf/tests/hists_common.h          |   3 +
 tools/perf/tests/hists_filter.c          |  38 +-
 tools/perf/tests/hists_link.c            |  30 +-
 tools/perf/tests/hists_output.c          | 618 +++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h                 |   1 +
 tools/perf/ui/browsers/hists.c           | 104 +++---
 tools/perf/ui/gtk/hists.c                |  41 +-
 tools/perf/ui/hist.c                     | 244 +++++++++---
 tools/perf/ui/setup.c                    |   2 -
 tools/perf/ui/stdio/hist.c               |  79 ++--
 tools/perf/util/hist.c                   |  83 ++---
 tools/perf/util/hist.h                   |  27 +-
 tools/perf/util/map.c                    |  95 ++++-
 tools/perf/util/pager.c                  |  12 +-
 tools/perf/util/sort.c                   | 436 ++++++++++++++++++++--
 tools/perf/util/sort.h                   |   6 +
 25 files changed, 1601 insertions(+), 386 deletions(-)
 create mode 100644 tools/perf/tests/hists_output.c

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 01/22] perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 02/22] perf tools: Convert sort entries to hpp formats Jiri Olsa
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Those function pointers will be used to sort report output based on
the selected fields.  This is a preparation of later change.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-2-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/hist.c   | 39 +++++++++++++++++++++++++++++++++++----
 tools/perf/util/hist.h |  3 +++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0912805..d4a4f2e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -192,6 +192,14 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,		\
 			  hpp_entry_scnprintf, true);				\
 }
 
+#define __HPP_SORT_FN(_type, _field)						\
+static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b)	\
+{										\
+	s64 __a = he_get_##_field(a);						\
+	s64 __b = he_get_##_field(b);						\
+	return __a - __b;							\
+}
+
 #define __HPP_ENTRY_RAW_FN(_type, _field)					\
 static u64 he_get_raw_##_field(struct hist_entry *he)				\
 {										\
@@ -206,16 +214,27 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,		\
 			  hpp_entry_scnprintf, false);				\
 }
 
+#define __HPP_SORT_RAW_FN(_type, _field)					\
+static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b)	\
+{										\
+	s64 __a = he_get_raw_##_field(a);					\
+	s64 __b = he_get_raw_##_field(b);					\
+	return __a - __b;							\
+}
+
+
 #define HPP_PERCENT_FNS(_type, _str, _field, _min_width, _unit_width)	\
 __HPP_HEADER_FN(_type, _str, _min_width, _unit_width)			\
 __HPP_WIDTH_FN(_type, _min_width, _unit_width)				\
 __HPP_COLOR_PERCENT_FN(_type, _field)					\
-__HPP_ENTRY_PERCENT_FN(_type, _field)
+__HPP_ENTRY_PERCENT_FN(_type, _field)					\
+__HPP_SORT_FN(_type, _field)
 
 #define HPP_RAW_FNS(_type, _str, _field, _min_width, _unit_width)	\
 __HPP_HEADER_FN(_type, _str, _min_width, _unit_width)			\
 __HPP_WIDTH_FN(_type, _min_width, _unit_width)				\
-__HPP_ENTRY_RAW_FN(_type, _field)
+__HPP_ENTRY_RAW_FN(_type, _field)					\
+__HPP_SORT_RAW_FN(_type, _field)
 
 
 HPP_PERCENT_FNS(overhead, "Overhead", period, 8, 8)
@@ -227,19 +246,31 @@ HPP_PERCENT_FNS(overhead_guest_us, "guest usr", period_guest_us, 9, 8)
 HPP_RAW_FNS(samples, "Samples", nr_events, 12, 12)
 HPP_RAW_FNS(period, "Period", period, 12, 12)
 
+static int64_t hpp__nop_cmp(struct hist_entry *a __maybe_unused,
+			    struct hist_entry *b __maybe_unused)
+{
+	return 0;
+}
+
 #define HPP__COLOR_PRINT_FNS(_name)			\
 	{						\
 		.header	= hpp__header_ ## _name,	\
 		.width	= hpp__width_ ## _name,		\
 		.color	= hpp__color_ ## _name,		\
-		.entry	= hpp__entry_ ## _name		\
+		.entry	= hpp__entry_ ## _name,		\
+		.cmp	= hpp__nop_cmp,			\
+		.collapse = hpp__nop_cmp,		\
+		.sort	= hpp__sort_ ## _name,		\
 	}
 
 #define HPP__PRINT_FNS(_name)				\
 	{						\
 		.header	= hpp__header_ ## _name,	\
 		.width	= hpp__width_ ## _name,		\
-		.entry	= hpp__entry_ ## _name		\
+		.entry	= hpp__entry_ ## _name,		\
+		.cmp	= hpp__nop_cmp,			\
+		.collapse = hpp__nop_cmp,		\
+		.sort	= hpp__sort_ ## _name,		\
 	}
 
 struct perf_hpp_fmt perf_hpp__format[] = {
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 38c3e87..36dbe00 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -160,6 +160,9 @@ struct perf_hpp_fmt {
 		     struct hist_entry *he);
 	int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 		     struct hist_entry *he);
+	int64_t (*cmp)(struct hist_entry *a, struct hist_entry *b);
+	int64_t (*collapse)(struct hist_entry *a, struct hist_entry *b);
+	int64_t (*sort)(struct hist_entry *a, struct hist_entry *b);
 
 	struct list_head list;
 };
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 02/22] perf tools: Convert sort entries to hpp formats
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
  2014-05-21 13:12 ` [PATCH 01/22] perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 03/22] perf tools: Use hpp formats to sort hist entries Jiri Olsa
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

This is a preparation of consolidating management of output field and
sort keys.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-3-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/hist.c   |  6 ++++
 tools/perf/util/hist.h |  6 ++++
 tools/perf/util/sort.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index d4a4f2e..a6eea66 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -284,6 +284,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
 };
 
 LIST_HEAD(perf_hpp__list);
+LIST_HEAD(perf_hpp__sort_list);
 
 
 #undef HPP__COLOR_PRINT_FNS
@@ -325,6 +326,11 @@ void perf_hpp__column_register(struct perf_hpp_fmt *format)
 	list_add_tail(&format->list, &perf_hpp__list);
 }
 
+void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
+{
+	list_add_tail(&format->sort_list, &perf_hpp__sort_list);
+}
+
 void perf_hpp__column_enable(unsigned col)
 {
 	BUG_ON(col >= PERF_HPP__MAX_INDEX);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 36dbe00..eee154a 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -165,13 +165,18 @@ struct perf_hpp_fmt {
 	int64_t (*sort)(struct hist_entry *a, struct hist_entry *b);
 
 	struct list_head list;
+	struct list_head sort_list;
 };
 
 extern struct list_head perf_hpp__list;
+extern struct list_head perf_hpp__sort_list;
 
 #define perf_hpp__for_each_format(format) \
 	list_for_each_entry(format, &perf_hpp__list, list)
 
+#define perf_hpp__for_each_sort_list(format) \
+	list_for_each_entry(format, &perf_hpp__sort_list, sort_list)
+
 extern struct perf_hpp_fmt perf_hpp__format[];
 
 enum {
@@ -190,6 +195,7 @@ enum {
 void perf_hpp__init(void);
 void perf_hpp__column_register(struct perf_hpp_fmt *format);
 void perf_hpp__column_enable(unsigned col);
+void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
 
 typedef u64 (*hpp_field_fn)(struct hist_entry *he);
 typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 635cd8f..b2829f9 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2,6 +2,7 @@
 #include "hist.h"
 #include "comm.h"
 #include "symbol.h"
+#include "evsel.h"
 
 regex_t		parent_regex;
 const char	default_parent_pattern[] = "^sys_|^do_page_fault";
@@ -1027,10 +1028,80 @@ static struct sort_dimension memory_sort_dimensions[] = {
 
 #undef DIM
 
-static void __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
+struct hpp_sort_entry {
+	struct perf_hpp_fmt hpp;
+	struct sort_entry *se;
+};
+
+static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
+			      struct perf_evsel *evsel)
+{
+	struct hpp_sort_entry *hse;
+	size_t len;
+
+	hse = container_of(fmt, struct hpp_sort_entry, hpp);
+	len = hists__col_len(&evsel->hists, hse->se->se_width_idx);
+
+	return scnprintf(hpp->buf, hpp->size, "%*s", len, hse->se->se_header);
+}
+
+static int __sort__hpp_width(struct perf_hpp_fmt *fmt,
+			     struct perf_hpp *hpp __maybe_unused,
+			     struct perf_evsel *evsel)
+{
+	struct hpp_sort_entry *hse;
+
+	hse = container_of(fmt, struct hpp_sort_entry, hpp);
+
+	return hists__col_len(&evsel->hists, hse->se->se_width_idx);
+}
+
+static int __sort__hpp_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
+			     struct hist_entry *he)
+{
+	struct hpp_sort_entry *hse;
+	size_t len;
+
+	hse = container_of(fmt, struct hpp_sort_entry, hpp);
+	len = hists__col_len(he->hists, hse->se->se_width_idx);
+
+	return hse->se->se_snprintf(he, hpp->buf, hpp->size, len);
+}
+
+static int __sort_dimension__add_hpp(struct sort_dimension *sd)
+{
+	struct hpp_sort_entry *hse;
+
+	hse = malloc(sizeof(*hse));
+	if (hse == NULL) {
+		pr_err("Memory allocation failed\n");
+		return -1;
+	}
+
+	hse->se = sd->entry;
+	hse->hpp.header = __sort__hpp_header;
+	hse->hpp.width = __sort__hpp_width;
+	hse->hpp.entry = __sort__hpp_entry;
+	hse->hpp.color = NULL;
+
+	hse->hpp.cmp = sd->entry->se_cmp;
+	hse->hpp.collapse = sd->entry->se_collapse ? : sd->entry->se_cmp;
+	hse->hpp.sort = hse->hpp.collapse;
+
+	INIT_LIST_HEAD(&hse->hpp.list);
+	INIT_LIST_HEAD(&hse->hpp.sort_list);
+
+	perf_hpp__register_sort_field(&hse->hpp);
+	return 0;
+}
+
+static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
 {
 	if (sd->taken)
-		return;
+		return 0;
+
+	if (__sort_dimension__add_hpp(sd) < 0)
+		return -1;
 
 	if (sd->entry->se_collapse)
 		sort__need_collapse = 1;
@@ -1040,6 +1111,8 @@ static void __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
 
 	list_add_tail(&sd->entry->list, &hist_entry__sort_list);
 	sd->taken = 1;
+
+	return 0;
 }
 
 int sort_dimension__add(const char *tok)
@@ -1068,8 +1141,7 @@ int sort_dimension__add(const char *tok)
 			sort__has_dso = 1;
 		}
 
-		__sort_dimension__add(sd, i);
-		return 0;
+		return __sort_dimension__add(sd, i);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 03/22] perf tools: Use hpp formats to sort hist entries
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
  2014-05-21 13:12 ` [PATCH 01/22] perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt Jiri Olsa
  2014-05-21 13:12 ` [PATCH 02/22] perf tools: Convert sort entries to hpp formats Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 04/22] perf tools: Support event grouping in hpp ->sort() Jiri Olsa
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

It wrapped sort entries to hpp functions, so using the hpp sort list
to sort entries.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-4-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/hist.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 7f0236c..38373c9 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -432,11 +432,11 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
 int64_t
 hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	struct sort_entry *se;
+	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		cmp = se->se_cmp(left, right);
+	perf_hpp__for_each_sort_list(fmt) {
+		cmp = fmt->cmp(left, right);
 		if (cmp)
 			break;
 	}
@@ -447,15 +447,11 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 int64_t
 hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
 {
-	struct sort_entry *se;
+	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		int64_t (*f)(struct hist_entry *, struct hist_entry *);
-
-		f = se->se_collapse ?: se->se_cmp;
-
-		cmp = f(left, right);
+	perf_hpp__for_each_sort_list(fmt) {
+		cmp = fmt->collapse(left, right);
 		if (cmp)
 			break;
 	}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 04/22] perf tools: Support event grouping in hpp ->sort()
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (2 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 03/22] perf tools: Use hpp formats to sort hist entries Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 05/22] perf tools: Use hpp formats to sort final output Jiri Olsa
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Move logic of hist_entry__sort_on_period to __hpp__sort() in order to
support event group report.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-5-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/hist.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 58 insertions(+), 6 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index a6eea66..0299385 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -116,6 +116,62 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
 	return ret;
 }
 
+static int field_cmp(u64 field_a, u64 field_b)
+{
+	if (field_a > field_b)
+		return 1;
+	if (field_a < field_b)
+		return -1;
+	return 0;
+}
+
+static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,
+		       hpp_field_fn get_field)
+{
+	s64 ret;
+	int i, nr_members;
+	struct perf_evsel *evsel;
+	struct hist_entry *pair;
+	u64 *fields_a, *fields_b;
+
+	ret = field_cmp(get_field(a), get_field(b));
+	if (ret || !symbol_conf.event_group)
+		return ret;
+
+	evsel = hists_to_evsel(a->hists);
+	if (!perf_evsel__is_group_event(evsel))
+		return ret;
+
+	nr_members = evsel->nr_members;
+	fields_a = calloc(sizeof(*fields_a), nr_members);
+	fields_b = calloc(sizeof(*fields_b), nr_members);
+
+	if (!fields_a || !fields_b)
+		goto out;
+
+	list_for_each_entry(pair, &a->pairs.head, pairs.node) {
+		evsel = hists_to_evsel(pair->hists);
+		fields_a[perf_evsel__group_idx(evsel)] = get_field(pair);
+	}
+
+	list_for_each_entry(pair, &b->pairs.head, pairs.node) {
+		evsel = hists_to_evsel(pair->hists);
+		fields_b[perf_evsel__group_idx(evsel)] = get_field(pair);
+	}
+
+	for (i = 1; i < nr_members; i++) {
+		ret = field_cmp(fields_a[i], fields_b[i]);
+		if (ret)
+			break;
+	}
+
+out:
+	free(fields_a);
+	free(fields_b);
+
+	return ret;
+}
+
 #define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) 		\
 static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused,	\
 			       struct perf_hpp *hpp,			\
@@ -195,9 +251,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,		\
 #define __HPP_SORT_FN(_type, _field)						\
 static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b)	\
 {										\
-	s64 __a = he_get_##_field(a);						\
-	s64 __b = he_get_##_field(b);						\
-	return __a - __b;							\
+	return __hpp__sort(a, b, he_get_##_field);				\
 }
 
 #define __HPP_ENTRY_RAW_FN(_type, _field)					\
@@ -217,9 +271,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,		\
 #define __HPP_SORT_RAW_FN(_type, _field)					\
 static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b)	\
 {										\
-	s64 __a = he_get_raw_##_field(a);					\
-	s64 __b = he_get_raw_##_field(b);					\
-	return __a - __b;							\
+	return __hpp__sort(a, b, he_get_raw_##_field);				\
 }
 
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 05/22] perf tools: Use hpp formats to sort final output
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (3 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 04/22] perf tools: Support event grouping in hpp ->sort() Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 06/22] perf tools: Consolidate output field handling to hpp format routines Jiri Olsa
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Convert output sorting function to use ->sort hpp functions.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-6-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/hist.c | 62 +++++++-------------------------------------------
 1 file changed, 8 insertions(+), 54 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 38373c9..c99ae4d 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -564,64 +564,18 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
 	}
 }
 
-/*
- * reverse the map, sort on period.
- */
-
-static int period_cmp(u64 period_a, u64 period_b)
+static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
 {
-	if (period_a > period_b)
-		return 1;
-	if (period_a < period_b)
-		return -1;
-	return 0;
-}
-
-static int hist_entry__sort_on_period(struct hist_entry *a,
-				      struct hist_entry *b)
-{
-	int ret;
-	int i, nr_members;
-	struct perf_evsel *evsel;
-	struct hist_entry *pair;
-	u64 *periods_a, *periods_b;
-
-	ret = period_cmp(a->stat.period, b->stat.period);
-	if (ret || !symbol_conf.event_group)
-		return ret;
-
-	evsel = hists_to_evsel(a->hists);
-	nr_members = evsel->nr_members;
-	if (nr_members <= 1)
-		return ret;
-
-	periods_a = zalloc(sizeof(periods_a) * nr_members);
-	periods_b = zalloc(sizeof(periods_b) * nr_members);
-
-	if (!periods_a || !periods_b)
-		goto out;
-
-	list_for_each_entry(pair, &a->pairs.head, pairs.node) {
-		evsel = hists_to_evsel(pair->hists);
-		periods_a[perf_evsel__group_idx(evsel)] = pair->stat.period;
-	}
-
-	list_for_each_entry(pair, &b->pairs.head, pairs.node) {
-		evsel = hists_to_evsel(pair->hists);
-		periods_b[perf_evsel__group_idx(evsel)] = pair->stat.period;
-	}
+	struct perf_hpp_fmt *fmt;
+	int64_t cmp = 0;
 
-	for (i = 1; i < nr_members; i++) {
-		ret = period_cmp(periods_a[i], periods_b[i]);
-		if (ret)
+	perf_hpp__for_each_format(fmt) {
+		cmp = fmt->sort(a, b);
+		if (cmp)
 			break;
 	}
 
-out:
-	free(periods_a);
-	free(periods_b);
-
-	return ret;
+	return cmp;
 }
 
 static void hists__reset_filter_stats(struct hists *hists)
@@ -669,7 +623,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
 		parent = *p;
 		iter = rb_entry(parent, struct hist_entry, rb_node);
 
-		if (hist_entry__sort_on_period(he, iter) > 0)
+		if (hist_entry__sort(he, iter) > 0)
 			p = &(*p)->rb_left;
 		else
 			p = &(*p)->rb_right;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 06/22] perf tools: Consolidate output field handling to hpp format routines
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (4 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 05/22] perf tools: Use hpp formats to sort final output Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 07/22] perf ui: Get rid of callback from __hpp__fmt() Jiri Olsa
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Until now the hpp and sort functions do similar jobs different ways.
Since the sort functions converted/wrapped to hpp formats it can do
the job in a uniform way.

The perf_hpp__sort_list has a list of hpp formats to sort entries and
the perf_hpp__list has a list of hpp formats to print output result.

To have a backward compatibility, it automatically adds 'overhead'
field in front of sort list.  And then all of fields in sort list
added to the output list (if it's not already there).

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/n/tip-7g3h86woz2sckg3h1lj42ygj@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 31 ++++++++++++++----------
 tools/perf/ui/gtk/hists.c      | 31 ------------------------
 tools/perf/ui/hist.c           | 26 ++++++++++++++++++++
 tools/perf/ui/stdio/hist.c     | 55 +++++++++++++-----------------------------
 tools/perf/util/hist.c         |  2 +-
 tools/perf/util/hist.h         |  1 +
 6 files changed, 63 insertions(+), 83 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index b0861e3..847de11 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -760,8 +760,8 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 		if (!browser->b.navkeypressed)
 			width += 1;
 
-		hist_entry__sort_snprintf(entry, s, sizeof(s), browser->hists);
-		slsmg_write_nstring(s, width);
+		slsmg_write_nstring("", width);
+
 		++row;
 		++printed;
 	} else
@@ -1104,27 +1104,32 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
 				       struct hist_entry *he, FILE *fp)
 {
 	char s[8192];
-	double percent;
 	int printed = 0;
 	char folded_sign = ' ';
+	struct perf_hpp hpp = {
+		.buf = s,
+		.size = sizeof(s),
+	};
+	struct perf_hpp_fmt *fmt;
+	bool first = true;
+	int ret;
 
 	if (symbol_conf.use_callchain)
 		folded_sign = hist_entry__folded(he);
 
-	hist_entry__sort_snprintf(he, s, sizeof(s), browser->hists);
-	percent = (he->stat.period * 100.0) / browser->hists->stats.total_period;
-
 	if (symbol_conf.use_callchain)
 		printed += fprintf(fp, "%c ", folded_sign);
 
-	printed += fprintf(fp, " %5.2f%%", percent);
-
-	if (symbol_conf.show_nr_samples)
-		printed += fprintf(fp, " %11u", he->stat.nr_events);
-
-	if (symbol_conf.show_total_period)
-		printed += fprintf(fp, " %12" PRIu64, he->stat.period);
+	perf_hpp__for_each_format(fmt) {
+		if (!first) {
+			ret = scnprintf(hpp.buf, hpp.size, "  ");
+			advance_hpp(&hpp, ret);
+		} else
+			first = false;
 
+		ret = fmt->entry(fmt, &hpp, he);
+		advance_hpp(&hpp, ret);
+	}
 	printed += fprintf(fp, "%s\n", rtrim(s));
 
 	if (folded_sign == '-')
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 91f10f3..d5c336e 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -153,7 +153,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 	struct perf_hpp_fmt *fmt;
 	GType col_types[MAX_COLUMNS];
 	GtkCellRenderer *renderer;
-	struct sort_entry *se;
 	GtkTreeStore *store;
 	struct rb_node *nd;
 	GtkWidget *view;
@@ -172,16 +171,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 	perf_hpp__for_each_format(fmt)
 		col_types[nr_cols++] = G_TYPE_STRING;
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		if (se->elide)
-			continue;
-
-		if (se == &sort_sym)
-			sym_col = nr_cols;
-
-		col_types[nr_cols++] = G_TYPE_STRING;
-	}
-
 	store = gtk_tree_store_newv(nr_cols, col_types);
 
 	view = gtk_tree_view_new();
@@ -199,16 +188,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 							    col_idx++, NULL);
 	}
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		if (se->elide)
-			continue;
-
-		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-							    -1, se->se_header,
-							    renderer, "text",
-							    col_idx++, NULL);
-	}
-
 	for (col_idx = 0; col_idx < nr_cols; col_idx++) {
 		GtkTreeViewColumn *column;
 
@@ -253,16 +232,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 			gtk_tree_store_set(store, &iter, col_idx++, s, -1);
 		}
 
-		list_for_each_entry(se, &hist_entry__sort_list, list) {
-			if (se->elide)
-				continue;
-
-			se->se_snprintf(h, s, ARRAY_SIZE(s),
-					hists__col_len(hists, se->se_width_idx));
-
-			gtk_tree_store_set(store, &iter, col_idx++, s, -1);
-		}
-
 		if (symbol_conf.use_callchain && sort__has_sym) {
 			if (callchain_param.mode == CHAIN_GRAPH_REL)
 				total = h->stat.period;
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0299385..400437e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -354,6 +354,14 @@ LIST_HEAD(perf_hpp__sort_list);
 
 void perf_hpp__init(void)
 {
+	struct list_head *list;
+	int i;
+
+	for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
+		INIT_LIST_HEAD(&perf_hpp__format[i].list);
+		INIT_LIST_HEAD(&perf_hpp__format[i].sort_list);
+	}
+
 	perf_hpp__column_enable(PERF_HPP__OVERHEAD);
 
 	if (symbol_conf.show_cpu_utilization) {
@@ -371,6 +379,13 @@ void perf_hpp__init(void)
 
 	if (symbol_conf.show_total_period)
 		perf_hpp__column_enable(PERF_HPP__PERIOD);
+
+	/* prepend overhead field for backward compatiblity.  */
+	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
+	if (list_empty(list))
+		list_add(list, &perf_hpp__sort_list);
+
+	perf_hpp__setup_output_field();
 }
 
 void perf_hpp__column_register(struct perf_hpp_fmt *format)
@@ -389,6 +404,17 @@ void perf_hpp__column_enable(unsigned col)
 	perf_hpp__column_register(&perf_hpp__format[col]);
 }
 
+void perf_hpp__setup_output_field(void)
+{
+	struct perf_hpp_fmt *fmt;
+
+	/* append sort keys to output field */
+	perf_hpp__for_each_sort_list(fmt) {
+		if (list_empty(&fmt->list))
+			perf_hpp__column_register(fmt);
+	}
+}
+
 int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
 			      struct hists *hists)
 {
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 9eccf7f..49e2e4a 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -306,8 +306,7 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
 	return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
 }
 
-static int hist_entry__period_snprintf(struct perf_hpp *hpp,
-				       struct hist_entry *he)
+static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
 {
 	const char *sep = symbol_conf.field_sep;
 	struct perf_hpp_fmt *fmt;
@@ -353,8 +352,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
 	if (size == 0 || size > bfsz)
 		size = hpp.size = bfsz;
 
-	ret = hist_entry__period_snprintf(&hpp, he);
-	hist_entry__sort_snprintf(he, bf + ret, size - ret, hists);
+	hist_entry__snprintf(he, &hpp);
 
 	ret = fprintf(fp, "%s\n", bf);
 
@@ -386,28 +384,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	init_rem_hits();
 
-	if (!show_header)
-		goto print_entries;
-
-	fprintf(fp, "# ");
-
-	perf_hpp__for_each_format(fmt) {
-		if (!first)
-			fprintf(fp, "%s", sep ?: "  ");
-		else
-			first = false;
-
-		fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
-		fprintf(fp, "%s", bf);
-	}
-
 	list_for_each_entry(se, &hist_entry__sort_list, list) {
 		if (se->elide)
 			continue;
-		if (sep) {
-			fprintf(fp, "%c%s", *sep, se->se_header);
-			continue;
-		}
 		width = strlen(se->se_header);
 		if (symbol_conf.col_width_list_str) {
 			if (col_width) {
@@ -420,7 +399,21 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 		}
 		if (!hists__new_col_len(hists, se->se_width_idx, width))
 			width = hists__col_len(hists, se->se_width_idx);
-		fprintf(fp, "  %*s", width, se->se_header);
+	}
+
+	if (!show_header)
+		goto print_entries;
+
+	fprintf(fp, "# ");
+
+	perf_hpp__for_each_format(fmt) {
+		if (!first)
+			fprintf(fp, "%s", sep ?: "  ");
+		else
+			first = false;
+
+		fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
+		fprintf(fp, "%s", bf);
 	}
 
 	fprintf(fp, "\n");
@@ -447,20 +440,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 			fprintf(fp, ".");
 	}
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		unsigned int i;
-
-		if (se->elide)
-			continue;
-
-		fprintf(fp, "  ");
-		width = hists__col_len(hists, se->se_width_idx);
-		if (width == 0)
-			width = strlen(se->se_header);
-		for (i = 0; i < width; i++)
-			fprintf(fp, ".");
-	}
-
 	fprintf(fp, "\n");
 	if (max_rows && ++nr_rows >= max_rows)
 		goto out;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c99ae4d..ae13c2d 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -569,7 +569,7 @@ static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp__for_each_sort_list(fmt) {
 		cmp = fmt->sort(a, b);
 		if (cmp)
 			break;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index eee154a..e76d323 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -196,6 +196,7 @@ void perf_hpp__init(void);
 void perf_hpp__column_register(struct perf_hpp_fmt *format);
 void perf_hpp__column_enable(unsigned col);
 void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
+void perf_hpp__setup_output_field(void);
 
 typedef u64 (*hpp_field_fn)(struct hist_entry *he);
 typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 07/22] perf ui: Get rid of callback from __hpp__fmt()
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (5 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 06/22] perf tools: Consolidate output field handling to hpp format routines Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 08/22] perf tools: Allow hpp fields to be sort keys Jiri Olsa
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

The callback was used by TUI for determining color of folded sign
using percent of first field/column. But it cannot be used anymore
since it now support dynamic reordering of output field.

So move the logic to the hist_browser__show_entry().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-8-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 62 ++++++++++++++++--------------------------
 tools/perf/ui/gtk/hists.c      |  2 +-
 tools/perf/ui/hist.c           | 28 ++++++-------------
 tools/perf/util/hist.h         |  4 +--
 4 files changed, 34 insertions(+), 62 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 847de11..37c5188 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -616,35 +616,6 @@ struct hpp_arg {
 	bool current_entry;
 };
 
-static int __hpp__overhead_callback(struct perf_hpp *hpp, bool front)
-{
-	struct hpp_arg *arg = hpp->ptr;
-
-	if (arg->current_entry && arg->b->navkeypressed)
-		ui_browser__set_color(arg->b, HE_COLORSET_SELECTED);
-	else
-		ui_browser__set_color(arg->b, HE_COLORSET_NORMAL);
-
-	if (front) {
-		if (!symbol_conf.use_callchain)
-			return 0;
-
-		slsmg_printf("%c ", arg->folded_sign);
-		return 2;
-	}
-
-	return 0;
-}
-
-static int __hpp__color_callback(struct perf_hpp *hpp, bool front __maybe_unused)
-{
-	struct hpp_arg *arg = hpp->ptr;
-
-	if (!arg->current_entry || !arg->b->navkeypressed)
-		ui_browser__set_color(arg->b, HE_COLORSET_NORMAL);
-	return 0;
-}
-
 static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...)
 {
 	struct hpp_arg *arg = hpp->ptr;
@@ -665,7 +636,7 @@ static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...)
 	return ret;
 }
 
-#define __HPP_COLOR_PERCENT_FN(_type, _field, _cb)			\
+#define __HPP_COLOR_PERCENT_FN(_type, _field)				\
 static u64 __hpp_get_##_field(struct hist_entry *he)			\
 {									\
 	return he->stat._field;						\
@@ -676,15 +647,15 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\
 				struct perf_hpp *hpp,			\
 				struct hist_entry *he)			\
 {									\
-	return __hpp__fmt(hpp, he, __hpp_get_##_field, _cb, " %6.2f%%",	\
+	return __hpp__fmt(hpp, he, __hpp_get_##_field, " %6.2f%%",	\
 			  __hpp__slsmg_color_printf, true);		\
 }
 
-__HPP_COLOR_PERCENT_FN(overhead, period, __hpp__overhead_callback)
-__HPP_COLOR_PERCENT_FN(overhead_sys, period_sys, __hpp__color_callback)
-__HPP_COLOR_PERCENT_FN(overhead_us, period_us, __hpp__color_callback)
-__HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys, __hpp__color_callback)
-__HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us, __hpp__color_callback)
+__HPP_COLOR_PERCENT_FN(overhead, period)
+__HPP_COLOR_PERCENT_FN(overhead_sys, period_sys)
+__HPP_COLOR_PERCENT_FN(overhead_us, period_us)
+__HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys)
+__HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us)
 
 #undef __HPP_COLOR_PERCENT_FN
 
@@ -729,7 +700,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 
 	if (row_offset == 0) {
 		struct hpp_arg arg = {
-			.b 		= &browser->b,
+			.b		= &browser->b,
 			.folded_sign	= folded_sign,
 			.current_entry	= current_entry,
 		};
@@ -742,11 +713,24 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 		ui_browser__gotorc(&browser->b, row, 0);
 
 		perf_hpp__for_each_format(fmt) {
-			if (!first) {
+			if (current_entry && browser->b.navkeypressed) {
+				ui_browser__set_color(&browser->b,
+						      HE_COLORSET_SELECTED);
+			} else {
+				ui_browser__set_color(&browser->b,
+						      HE_COLORSET_NORMAL);
+			}
+
+			if (first) {
+				if (symbol_conf.use_callchain) {
+					slsmg_printf("%c ", folded_sign);
+					width -= 2;
+				}
+				first = false;
+			} else {
 				slsmg_printf("  ");
 				width -= 2;
 			}
-			first = false;
 
 			if (fmt->color) {
 				width -= fmt->color(fmt, &hpp, entry);
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index d5c336e..2237245 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -43,7 +43,7 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,
 				       struct perf_hpp *hpp,			\
 				       struct hist_entry *he)			\
 {										\
-	return __hpp__fmt(hpp, he, he_get_##_field, NULL, " %6.2f%%",		\
+	return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%",			\
 			  __percent_color_snprintf, true);			\
 }
 
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 400437e..e7ac794 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -16,20 +16,15 @@
 })
 
 int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
-	       hpp_field_fn get_field, hpp_callback_fn callback,
-	       const char *fmt, hpp_snprint_fn print_fn, bool fmt_percent)
+	       hpp_field_fn get_field, const char *fmt,
+	       hpp_snprint_fn print_fn, bool fmt_percent)
 {
-	int ret = 0;
+	int ret;
 	struct hists *hists = he->hists;
 	struct perf_evsel *evsel = hists_to_evsel(hists);
 	char *buf = hpp->buf;
 	size_t size = hpp->size;
 
-	if (callback) {
-		ret = callback(hpp, true);
-		advance_hpp(hpp, ret);
-	}
-
 	if (fmt_percent) {
 		double percent = 0.0;
 		u64 total = hists__total_period(hists);
@@ -37,9 +32,9 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
 		if (total)
 			percent = 100.0 * get_field(he) / total;
 
-		ret += hpp__call_print_fn(hpp, print_fn, fmt, percent);
+		ret = hpp__call_print_fn(hpp, print_fn, fmt, percent);
 	} else
-		ret += hpp__call_print_fn(hpp, print_fn, fmt, get_field(he));
+		ret = hpp__call_print_fn(hpp, print_fn, fmt, get_field(he));
 
 	if (perf_evsel__is_group_event(evsel)) {
 		int prev_idx, idx_delta;
@@ -99,13 +94,6 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
 		}
 	}
 
-	if (callback) {
-		int __ret = callback(hpp, false);
-
-		advance_hpp(hpp, __ret);
-		ret += __ret;
-	}
-
 	/*
 	 * Restore original buf and size as it's where caller expects
 	 * the result will be saved.
@@ -235,7 +223,7 @@ static u64 he_get_##_field(struct hist_entry *he)				\
 static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,		\
 			      struct perf_hpp *hpp, struct hist_entry *he) 	\
 {										\
-	return __hpp__fmt(hpp, he, he_get_##_field, NULL, " %6.2f%%",		\
+	return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%",			\
 			  hpp_color_scnprintf, true);				\
 }
 
@@ -244,7 +232,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,		\
 			      struct perf_hpp *hpp, struct hist_entry *he) 	\
 {										\
 	const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%";		\
-	return __hpp__fmt(hpp, he, he_get_##_field, NULL, fmt,			\
+	return __hpp__fmt(hpp, he, he_get_##_field, fmt,			\
 			  hpp_entry_scnprintf, true);				\
 }
 
@@ -264,7 +252,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused,		\
 			      struct perf_hpp *hpp, struct hist_entry *he) 	\
 {										\
 	const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64;	\
-	return __hpp__fmt(hpp, he, he_get_raw_##_field, NULL, fmt,		\
+	return __hpp__fmt(hpp, he, he_get_raw_##_field, fmt,			\
 			  hpp_entry_scnprintf, false);				\
 }
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e76d323..76bb72e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -203,8 +203,8 @@ typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
 typedef int (*hpp_snprint_fn)(struct perf_hpp *hpp, const char *fmt, ...);
 
 int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
-	       hpp_field_fn get_field, hpp_callback_fn callback,
-	       const char *fmt, hpp_snprint_fn print_fn, bool fmt_percent);
+	       hpp_field_fn get_field, const char *fmt,
+	       hpp_snprint_fn print_fn, bool fmt_percent);
 
 static inline void advance_hpp(struct perf_hpp *hpp, int inc)
 {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 08/22] perf tools: Allow hpp fields to be sort keys
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (6 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 07/22] perf ui: Get rid of callback from __hpp__fmt() Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 09/22] perf tools: Consolidate management of default sort orders Jiri Olsa
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Add overhead{,_sys,_us,_guest_sys,_guest_us}, sample and period sort
keys so that they can be selected with --sort/-s option.

  $ perf report -s period,comm --stdio
  ...
  # Overhead        Period          Command
  # ........  ............  ...............
  #
      47.06%           152          swapper
      13.93%            45  qemu-system-arm
      12.38%            40         synergys
       3.72%            12          firefox
       2.48%             8            xchat

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-9-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Documentation/perf-diff.txt   |  5 ++--
 tools/perf/Documentation/perf-report.txt |  9 ++++++++
 tools/perf/Documentation/perf-top.txt    |  5 ++--
 tools/perf/builtin-diff.c                |  3 ++-
 tools/perf/builtin-report.c              |  6 ++---
 tools/perf/builtin-top.c                 |  4 ++--
 tools/perf/ui/hist.c                     |  9 ++++++--
 tools/perf/util/sort.c                   | 39 ++++++++++++++++++++++++++++++++
 8 files changed, 67 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index fbfa119..b3b8aba 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -50,7 +50,8 @@ OPTIONS
 
 -s::
 --sort=::
-	Sort by key(s): pid, comm, dso, symbol.
+	Sort by key(s): pid, comm, dso, symbol, cpu, parent, srcline.
+	Please see description of --sort in the perf-report man page.
 
 -t::
 --field-separator=::
@@ -202,4 +203,4 @@ If specified the 'Weighted diff' column is displayed with value 'd' computed as:
 
 SEE ALSO
 --------
-linkperf:perf-record[1]
+linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 09af662..9babe91 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -79,6 +79,15 @@ OPTIONS
 	abort cost. This is the global weight.
 	- local_weight: Local weight version of the weight above.
 	- transaction: Transaction abort flags.
+	- overhead: Overhead percentage of sample
+	- overhead_sys: Overhead percentage of sample running in system mode
+	- overhead_us: Overhead percentage of sample running in user mode
+	- overhead_guest_sys: Overhead percentage of sample running in system mode
+	on guest machine
+	- overhead_guest_us: Overhead percentage of sample running in user mode on
+	guest machine
+	- sample: Number of sample
+	- period: Raw number of event count of sample
 
 	By default, comm, dso and symbol keys are used.
 	(i.e. --sort comm,dso,symbol)
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 64ed79c..df86328 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -113,7 +113,8 @@ Default is to monitor all CPUS.
 -s::
 --sort::
 	Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight,
-	local_weight, abort, in_tx, transaction
+	local_weight, abort, in_tx, transaction, overhead, sample, period.
+	Please see description of --sort in the perf-report man page.
 
 -n::
 --show-nr-samples::
@@ -212,4 +213,4 @@ Pressing any unmapped key displays a menu, and prompts for input.
 
 SEE ALSO
 --------
-linkperf:perf-stat[1], linkperf:perf-list[1]
+linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-report[1]
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index f3b10dc..b60c711 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -741,7 +741,8 @@ static const struct option options[] = {
 	OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
 		   "only consider these symbols"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
-		   "sort by key(s): pid, comm, dso, symbol, parent"),
+		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
+		   " Please refer the man page for the complete list."),
 	OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
 		   "separator for columns, no spaces will be added between "
 		   "columns '.' is reserved."),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 89c9528..d0180d5 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -699,10 +699,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN(0, "header-only", &report.header_only,
 		    "Show only data header."),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
-		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline,"
-		   " dso_to, dso_from, symbol_to, symbol_from, mispredict,"
-		   " weight, local_weight, mem, symbol_daddr, dso_daddr, tlb, "
-		   "snoop, locked, abort, in_tx, transaction"),
+		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
+		   " Please refer the man page for the complete list."),
 	OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
 		    "Show sample percentage for different cpu modes"),
 	OPT_STRING('p', "parent", &parent_pattern, "regex",
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 37d3046..4fef1e4 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1083,8 +1083,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show counter open errors, etc)"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
-		   "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight,"
-		   " abort, in_tx, transaction"),
+		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
+		   " Please refer the man page for the complete list."),
 	OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
 		    "Show a column with the number of samples"),
 	OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index e7ac794..24116a4 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -346,8 +346,13 @@ void perf_hpp__init(void)
 	int i;
 
 	for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
-		INIT_LIST_HEAD(&perf_hpp__format[i].list);
-		INIT_LIST_HEAD(&perf_hpp__format[i].sort_list);
+		struct perf_hpp_fmt *fmt = &perf_hpp__format[i];
+
+		INIT_LIST_HEAD(&fmt->list);
+
+		/* sort_list may be linked by setup_sorting() */
+		if (fmt->sort_list.next == NULL)
+			INIT_LIST_HEAD(&fmt->sort_list);
 	}
 
 	perf_hpp__column_enable(PERF_HPP__OVERHEAD);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b2829f9..916652a 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1028,6 +1028,26 @@ static struct sort_dimension memory_sort_dimensions[] = {
 
 #undef DIM
 
+struct hpp_dimension {
+	const char		*name;
+	struct perf_hpp_fmt	*fmt;
+	int			taken;
+};
+
+#define DIM(d, n) { .name = n, .fmt = &perf_hpp__format[d], }
+
+static struct hpp_dimension hpp_sort_dimensions[] = {
+	DIM(PERF_HPP__OVERHEAD, "overhead"),
+	DIM(PERF_HPP__OVERHEAD_SYS, "overhead_sys"),
+	DIM(PERF_HPP__OVERHEAD_US, "overhead_us"),
+	DIM(PERF_HPP__OVERHEAD_GUEST_SYS, "overhead_guest_sys"),
+	DIM(PERF_HPP__OVERHEAD_GUEST_US, "overhead_guest_us"),
+	DIM(PERF_HPP__SAMPLES, "sample"),
+	DIM(PERF_HPP__PERIOD, "period"),
+};
+
+#undef DIM
+
 struct hpp_sort_entry {
 	struct perf_hpp_fmt hpp;
 	struct sort_entry *se;
@@ -1115,6 +1135,16 @@ static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
 	return 0;
 }
 
+static int __hpp_dimension__add(struct hpp_dimension *hd)
+{
+	if (!hd->taken) {
+		hd->taken = 1;
+
+		perf_hpp__register_sort_field(hd->fmt);
+	}
+	return 0;
+}
+
 int sort_dimension__add(const char *tok)
 {
 	unsigned int i;
@@ -1144,6 +1174,15 @@ int sort_dimension__add(const char *tok)
 		return __sort_dimension__add(sd, i);
 	}
 
+	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
+		struct hpp_dimension *hd = &hpp_sort_dimensions[i];
+
+		if (strncasecmp(tok, hd->name, strlen(tok)))
+			continue;
+
+		return __hpp_dimension__add(hd);
+	}
+
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
 		struct sort_dimension *sd = &bstack_sort_dimensions[i];
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 09/22] perf tools: Consolidate management of default sort orders
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (7 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 08/22] perf tools: Allow hpp fields to be sort keys Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 10/22] perf tools: Call perf_hpp__init() before setting up GUI browsers Jiri Olsa
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Stephane Eranian, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

The perf uses different default sort orders for different use-cases,
and this was scattered throughout the code.  Add get_default_sort_
order() function to handle this and change initial value of sort_order
to NULL to distinguish it from user-given one.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1400480762-22852-10-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-diff.c   |  4 ++--
 tools/perf/builtin-report.c | 18 ------------------
 tools/perf/builtin-top.c    |  3 +--
 tools/perf/util/sort.c      | 28 ++++++++++++++++++++++++++--
 tools/perf/util/sort.h      |  2 ++
 5 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index b60c711..8bff543 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -60,7 +60,6 @@ static int data__files_cnt;
 #define data__for_each_file(i, d) data__for_each_file_start(i, d, 0)
 #define data__for_each_file_new(i, d) data__for_each_file_start(i, d, 1)
 
-static char diff__default_sort_order[] = "dso,symbol";
 static bool force;
 static bool show_period;
 static bool show_formula;
@@ -1142,7 +1141,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	perf_config(perf_default_config, NULL);
 
-	sort_order = diff__default_sort_order;
 	argc = parse_options(argc, argv, options, diff_usage, 0);
 
 	if (symbol__init() < 0)
@@ -1153,6 +1151,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	ui_init();
 
+	sort__mode = SORT_MODE__DIFF;
+
 	if (setup_sorting() < 0)
 		usage_with_options(diff_usage, options);
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d0180d5..f4d640cf 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -805,30 +805,12 @@ repeat:
 	if (branch_mode == -1 && has_br_stack)
 		sort__mode = SORT_MODE__BRANCH;
 
-	/* sort__mode could be NORMAL if --no-branch-stack */
-	if (sort__mode == SORT_MODE__BRANCH) {
-		/*
-		 * if no sort_order is provided, then specify
-		 * branch-mode specific order
-		 */
-		if (sort_order == default_sort_order)
-			sort_order = "comm,dso_from,symbol_from,"
-				     "dso_to,symbol_to";
-
-	}
 	if (report.mem_mode) {
 		if (sort__mode == SORT_MODE__BRANCH) {
 			pr_err("branch and mem mode incompatible\n");
 			goto error;
 		}
 		sort__mode = SORT_MODE__MEMORY;
-
-		/*
-		 * if no sort_order is provided, then specify
-		 * branch-mode specific order
-		 */
-		if (sort_order == default_sort_order)
-			sort_order = "local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked";
 	}
 
 	if (setup_sorting() < 0) {
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 4fef1e4..34764b6 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1137,8 +1137,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (argc)
 		usage_with_options(top_usage, options);
 
-	if (sort_order == default_sort_order)
-		sort_order = "dso,symbol";
+	sort__mode = SORT_MODE__TOP;
 
 	if (setup_sorting() < 0) {
 		parse_options_usage(top_usage, options, "s", 1);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 916652a..d64c1e5 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -8,7 +8,11 @@ regex_t		parent_regex;
 const char	default_parent_pattern[] = "^sys_|^do_page_fault";
 const char	*parent_pattern = default_parent_pattern;
 const char	default_sort_order[] = "comm,dso,symbol";
-const char	*sort_order = default_sort_order;
+const char	default_branch_sort_order[] = "comm,dso_from,symbol_from,dso_to,symbol_to";
+const char	default_mem_sort_order[] = "local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked";
+const char	default_top_sort_order[] = "dso,symbol";
+const char	default_diff_sort_order[] = "dso,symbol";
+const char	*sort_order;
 regex_t		ignore_callees_regex;
 int		have_ignore_callees = 0;
 int		sort__need_collapse = 0;
@@ -1218,11 +1222,31 @@ int sort_dimension__add(const char *tok)
 	return -ESRCH;
 }
 
+static const char *get_default_sort_order(void)
+{
+	const char *default_sort_orders[] = {
+		default_sort_order,
+		default_branch_sort_order,
+		default_mem_sort_order,
+		default_top_sort_order,
+		default_diff_sort_order,
+	};
+
+	BUG_ON(sort__mode >= ARRAY_SIZE(default_sort_orders));
+
+	return default_sort_orders[sort__mode];
+}
+
 int setup_sorting(void)
 {
-	char *tmp, *tok, *str = strdup(sort_order);
+	char *tmp, *tok, *str;
+	const char *sort_keys = sort_order;
 	int ret = 0;
 
+	if (sort_keys == NULL)
+		sort_keys = get_default_sort_order();
+
+	str = strdup(sort_keys);
 	if (str == NULL) {
 		error("Not enough memory to setup sort keys");
 		return -ENOMEM;
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 43e5ff4..1a72952 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -133,6 +133,8 @@ enum sort_mode {
 	SORT_MODE__NORMAL,
 	SORT_MODE__BRANCH,
 	SORT_MODE__MEMORY,
+	SORT_MODE__TOP,
+	SORT_MODE__DIFF,
 };
 
 enum sort_type {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 10/22] perf tools: Call perf_hpp__init() before setting up GUI browsers
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (8 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 09/22] perf tools: Consolidate management of default sort orders Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 11/22] perf report: Add -F option to specify output fields Jiri Olsa
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

So that it can be set properly prior to set up output fields.  That
makes easy to handle/warn errors during the setup since it doesn't
need to be bothered with the GUI.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-11-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-report.c    | 6 +++---
 tools/perf/builtin-top.c       | 2 ++
 tools/perf/ui/browsers/hists.c | 2 --
 tools/perf/ui/gtk/hists.c      | 2 --
 tools/perf/ui/setup.c          | 2 --
 5 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index f4d640cf..c4dab7a 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -823,16 +823,16 @@ repeat:
 			goto error;
 	}
 
+	perf_hpp__init();
+
 	/* Force tty output for header output. */
 	if (report.header || report.header_only)
 		use_browser = 0;
 
 	if (strcmp(input_name, "-") != 0)
 		setup_browser(true);
-	else {
+	else
 		use_browser = 0;
-		perf_hpp__init();
-	}
 
 	if (report.header || report.header_only) {
 		perf_session__fprintf_info(session, stdout,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 34764b6..280945b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1147,6 +1147,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	/* display thread wants entries to be collapsed in a different tree */
 	sort__need_collapse = 1;
 
+	perf_hpp__init();
+
 	if (top.use_stdio)
 		use_browser = 0;
 	else if (top.use_tui)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 37c5188..92d128f 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -661,8 +661,6 @@ __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us)
 
 void hist_browser__init_hpp(void)
 {
-	perf_hpp__init();
-
 	perf_hpp__format[PERF_HPP__OVERHEAD].color =
 				hist_browser__hpp_color_overhead;
 	perf_hpp__format[PERF_HPP__OVERHEAD_SYS].color =
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 2237245..fd52669 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -58,8 +58,6 @@ __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us)
 
 void perf_gtk__init_hpp(void)
 {
-	perf_hpp__init();
-
 	perf_hpp__format[PERF_HPP__OVERHEAD].color =
 				perf_gtk__hpp_color_overhead;
 	perf_hpp__format[PERF_HPP__OVERHEAD_SYS].color =
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 5df5140..ba51fa8 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -86,8 +86,6 @@ void setup_browser(bool fallback_to_pager)
 		use_browser = 0;
 		if (fallback_to_pager)
 			setup_pager();
-
-		perf_hpp__init();
 		break;
 	}
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 11/22] perf report: Add -F option to specify output fields
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (9 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 10/22] perf tools: Call perf_hpp__init() before setting up GUI browsers Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 12/22] perf tools: Add ->sort() member to struct sort_entry Jiri Olsa
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

The -F/--fields option is to allow user setup output field in any
order.  It can receive any sort keys and following (hpp) fields:

  overhead, overhead_sys, overhead_us, sample and period

If guest profiling is enabled, overhead_guest_{sys,us} will be
available too.

The output fields also affect sort order unless you give -s/--sort
option.  And any keys specified on -s option, will also be added to
the output field list automatically.

  $ perf report -F sym,sample,overhead
  ...
  #                     Symbol       Samples  Overhead
  # ..........................  ............  ........
  #
    [.] __cxa_atexit                       2     2.50%
    [.] __libc_csu_init                    4     5.00%
    [.] __new_exitfn                       3     3.75%
    [.] _dl_check_map_versions             1     1.25%
    [.] _dl_name_match_p                   4     5.00%
    [.] _dl_setup_hash                     1     1.25%
    [.] _dl_sysdep_start                   1     1.25%
    [.] _init                              5     6.25%
    [.] _setjmp                            6     7.50%
    [.] a                                  8    10.00%
    [.] b                                  8    10.00%
    [.] brk                                1     1.25%
    [.] c                                  8    10.00%

Note that, the example output above is captured after applying next
patch which fixes sort/comparing behavior.

Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-12-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Documentation/perf-report.txt |  10 ++
 tools/perf/builtin-report.c              |  15 ++-
 tools/perf/ui/hist.c                     |  59 ++++++++-
 tools/perf/util/hist.h                   |   4 +
 tools/perf/util/sort.c                   | 209 ++++++++++++++++++++++++++++++-
 tools/perf/util/sort.h                   |   2 +
 6 files changed, 282 insertions(+), 17 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 9babe91..a1b5185 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -107,6 +107,16 @@ OPTIONS
 	And default sort keys are changed to comm, dso_from, symbol_from, dso_to
 	and symbol_to, see '--branch-stack'.
 
+-F::
+--fields=::
+	Specify output field - multiple keys can be specified in CSV format.
+	Following fields are available:
+	overhead, overhead_sys, overhead_us, sample and period.
+	Also it can contain any sort key(s).
+
+	By default, every sort keys not specified in -F will be appended
+	automatically.
+
 -p::
 --parent=<regex>::
         A regex filter to identify parent. The parent is a caller of this
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index c4dab7a..bc0eec1 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -701,6 +701,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
 		   " Please refer the man page for the complete list."),
+	OPT_STRING('F', "fields", &field_order, "key[,keys...]",
+		   "output field(s): overhead, period, sample plus all of sort keys"),
 	OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
 		    "Show sample percentage for different cpu modes"),
 	OPT_STRING('p', "parent", &parent_pattern, "regex",
@@ -814,17 +816,14 @@ repeat:
 	}
 
 	if (setup_sorting() < 0) {
-		parse_options_usage(report_usage, options, "s", 1);
+		if (sort_order)
+			parse_options_usage(report_usage, options, "s", 1);
+		if (field_order)
+			parse_options_usage(sort_order ? NULL : report_usage,
+					    options, "F", 1);
 		goto error;
 	}
 
-	if (parent_pattern != default_parent_pattern) {
-		if (sort_dimension__add("parent") < 0)
-			goto error;
-	}
-
-	perf_hpp__init();
-
 	/* Force tty output for header output. */
 	if (report.header || report.header_only)
 		use_browser = 0;
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 24116a4..b114c66 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -355,6 +355,12 @@ void perf_hpp__init(void)
 			INIT_LIST_HEAD(&fmt->sort_list);
 	}
 
+	/*
+	 * If user specified field order, no need to setup default fields.
+	 */
+	if (field_order)
+		return;
+
 	perf_hpp__column_enable(PERF_HPP__OVERHEAD);
 
 	if (symbol_conf.show_cpu_utilization) {
@@ -377,8 +383,6 @@ void perf_hpp__init(void)
 	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
 	if (list_empty(list))
 		list_add(list, &perf_hpp__sort_list);
-
-	perf_hpp__setup_output_field();
 }
 
 void perf_hpp__column_register(struct perf_hpp_fmt *format)
@@ -403,8 +407,55 @@ void perf_hpp__setup_output_field(void)
 
 	/* append sort keys to output field */
 	perf_hpp__for_each_sort_list(fmt) {
-		if (list_empty(&fmt->list))
-			perf_hpp__column_register(fmt);
+		if (!list_empty(&fmt->list))
+			continue;
+
+		/*
+		 * sort entry fields are dynamically created,
+		 * so they can share a same sort key even though
+		 * the list is empty.
+		 */
+		if (perf_hpp__is_sort_entry(fmt)) {
+			struct perf_hpp_fmt *pos;
+
+			perf_hpp__for_each_format(pos) {
+				if (perf_hpp__same_sort_entry(pos, fmt))
+					goto next;
+			}
+		}
+
+		perf_hpp__column_register(fmt);
+next:
+		continue;
+	}
+}
+
+void perf_hpp__append_sort_keys(void)
+{
+	struct perf_hpp_fmt *fmt;
+
+	/* append output fields to sort keys */
+	perf_hpp__for_each_format(fmt) {
+		if (!list_empty(&fmt->sort_list))
+			continue;
+
+		/*
+		 * sort entry fields are dynamically created,
+		 * so they can share a same sort key even though
+		 * the list is empty.
+		 */
+		if (perf_hpp__is_sort_entry(fmt)) {
+			struct perf_hpp_fmt *pos;
+
+			perf_hpp__for_each_sort_list(pos) {
+				if (perf_hpp__same_sort_entry(pos, fmt))
+					goto next;
+			}
+		}
+
+		perf_hpp__register_sort_field(fmt);
+next:
+		continue;
 	}
 }
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 76bb72e..f3713b7 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -197,6 +197,10 @@ void perf_hpp__column_register(struct perf_hpp_fmt *format);
 void perf_hpp__column_enable(unsigned col);
 void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
 void perf_hpp__setup_output_field(void);
+void perf_hpp__append_sort_keys(void);
+
+bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
+bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
 
 typedef u64 (*hpp_field_fn)(struct hist_entry *he);
 typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index d64c1e5..b748b02 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -13,6 +13,7 @@ const char	default_mem_sort_order[] = "local_weight,mem,sym,dso,symbol_daddr,dso
 const char	default_top_sort_order[] = "dso,symbol";
 const char	default_diff_sort_order[] = "dso,symbol";
 const char	*sort_order;
+const char	*field_order;
 regex_t		ignore_callees_regex;
 int		have_ignore_callees = 0;
 int		sort__need_collapse = 0;
@@ -1057,6 +1058,20 @@ struct hpp_sort_entry {
 	struct sort_entry *se;
 };
 
+bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
+{
+	struct hpp_sort_entry *hse_a;
+	struct hpp_sort_entry *hse_b;
+
+	if (!perf_hpp__is_sort_entry(a) || !perf_hpp__is_sort_entry(b))
+		return false;
+
+	hse_a = container_of(a, struct hpp_sort_entry, hpp);
+	hse_b = container_of(b, struct hpp_sort_entry, hpp);
+
+	return hse_a->se == hse_b->se;
+}
+
 static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 			      struct perf_evsel *evsel)
 {
@@ -1092,14 +1107,15 @@ static int __sort__hpp_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 	return hse->se->se_snprintf(he, hpp->buf, hpp->size, len);
 }
 
-static int __sort_dimension__add_hpp(struct sort_dimension *sd)
+static struct hpp_sort_entry *
+__sort_dimension__alloc_hpp(struct sort_dimension *sd)
 {
 	struct hpp_sort_entry *hse;
 
 	hse = malloc(sizeof(*hse));
 	if (hse == NULL) {
 		pr_err("Memory allocation failed\n");
-		return -1;
+		return NULL;
 	}
 
 	hse->se = sd->entry;
@@ -1115,16 +1131,42 @@ static int __sort_dimension__add_hpp(struct sort_dimension *sd)
 	INIT_LIST_HEAD(&hse->hpp.list);
 	INIT_LIST_HEAD(&hse->hpp.sort_list);
 
+	return hse;
+}
+
+bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format)
+{
+	return format->header == __sort__hpp_header;
+}
+
+static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
+{
+	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);
+
+	if (hse == NULL)
+		return -1;
+
 	perf_hpp__register_sort_field(&hse->hpp);
 	return 0;
 }
 
+static int __sort_dimension__add_hpp_output(struct sort_dimension *sd)
+{
+	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);
+
+	if (hse == NULL)
+		return -1;
+
+	perf_hpp__column_register(&hse->hpp);
+	return 0;
+}
+
 static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
 {
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp(sd) < 0)
+	if (__sort_dimension__add_hpp_sort(sd) < 0)
 		return -1;
 
 	if (sd->entry->se_collapse)
@@ -1149,6 +1191,28 @@ static int __hpp_dimension__add(struct hpp_dimension *hd)
 	return 0;
 }
 
+static int __sort_dimension__add_output(struct sort_dimension *sd)
+{
+	if (sd->taken)
+		return 0;
+
+	if (__sort_dimension__add_hpp_output(sd) < 0)
+		return -1;
+
+	sd->taken = 1;
+	return 0;
+}
+
+static int __hpp_dimension__add_output(struct hpp_dimension *hd)
+{
+	if (!hd->taken) {
+		hd->taken = 1;
+
+		perf_hpp__column_register(hd->fmt);
+	}
+	return 0;
+}
+
 int sort_dimension__add(const char *tok)
 {
 	unsigned int i;
@@ -1237,14 +1301,23 @@ static const char *get_default_sort_order(void)
 	return default_sort_orders[sort__mode];
 }
 
-int setup_sorting(void)
+static int __setup_sorting(void)
 {
 	char *tmp, *tok, *str;
 	const char *sort_keys = sort_order;
 	int ret = 0;
 
-	if (sort_keys == NULL)
+	if (sort_keys == NULL) {
+		if (field_order) {
+			/*
+			 * If user specified field order but no sort order,
+			 * we'll honor it and not add default sort orders.
+			 */
+			return 0;
+		}
+
 		sort_keys = get_default_sort_order();
+	}
 
 	str = strdup(sort_keys);
 	if (str == NULL) {
@@ -1331,3 +1404,129 @@ void sort__setup_elide(FILE *output)
 	list_for_each_entry(se, &hist_entry__sort_list, list)
 		se->elide = false;
 }
+
+static int output_field_add(char *tok)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(common_sort_dimensions); i++) {
+		struct sort_dimension *sd = &common_sort_dimensions[i];
+
+		if (strncasecmp(tok, sd->name, strlen(tok)))
+			continue;
+
+		return __sort_dimension__add_output(sd);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
+		struct hpp_dimension *hd = &hpp_sort_dimensions[i];
+
+		if (strncasecmp(tok, hd->name, strlen(tok)))
+			continue;
+
+		return __hpp_dimension__add_output(hd);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
+		struct sort_dimension *sd = &bstack_sort_dimensions[i];
+
+		if (strncasecmp(tok, sd->name, strlen(tok)))
+			continue;
+
+		return __sort_dimension__add_output(sd);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(memory_sort_dimensions); i++) {
+		struct sort_dimension *sd = &memory_sort_dimensions[i];
+
+		if (strncasecmp(tok, sd->name, strlen(tok)))
+			continue;
+
+		return __sort_dimension__add_output(sd);
+	}
+
+	return -ESRCH;
+}
+
+static void reset_dimensions(void)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(common_sort_dimensions); i++)
+		common_sort_dimensions[i].taken = 0;
+
+	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++)
+		hpp_sort_dimensions[i].taken = 0;
+
+	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++)
+		bstack_sort_dimensions[i].taken = 0;
+
+	for (i = 0; i < ARRAY_SIZE(memory_sort_dimensions); i++)
+		memory_sort_dimensions[i].taken = 0;
+}
+
+static int __setup_output_field(void)
+{
+	char *tmp, *tok, *str;
+	int ret = 0;
+
+	if (field_order == NULL)
+		return 0;
+
+	reset_dimensions();
+
+	str = strdup(field_order);
+	if (str == NULL) {
+		error("Not enough memory to setup output fields");
+		return -ENOMEM;
+	}
+
+	for (tok = strtok_r(str, ", ", &tmp);
+			tok; tok = strtok_r(NULL, ", ", &tmp)) {
+		ret = output_field_add(tok);
+		if (ret == -EINVAL) {
+			error("Invalid --fields key: `%s'", tok);
+			break;
+		} else if (ret == -ESRCH) {
+			error("Unknown --fields key: `%s'", tok);
+			break;
+		}
+	}
+
+	free(str);
+	return ret;
+}
+
+int setup_sorting(void)
+{
+	int err;
+
+	err = __setup_sorting();
+	if (err < 0)
+		return err;
+
+	if (parent_pattern != default_parent_pattern) {
+		err = sort_dimension__add("parent");
+		if (err < 0)
+			return err;
+	}
+
+	reset_dimensions();
+
+	/*
+	 * perf diff doesn't use default hpp output fields.
+	 */
+	if (sort__mode != SORT_MODE__DIFF)
+		perf_hpp__init();
+
+	err = __setup_output_field();
+	if (err < 0)
+		return err;
+
+	/* copy sort keys to output fields */
+	perf_hpp__setup_output_field();
+	/* and then copy output fields to sort keys */
+	perf_hpp__append_sort_keys();
+
+	return 0;
+}
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 1a72952..89e5057 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -25,6 +25,7 @@
 
 extern regex_t parent_regex;
 extern const char *sort_order;
+extern const char *field_order;
 extern const char default_parent_pattern[];
 extern const char *parent_pattern;
 extern const char default_sort_order[];
@@ -191,6 +192,7 @@ extern struct sort_entry sort_thread;
 extern struct list_head hist_entry__sort_list;
 
 int setup_sorting(void);
+int setup_output_field(void);
 extern int sort_dimension__add(const char *);
 void sort__setup_elide(FILE *fp);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 12/22] perf tools: Add ->sort() member to struct sort_entry
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (10 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 11/22] perf report: Add -F option to specify output fields Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 13/22] perf report/tui: Fix a bug when --fields/sort is given Jiri Olsa
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Currently, what the sort_entry does is just identifying hist entries
so that they can be grouped properly.  However, with -F option
support, it indeed needs to sort entries appropriately to be shown to
users.  So add ->sort() member to do it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-13-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/sort.c | 27 ++++++++++++++++++++++-----
 tools/perf/util/sort.h |  1 +
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b748b02..5414ba5 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -99,6 +99,12 @@ sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
 	return comm__str(right->comm) - comm__str(left->comm);
 }
 
+static int64_t
+sort__comm_sort(struct hist_entry *left, struct hist_entry *right)
+{
+	return strcmp(comm__str(right->comm), comm__str(left->comm));
+}
+
 static int hist_entry__comm_snprintf(struct hist_entry *he, char *bf,
 				     size_t size, unsigned int width)
 {
@@ -109,6 +115,7 @@ struct sort_entry sort_comm = {
 	.se_header	= "Command",
 	.se_cmp		= sort__comm_cmp,
 	.se_collapse	= sort__comm_collapse,
+	.se_sort	= sort__comm_sort,
 	.se_snprintf	= hist_entry__comm_snprintf,
 	.se_width_idx	= HISTC_COMM,
 };
@@ -122,7 +129,7 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r)
 	const char *dso_name_l, *dso_name_r;
 
 	if (!dso_l || !dso_r)
-		return cmp_null(dso_l, dso_r);
+		return cmp_null(dso_r, dso_l);
 
 	if (verbose) {
 		dso_name_l = dso_l->long_name;
@@ -138,7 +145,7 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r)
 static int64_t
 sort__dso_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	return _sort__dso_cmp(left->ms.map, right->ms.map);
+	return _sort__dso_cmp(right->ms.map, left->ms.map);
 }
 
 static int _hist_entry__dso_snprintf(struct map *map, char *bf,
@@ -210,6 +217,15 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
 	return _sort__sym_cmp(left->ms.sym, right->ms.sym);
 }
 
+static int64_t
+sort__sym_sort(struct hist_entry *left, struct hist_entry *right)
+{
+	if (!left->ms.sym || !right->ms.sym)
+		return cmp_null(left->ms.sym, right->ms.sym);
+
+	return strcmp(right->ms.sym->name, left->ms.sym->name);
+}
+
 static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym,
 				     u64 ip, char level, char *bf, size_t size,
 				     unsigned int width)
@@ -256,6 +272,7 @@ static int hist_entry__sym_snprintf(struct hist_entry *he, char *bf,
 struct sort_entry sort_sym = {
 	.se_header	= "Symbol",
 	.se_cmp		= sort__sym_cmp,
+	.se_sort	= sort__sym_sort,
 	.se_snprintf	= hist_entry__sym_snprintf,
 	.se_width_idx	= HISTC_SYMBOL,
 };
@@ -283,7 +300,7 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 					    map__rip_2objdump(map, right->ip));
 		}
 	}
-	return strcmp(left->srcline, right->srcline);
+	return strcmp(right->srcline, left->srcline);
 }
 
 static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf,
@@ -311,7 +328,7 @@ sort__parent_cmp(struct hist_entry *left, struct hist_entry *right)
 	if (!sym_l || !sym_r)
 		return cmp_null(sym_l, sym_r);
 
-	return strcmp(sym_l->name, sym_r->name);
+	return strcmp(sym_r->name, sym_l->name);
 }
 
 static int hist_entry__parent_snprintf(struct hist_entry *he, char *bf,
@@ -1126,7 +1143,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 
 	hse->hpp.cmp = sd->entry->se_cmp;
 	hse->hpp.collapse = sd->entry->se_collapse ? : sd->entry->se_cmp;
-	hse->hpp.sort = hse->hpp.collapse;
+	hse->hpp.sort = sd->entry->se_sort ? : hse->hpp.collapse;
 
 	INIT_LIST_HEAD(&hse->hpp.list);
 	INIT_LIST_HEAD(&hse->hpp.sort_list);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 89e5057..f5a831c 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -182,6 +182,7 @@ struct sort_entry {
 
 	int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
 	int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
+	int64_t	(*se_sort)(struct hist_entry *, struct hist_entry *);
 	int	(*se_snprintf)(struct hist_entry *he, char *bf, size_t size,
 			       unsigned int width);
 	u8	se_width_idx;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 13/22] perf report/tui: Fix a bug when --fields/sort is given
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (11 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 12/22] perf tools: Add ->sort() member to struct sort_entry Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 14/22] perf top: Add --fields option to specify output fields Jiri Olsa
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

The hists__filter_entries() function is called when down arrow key is
pressed for navigating through the entries in TUI.  It has a check for
filtering out entries that have very small overhead (under min_pcnt).

However it just assumed the entries are sorted by the overhead so when
it saw such a small overheaded entry, it just stopped navigating as an
optimization.  But it's not true anymore due to new --fields and
--sort optoin behavior and this case users cannot go down to a next
entry if ther's an entry with small overhead in-between.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-14-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 92d128f..169224c 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -812,10 +812,7 @@ static struct rb_node *hists__filter_entries(struct rb_node *nd,
 		if (total)
 			percent = h->stat.period * 100.0 / total;
 
-		if (percent < min_pcnt)
-			return NULL;
-
-		if (!h->filtered)
+		if (!h->filtered && percent >= min_pcnt)
 			return nd;
 
 		nd = rb_next(nd);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 14/22] perf top: Add --fields option to specify output fields
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (12 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 13/22] perf report/tui: Fix a bug when --fields/sort is given Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 15/22] perf tools: Skip elided sort entries Jiri Olsa
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

The --fields option is to allow user setup output field in any order.
It can receive any sort keys and following (hpp) fields:

  overhead, overhead_sys, overhead_us, sample and period

If guest profiling is enabled, overhead_guest_{sys,us} will be
available too.

More more information, please see previous patch "perf report:
Add -F option to specify output fields"

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-15-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Documentation/perf-top.txt |  9 +++++++++
 tools/perf/builtin-top.c              | 15 +++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index df86328..dcfa54c 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -116,6 +116,15 @@ Default is to monitor all CPUS.
 	local_weight, abort, in_tx, transaction, overhead, sample, period.
 	Please see description of --sort in the perf-report man page.
 
+--fields=::
+	Specify output field - multiple keys can be specified in CSV format.
+	Following fields are available:
+	overhead, overhead_sys, overhead_us, sample and period.
+	Also it can contain any sort key(s).
+
+	By default, every sort keys not specified in --field will be appended
+	automatically.
+
 -n::
 --show-nr-samples::
 	Show a column with the number of samples.
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 280945b..5b389ce 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1085,6 +1085,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
 		   " Please refer the man page for the complete list."),
+	OPT_STRING(0, "fields", &field_order, "key[,keys...]",
+		   "output field(s): overhead, period, sample plus all of sort keys"),
 	OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
 		    "Show a column with the number of samples"),
 	OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
@@ -1138,17 +1140,18 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 		usage_with_options(top_usage, options);
 
 	sort__mode = SORT_MODE__TOP;
+	/* display thread wants entries to be collapsed in a different tree */
+	sort__need_collapse = 1;
 
 	if (setup_sorting() < 0) {
-		parse_options_usage(top_usage, options, "s", 1);
+		if (sort_order)
+			parse_options_usage(top_usage, options, "s", 1);
+		if (field_order)
+			parse_options_usage(sort_order ? NULL : top_usage,
+					    options, "fields", 0);
 		goto out_delete_evlist;
 	}
 
-	/* display thread wants entries to be collapsed in a different tree */
-	sort__need_collapse = 1;
-
-	perf_hpp__init();
-
 	if (top.use_stdio)
 		use_browser = 0;
 	else if (top.use_tui)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 15/22] perf tools: Skip elided sort entries
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (13 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 14/22] perf top: Add --fields option to specify output fields Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 16/22] perf hists: Reset width of output fields with header length Jiri Olsa
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

When it converted sort entries to hpp formats, it missed se->elide
handling, so add it for compatibility.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-16-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/hists.c |  6 ++++++
 tools/perf/ui/gtk/hists.c      |  6 ++++++
 tools/perf/ui/stdio/hist.c     |  9 +++++++++
 tools/perf/util/hist.c         |  9 +++++++++
 tools/perf/util/hist.h         |  1 +
 tools/perf/util/sort.c         | 11 +++++++++++
 6 files changed, 42 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 169224c..1c331b9 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -711,6 +711,9 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 		ui_browser__gotorc(&browser->b, row, 0);
 
 		perf_hpp__for_each_format(fmt) {
+			if (perf_hpp__should_skip(fmt))
+				continue;
+
 			if (current_entry && browser->b.navkeypressed) {
 				ui_browser__set_color(&browser->b,
 						      HE_COLORSET_SELECTED);
@@ -1100,6 +1103,9 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
 		printed += fprintf(fp, "%c ", folded_sign);
 
 	perf_hpp__for_each_format(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		if (!first) {
 			ret = scnprintf(hpp.buf, hpp.size, "  ");
 			advance_hpp(&hpp, ret);
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index fd52669..9d90683 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -178,6 +178,9 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 	col_idx = 0;
 
 	perf_hpp__for_each_format(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		fmt->header(fmt, &hpp, hists_to_evsel(hists));
 
 		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
@@ -222,6 +225,9 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 		col_idx = 0;
 
 		perf_hpp__for_each_format(fmt) {
+			if (perf_hpp__should_skip(fmt))
+				continue;
+
 			if (fmt->color)
 				fmt->color(fmt, &hpp, h);
 			else
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 49e2e4a..e3fdf4e 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -318,6 +318,9 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
 		return 0;
 
 	perf_hpp__for_each_format(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		/*
 		 * If there's no field_sep, we still need
 		 * to display initial '  '.
@@ -407,6 +410,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 	fprintf(fp, "# ");
 
 	perf_hpp__for_each_format(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		if (!first)
 			fprintf(fp, "%s", sep ?: "  ");
 		else
@@ -430,6 +436,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 	perf_hpp__for_each_format(fmt) {
 		unsigned int i;
 
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		if (!first)
 			fprintf(fp, "%s", sep ?: "  ");
 		else
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index ae13c2d..b262b44 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -436,6 +436,9 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 	int64_t cmp = 0;
 
 	perf_hpp__for_each_sort_list(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		cmp = fmt->cmp(left, right);
 		if (cmp)
 			break;
@@ -451,6 +454,9 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
 	int64_t cmp = 0;
 
 	perf_hpp__for_each_sort_list(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		cmp = fmt->collapse(left, right);
 		if (cmp)
 			break;
@@ -570,6 +576,9 @@ static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
 	int64_t cmp = 0;
 
 	perf_hpp__for_each_sort_list(fmt) {
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
 		cmp = fmt->sort(a, b);
 		if (cmp)
 			break;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f3713b7..f67feb4 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -201,6 +201,7 @@ void perf_hpp__append_sort_keys(void);
 
 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
 bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
+bool perf_hpp__should_skip(struct perf_hpp_fmt *format);
 
 typedef u64 (*hpp_field_fn)(struct hist_entry *he);
 typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 5414ba5..0fe7cbe 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1358,6 +1358,17 @@ static int __setup_sorting(void)
 	return ret;
 }
 
+bool perf_hpp__should_skip(struct perf_hpp_fmt *format)
+{
+	if (perf_hpp__is_sort_entry(format)) {
+		struct hpp_sort_entry *hse;
+
+		hse = container_of(format, struct hpp_sort_entry, hpp);
+		return hse->se->elide;
+	}
+	return false;
+}
+
 static void sort_entry__setup_elide(struct sort_entry *se,
 				    struct strlist *list,
 				    const char *list_name, FILE *fp)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 16/22] perf hists: Reset width of output fields with header length
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (14 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 15/22] perf tools: Skip elided sort entries Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 17/22] perf tools: Get rid of obsolete hist_entry__sort_list Jiri Olsa
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Some fields missed to set default column length so it broke align in
--stdio output.  Add perf_hpp__reset_width() to set it to a sane
default value.

Note that this change will ignore -w/--column-widths option for now.

Before:
  $ perf report -F cpu,comm,overhead --stdio
  ...
  # CPU          Command  Overhead
  #   ...............  ........
  #
    0          firefox     2.65%
    0      kworker/0:0     1.45%
    0          swapper     5.52%
    0         synergys     0.92%
    1          firefox     4.54%

After:
  # CPU          Command  Overhead
  # ...  ...............  ........
  #
      0          firefox     2.65%
      0      kworker/0:0     1.45%
      0          swapper     5.52%
      0         synergys     0.92%
      1          firefox     4.54%

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-17-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/stdio/hist.c | 21 +++------------------
 tools/perf/util/hist.h     |  1 +
 tools/perf/util/sort.c     | 12 ++++++++++++
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index e3fdf4e..cfcd3f6 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -369,12 +369,10 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 		      int max_cols, float min_pcnt, FILE *fp)
 {
 	struct perf_hpp_fmt *fmt;
-	struct sort_entry *se;
 	struct rb_node *nd;
 	size_t ret = 0;
 	unsigned int width;
 	const char *sep = symbol_conf.field_sep;
-	const char *col_width = symbol_conf.col_width_list_str;
 	int nr_rows = 0;
 	char bf[96];
 	struct perf_hpp dummy_hpp = {
@@ -387,22 +385,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	init_rem_hits();
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		if (se->elide)
-			continue;
-		width = strlen(se->se_header);
-		if (symbol_conf.col_width_list_str) {
-			if (col_width) {
-				hists__set_col_len(hists, se->se_width_idx,
-						   atoi(col_width));
-				col_width = strchr(col_width, ',');
-				if (col_width)
-					++col_width;
-			}
-		}
-		if (!hists__new_col_len(hists, se->se_width_idx, width))
-			width = hists__col_len(hists, se->se_width_idx);
-	}
+
+	perf_hpp__for_each_format(fmt)
+		perf_hpp__reset_width(fmt, hists);
 
 	if (!show_header)
 		goto print_entries;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f67feb4..034db76 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -202,6 +202,7 @@ void perf_hpp__append_sort_keys(void);
 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
 bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
 bool perf_hpp__should_skip(struct perf_hpp_fmt *format);
+void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
 
 typedef u64 (*hpp_field_fn)(struct hist_entry *he);
 typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 0fe7cbe..9bee728 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1089,6 +1089,18 @@ bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
 	return hse_a->se == hse_b->se;
 }
 
+void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
+{
+	struct hpp_sort_entry *hse;
+
+	if (!perf_hpp__is_sort_entry(fmt))
+		return;
+
+	hse = container_of(fmt, struct hpp_sort_entry, hpp);
+	hists__new_col_len(hists, hse->se->se_width_idx,
+			   strlen(hse->se->se_header));
+}
+
 static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 			      struct perf_evsel *evsel)
 {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 17/22] perf tools: Get rid of obsolete hist_entry__sort_list
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (15 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 16/22] perf hists: Reset width of output fields with header length Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 18/22] perf tools: Introduce reset_output_field() Jiri Olsa
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Now we moved to the perf_hpp_[_sort]_list so no need to keep the old
hist_entry__sort_list and sort__first_dimension.  Also the
hist_entry__sort_snprintf() can be gone as hist_entry__snprintf()
provides the functionality.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-18-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/hist.c       | 36 +++++++++---------------------------
 tools/perf/ui/stdio/hist.c | 22 +++++++++++++++-------
 tools/perf/util/sort.c     | 35 +++++++++++++++++++----------------
 3 files changed, 43 insertions(+), 50 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index b114c66..61cf31e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -459,47 +459,29 @@ next:
 	}
 }
 
-int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
-			      struct hists *hists)
-{
-	const char *sep = symbol_conf.field_sep;
-	struct sort_entry *se;
-	int ret = 0;
-
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		if (se->elide)
-			continue;
-
-		ret += scnprintf(s + ret, size - ret, "%s", sep ?: "  ");
-		ret += se->se_snprintf(he, s + ret, size - ret,
-				       hists__col_len(hists, se->se_width_idx));
-	}
-
-	return ret;
-}
-
 /*
  * See hists__fprintf to match the column widths
  */
 unsigned int hists__sort_list_width(struct hists *hists)
 {
 	struct perf_hpp_fmt *fmt;
-	struct sort_entry *se;
-	int i = 0, ret = 0;
+	int ret = 0;
+	bool first = true;
 	struct perf_hpp dummy_hpp;
 
 	perf_hpp__for_each_format(fmt) {
-		if (i)
+		if (perf_hpp__should_skip(fmt))
+			continue;
+
+		if (first)
+			first = false;
+		else
 			ret += 2;
 
 		ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists));
 	}
 
-	list_for_each_entry(se, &hist_entry__sort_list, list)
-		if (!se->elide)
-			ret += 2 + hists__col_len(hists, se->se_width_idx);
-
-	if (verbose) /* Addr + origin */
+	if (verbose && sort__has_sym) /* Addr + origin */
 		ret += 3 + BITS_PER_LONG / 4;
 
 	return ret;
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index cfcd3f6..9f57991 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -183,7 +183,8 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 			 * the symbol. No need to print it otherwise it appears as
 			 * displayed twice.
 			 */
-			if (!i++ && sort__first_dimension == SORT_SYM)
+			if (!i++ && field_order == NULL &&
+			    sort_order && !prefixcmp(sort_order, "sym"))
 				continue;
 			if (!printed) {
 				ret += callchain__fprintf_left_margin(fp, left_margin);
@@ -296,13 +297,20 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
 	int left_margin = 0;
 	u64 total_period = hists->stats.total_period;
 
-	if (sort__first_dimension == SORT_COMM) {
-		struct sort_entry *se = list_first_entry(&hist_entry__sort_list,
-							 typeof(*se), list);
-		left_margin = hists__col_len(hists, se->se_width_idx);
-		left_margin -= thread__comm_len(he->thread);
-	}
+	if (field_order == NULL && (sort_order == NULL ||
+				    !prefixcmp(sort_order, "comm"))) {
+		struct perf_hpp_fmt *fmt;
+
+		perf_hpp__for_each_format(fmt) {
+			if (!perf_hpp__is_sort_entry(fmt))
+				continue;
 
+			/* must be 'comm' sort entry */
+			left_margin = fmt->width(fmt, NULL, hists_to_evsel(hists));
+			left_margin -= thread__comm_len(he->thread);
+			break;
+		}
+	}
 	return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
 }
 
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 9bee728..d913206 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -22,9 +22,6 @@ int		sort__has_sym = 0;
 int		sort__has_dso = 0;
 enum sort_mode	sort__mode = SORT_MODE__NORMAL;
 
-enum sort_type	sort__first_dimension;
-
-LIST_HEAD(hist_entry__sort_list);
 
 static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
 {
@@ -1190,7 +1187,7 @@ static int __sort_dimension__add_hpp_output(struct sort_dimension *sd)
 	return 0;
 }
 
-static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
+static int __sort_dimension__add(struct sort_dimension *sd)
 {
 	if (sd->taken)
 		return 0;
@@ -1201,10 +1198,6 @@ static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
 	if (sd->entry->se_collapse)
 		sort__need_collapse = 1;
 
-	if (list_empty(&hist_entry__sort_list))
-		sort__first_dimension = idx;
-
-	list_add_tail(&sd->entry->list, &hist_entry__sort_list);
 	sd->taken = 1;
 
 	return 0;
@@ -1268,7 +1261,7 @@ int sort_dimension__add(const char *tok)
 			sort__has_dso = 1;
 		}
 
-		return __sort_dimension__add(sd, i);
+		return __sort_dimension__add(sd);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -1292,7 +1285,7 @@ int sort_dimension__add(const char *tok)
 		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, i + __SORT_BRANCH_STACK);
+		__sort_dimension__add(sd);
 		return 0;
 	}
 
@@ -1308,7 +1301,7 @@ int sort_dimension__add(const char *tok)
 		if (sd->entry == &sort_mem_daddr_sym)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, i + __SORT_MEMORY_MODE);
+		__sort_dimension__add(sd);
 		return 0;
 	}
 
@@ -1395,7 +1388,8 @@ static void sort_entry__setup_elide(struct sort_entry *se,
 
 void sort__setup_elide(FILE *output)
 {
-	struct sort_entry *se;
+	struct perf_hpp_fmt *fmt;
+	struct hpp_sort_entry *hse;
 
 	sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
 				"dso", output);
@@ -1436,13 +1430,22 @@ void sort__setup_elide(FILE *output)
 	 * It makes no sense to elide all of sort entries.
 	 * Just revert them to show up again.
 	 */
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		if (!se->elide)
+	perf_hpp__for_each_format(fmt) {
+		if (!perf_hpp__is_sort_entry(fmt))
+			continue;
+
+		hse = container_of(fmt, struct hpp_sort_entry, hpp);
+		if (!hse->se->elide)
 			return;
 	}
 
-	list_for_each_entry(se, &hist_entry__sort_list, list)
-		se->elide = false;
+	perf_hpp__for_each_format(fmt) {
+		if (!perf_hpp__is_sort_entry(fmt))
+			continue;
+
+		hse = container_of(fmt, struct hpp_sort_entry, hpp);
+		hse->se->elide = false;
+	}
 }
 
 static int output_field_add(char *tok)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 18/22] perf tools: Introduce reset_output_field()
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (16 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 17/22] perf tools: Get rid of obsolete hist_entry__sort_list Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 19/22] perf tests: Factor out print_hists_*() Jiri Olsa
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

The reset_output_field() function is for clearing output field
settings and will be used for test code in later patch.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-19-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/hist.c   | 17 +++++++++++++++++
 tools/perf/util/hist.h |  7 +++++++
 tools/perf/util/sort.c | 11 +++++++++++
 tools/perf/util/sort.h |  1 +
 4 files changed, 36 insertions(+)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 61cf31e..4484f5b 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -459,6 +459,23 @@ next:
 	}
 }
 
+void perf_hpp__reset_output_field(void)
+{
+	struct perf_hpp_fmt *fmt, *tmp;
+
+	/* reset output fields */
+	perf_hpp__for_each_format_safe(fmt, tmp) {
+		list_del_init(&fmt->list);
+		list_del_init(&fmt->sort_list);
+	}
+
+	/* reset sort keys */
+	perf_hpp__for_each_sort_list_safe(fmt, tmp) {
+		list_del_init(&fmt->list);
+		list_del_init(&fmt->sort_list);
+	}
+}
+
 /*
  * See hists__fprintf to match the column widths
  */
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 034db76..a8418d1 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -174,9 +174,15 @@ extern struct list_head perf_hpp__sort_list;
 #define perf_hpp__for_each_format(format) \
 	list_for_each_entry(format, &perf_hpp__list, list)
 
+#define perf_hpp__for_each_format_safe(format, tmp)	\
+	list_for_each_entry_safe(format, tmp, &perf_hpp__list, list)
+
 #define perf_hpp__for_each_sort_list(format) \
 	list_for_each_entry(format, &perf_hpp__sort_list, sort_list)
 
+#define perf_hpp__for_each_sort_list_safe(format, tmp)	\
+	list_for_each_entry_safe(format, tmp, &perf_hpp__sort_list, sort_list)
+
 extern struct perf_hpp_fmt perf_hpp__format[];
 
 enum {
@@ -197,6 +203,7 @@ void perf_hpp__column_register(struct perf_hpp_fmt *format);
 void perf_hpp__column_enable(unsigned col);
 void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
 void perf_hpp__setup_output_field(void);
+void perf_hpp__reset_output_field(void);
 void perf_hpp__append_sort_keys(void);
 
 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index d913206..901b9be 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1573,3 +1573,14 @@ int setup_sorting(void)
 
 	return 0;
 }
+
+void reset_output_field(void)
+{
+	sort__need_collapse = 0;
+	sort__has_parent = 0;
+	sort__has_sym = 0;
+	sort__has_dso = 0;
+
+	reset_dimensions();
+	perf_hpp__reset_output_field();
+}
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index f5a831c..5f38d92 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -194,6 +194,7 @@ extern struct list_head hist_entry__sort_list;
 
 int setup_sorting(void);
 int setup_output_field(void);
+void reset_output_field(void);
 extern int sort_dimension__add(const char *);
 void sort__setup_elide(FILE *fp);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 19/22] perf tests: Factor out print_hists_*()
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (17 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 18/22] perf tools: Introduce reset_output_field() Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 20/22] perf tests: Add a testcase for histogram output sorting Jiri Olsa
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

Those print helper functions can be reused by later hist test cases so
factor them out to a common location.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-20-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/hists_common.c | 57 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/hists_common.h |  3 +++
 tools/perf/tests/hists_filter.c | 37 ++++----------------------
 tools/perf/tests/hists_link.c   | 29 +--------------------
 4 files changed, 66 insertions(+), 60 deletions(-)

diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c
index 44655b3..040a85b 100644
--- a/tools/perf/tests/hists_common.c
+++ b/tools/perf/tests/hists_common.c
@@ -146,3 +146,60 @@ out:
 	machine__delete(machine);
 	return NULL;
 }
+
+void print_hists_in(struct hists *hists)
+{
+	int i = 0;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	if (sort__need_collapse)
+		root = &hists->entries_collapsed;
+	else
+		root = hists->entries_in;
+
+	pr_info("----- %s --------\n", __func__);
+	node = rb_first(root);
+	while (node) {
+		struct hist_entry *he;
+
+		he = rb_entry(node, struct hist_entry, rb_node_in);
+
+		if (!he->filtered) {
+			pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
+				i, thread__comm_str(he->thread),
+				he->ms.map->dso->short_name,
+				he->ms.sym->name, he->stat.period);
+		}
+
+		i++;
+		node = rb_next(node);
+	}
+}
+
+void print_hists_out(struct hists *hists)
+{
+	int i = 0;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	root = &hists->entries;
+
+	pr_info("----- %s --------\n", __func__);
+	node = rb_first(root);
+	while (node) {
+		struct hist_entry *he;
+
+		he = rb_entry(node, struct hist_entry, rb_node);
+
+		if (!he->filtered) {
+			pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
+				i, thread__comm_str(he->thread),
+				he->ms.map->dso->short_name,
+				he->ms.sym->name, he->stat.period);
+		}
+
+		i++;
+		node = rb_next(node);
+	}
+}
diff --git a/tools/perf/tests/hists_common.h b/tools/perf/tests/hists_common.h
index 2528b8f..1415ae6 100644
--- a/tools/perf/tests/hists_common.h
+++ b/tools/perf/tests/hists_common.h
@@ -41,4 +41,7 @@ struct machines;
  */
 struct machine *setup_fake_machine(struct machines *machines);
 
+void print_hists_in(struct hists *hists);
+void print_hists_out(struct hists *hists);
+
 #endif /* __PERF_TESTS__HISTS_COMMON_H__ */
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 4617a8b..13c8cf4 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -98,33 +98,6 @@ out:
 	return TEST_FAIL;
 }
 
-static void print_hists(struct hists *hists)
-{
-	int i = 0;
-	struct rb_root *root;
-	struct rb_node *node;
-
-	root = &hists->entries;
-
-	pr_info("----- %s --------\n", __func__);
-	node = rb_first(root);
-	while (node) {
-		struct hist_entry *he;
-
-		he = rb_entry(node, struct hist_entry, rb_node);
-
-		if (!he->filtered) {
-			pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
-				i, thread__comm_str(he->thread),
-				he->ms.map->dso->short_name,
-				he->ms.sym->name, he->stat.period);
-		}
-
-		i++;
-		node = rb_next(node);
-	}
-}
-
 int test__hists_filter(void)
 {
 	int err = TEST_FAIL;
@@ -169,7 +142,7 @@ int test__hists_filter(void)
 
 		if (verbose > 2) {
 			pr_info("Normal histogram\n");
-			print_hists(hists);
+			print_hists_out(hists);
 		}
 
 		TEST_ASSERT_VAL("Invalid nr samples",
@@ -193,7 +166,7 @@ int test__hists_filter(void)
 
 		if (verbose > 2) {
 			pr_info("Histogram for thread filter\n");
-			print_hists(hists);
+			print_hists_out(hists);
 		}
 
 		/* normal stats should be invariant */
@@ -222,7 +195,7 @@ int test__hists_filter(void)
 
 		if (verbose > 2) {
 			pr_info("Histogram for dso filter\n");
-			print_hists(hists);
+			print_hists_out(hists);
 		}
 
 		/* normal stats should be invariant */
@@ -257,7 +230,7 @@ int test__hists_filter(void)
 
 		if (verbose > 2) {
 			pr_info("Histogram for symbol filter\n");
-			print_hists(hists);
+			print_hists_out(hists);
 		}
 
 		/* normal stats should be invariant */
@@ -284,7 +257,7 @@ int test__hists_filter(void)
 
 		if (verbose > 2) {
 			pr_info("Histogram for all filters\n");
-			print_hists(hists);
+			print_hists_out(hists);
 		}
 
 		/* normal stats should be invariant */
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index b009bbf..4e783db 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -268,33 +268,6 @@ static int validate_link(struct hists *leader, struct hists *other)
 	return __validate_link(leader, 0) || __validate_link(other, 1);
 }
 
-static void print_hists(struct hists *hists)
-{
-	int i = 0;
-	struct rb_root *root;
-	struct rb_node *node;
-
-	if (sort__need_collapse)
-		root = &hists->entries_collapsed;
-	else
-		root = hists->entries_in;
-
-	pr_info("----- %s --------\n", __func__);
-	node = rb_first(root);
-	while (node) {
-		struct hist_entry *he;
-
-		he = rb_entry(node, struct hist_entry, rb_node_in);
-
-		pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
-			i, thread__comm_str(he->thread), he->ms.map->dso->short_name,
-			he->ms.sym->name, he->stat.period);
-
-		i++;
-		node = rb_next(node);
-	}
-}
-
 int test__hists_link(void)
 {
 	int err = -1;
@@ -336,7 +309,7 @@ int test__hists_link(void)
 		hists__collapse_resort(&evsel->hists, NULL);
 
 		if (verbose > 2)
-			print_hists(&evsel->hists);
+			print_hists_in(&evsel->hists);
 	}
 
 	first = perf_evlist__first(evlist);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 20/22] perf tests: Add a testcase for histogram output sorting
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (18 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 19/22] perf tests: Factor out print_hists_*() Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 21/22] perf tools: Add cat as fallback pager Jiri Olsa
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa

From: Namhyung Kim <namhyung@kernel.org>

With new output fields option, its internal implementation was changed
so add a new testcase to verify whether it breaks things.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-21-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Makefile.perf        |   1 +
 tools/perf/tests/builtin-test.c |   4 +
 tools/perf/tests/hists_common.c |   4 +-
 tools/perf/tests/hists_filter.c |   1 +
 tools/perf/tests/hists_link.c   |   1 +
 tools/perf/tests/hists_output.c | 618 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |   1 +
 7 files changed, 628 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/tests/hists_output.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index dea2d633..02f0a4d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -399,6 +399,7 @@ LIB_OBJS += $(OUTPUT)tests/pmu.o
 LIB_OBJS += $(OUTPUT)tests/hists_common.o
 LIB_OBJS += $(OUTPUT)tests/hists_link.o
 LIB_OBJS += $(OUTPUT)tests/hists_filter.o
+LIB_OBJS += $(OUTPUT)tests/hists_output.o
 LIB_OBJS += $(OUTPUT)tests/python-use.o
 LIB_OBJS += $(OUTPUT)tests/bp_signal.o
 LIB_OBJS += $(OUTPUT)tests/bp_signal_overflow.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 5e0764b..831f52c 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -136,6 +136,10 @@ static struct test {
 		.func = test__thread_mg_share,
 	},
 	{
+		.desc = "Test output sorting of hist entries",
+		.func = test__hists_output,
+	},
+	{
 		.func = NULL,
 	},
 };
diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c
index 040a85b..e4e01aad 100644
--- a/tools/perf/tests/hists_common.c
+++ b/tools/perf/tests/hists_common.c
@@ -193,8 +193,8 @@ void print_hists_out(struct hists *hists)
 		he = rb_entry(node, struct hist_entry, rb_node);
 
 		if (!he->filtered) {
-			pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
-				i, thread__comm_str(he->thread),
+			pr_info("%2d: entry: %8s:%5d [%-8s] %20s: period = %"PRIu64"\n",
+				i, thread__comm_str(he->thread), he->thread->tid,
 				he->ms.map->dso->short_name,
 				he->ms.sym->name, he->stat.period);
 		}
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 13c8cf4..c5ba924 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -283,6 +283,7 @@ int test__hists_filter(void)
 out:
 	/* tear down everything */
 	perf_evlist__delete(evlist);
+	reset_output_field();
 	machines__exit(&machines);
 
 	return err;
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 4e783db..5ffa2c3 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -332,6 +332,7 @@ int test__hists_link(void)
 out:
 	/* tear down everything */
 	perf_evlist__delete(evlist);
+	reset_output_field();
 	machines__exit(&machines);
 
 	return err;
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
new file mode 100644
index 0000000..a168505
--- /dev/null
+++ b/tools/perf/tests/hists_output.c
@@ -0,0 +1,618 @@
+#include "perf.h"
+#include "util/debug.h"
+#include "util/symbol.h"
+#include "util/sort.h"
+#include "util/evsel.h"
+#include "util/evlist.h"
+#include "util/machine.h"
+#include "util/thread.h"
+#include "util/parse-events.h"
+#include "tests/tests.h"
+#include "tests/hists_common.h"
+
+struct sample {
+	u32 cpu;
+	u32 pid;
+	u64 ip;
+	struct thread *thread;
+	struct map *map;
+	struct symbol *sym;
+};
+
+/* For the numbers, see hists_common.c */
+static struct sample fake_samples[] = {
+	/* perf [kernel] schedule() */
+	{ .cpu = 0, .pid = 100, .ip = 0xf0000 + 700, },
+	/* perf [perf]   main() */
+	{ .cpu = 1, .pid = 100, .ip = 0x40000 + 700, },
+	/* perf [perf]   cmd_record() */
+	{ .cpu = 1, .pid = 100, .ip = 0x40000 + 900, },
+	/* perf [libc]   malloc() */
+	{ .cpu = 1, .pid = 100, .ip = 0x50000 + 700, },
+	/* perf [libc]   free() */
+	{ .cpu = 2, .pid = 100, .ip = 0x50000 + 800, },
+	/* perf [perf]   main() */
+	{ .cpu = 2, .pid = 200, .ip = 0x40000 + 700, },
+	/* perf [kernel] page_fault() */
+	{ .cpu = 2, .pid = 200, .ip = 0xf0000 + 800, },
+	/* bash [bash]   main() */
+	{ .cpu = 3, .pid = 300, .ip = 0x40000 + 700, },
+	/* bash [bash]   xmalloc() */
+	{ .cpu = 0, .pid = 300, .ip = 0x40000 + 800, },
+	/* bash [kernel] page_fault() */
+	{ .cpu = 1, .pid = 300, .ip = 0xf0000 + 800, },
+};
+
+static int add_hist_entries(struct hists *hists, struct machine *machine)
+{
+	struct addr_location al;
+	struct hist_entry *he;
+	struct perf_sample sample = { .period = 100, };
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(fake_samples); i++) {
+		const union perf_event event = {
+			.header = {
+				.misc = PERF_RECORD_MISC_USER,
+			},
+		};
+
+		sample.cpu = fake_samples[i].cpu;
+		sample.pid = fake_samples[i].pid;
+		sample.tid = fake_samples[i].pid;
+		sample.ip = fake_samples[i].ip;
+
+		if (perf_event__preprocess_sample(&event, machine, &al,
+						  &sample) < 0)
+			goto out;
+
+		he = __hists__add_entry(hists, &al, NULL, NULL, NULL,
+					sample.period, 1, 0);
+		if (he == NULL)
+			goto out;
+
+		fake_samples[i].thread = al.thread;
+		fake_samples[i].map = al.map;
+		fake_samples[i].sym = al.sym;
+	}
+
+	return TEST_OK;
+
+out:
+	pr_debug("Not enough memory for adding a hist entry\n");
+	return TEST_FAIL;
+}
+
+static void del_hist_entries(struct hists *hists)
+{
+	struct hist_entry *he;
+	struct rb_root *root_in;
+	struct rb_root *root_out;
+	struct rb_node *node;
+
+	if (sort__need_collapse)
+		root_in = &hists->entries_collapsed;
+	else
+		root_in = hists->entries_in;
+
+	root_out = &hists->entries;
+
+	while (!RB_EMPTY_ROOT(root_out)) {
+		node = rb_first(root_out);
+
+		he = rb_entry(node, struct hist_entry, rb_node);
+		rb_erase(node, root_out);
+		rb_erase(&he->rb_node_in, root_in);
+		hist_entry__free(he);
+	}
+}
+
+typedef int (*test_fn_t)(struct perf_evsel *, struct machine *);
+
+#define COMM(he)  (thread__comm_str(he->thread))
+#define DSO(he)   (he->ms.map->dso->short_name)
+#define SYM(he)   (he->ms.sym->name)
+#define CPU(he)   (he->cpu)
+#define PID(he)   (he->thread->tid)
+
+/* default sort keys (no field) */
+static int test1(struct perf_evsel *evsel, struct machine *machine)
+{
+	int err;
+	struct hists *hists = &evsel->hists;
+	struct hist_entry *he;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	field_order = NULL;
+	sort_order = NULL; /* equivalent to sort_order = "comm,dso,sym" */
+
+	setup_sorting();
+
+	/*
+	 * expected output:
+	 *
+	 * Overhead  Command  Shared Object          Symbol
+	 * ========  =======  =============  ==============
+	 *   20.00%     perf  perf           [.] main
+	 *   10.00%     bash  [kernel]       [k] page_fault
+	 *   10.00%     bash  bash           [.] main
+	 *   10.00%     bash  bash           [.] xmalloc
+	 *   10.00%     perf  [kernel]       [k] page_fault
+	 *   10.00%     perf  [kernel]       [k] schedule
+	 *   10.00%     perf  libc           [.] free
+	 *   10.00%     perf  libc           [.] malloc
+	 *   10.00%     perf  perf           [.] cmd_record
+	 */
+	err = add_hist_entries(hists, machine);
+	if (err < 0)
+		goto out;
+
+	hists__collapse_resort(hists, NULL);
+	hists__output_resort(hists);
+
+	if (verbose > 2) {
+		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
+		print_hists_out(hists);
+	}
+
+	root = &evsel->hists.entries;
+	node = rb_first(root);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "perf") &&
+			!strcmp(SYM(he), "main") && he->stat.period == 200);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "[kernel]") &&
+			!strcmp(SYM(he), "page_fault") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "bash") &&
+			!strcmp(SYM(he), "main") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "bash") &&
+			!strcmp(SYM(he), "xmalloc") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "[kernel]") &&
+			!strcmp(SYM(he), "page_fault") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "[kernel]") &&
+			!strcmp(SYM(he), "schedule") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "libc") &&
+			!strcmp(SYM(he), "free") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "libc") &&
+			!strcmp(SYM(he), "malloc") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "perf") &&
+			!strcmp(SYM(he), "cmd_record") && he->stat.period == 100);
+
+out:
+	del_hist_entries(hists);
+	reset_output_field();
+	return err;
+}
+
+/* mixed fields and sort keys */
+static int test2(struct perf_evsel *evsel, struct machine *machine)
+{
+	int err;
+	struct hists *hists = &evsel->hists;
+	struct hist_entry *he;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	field_order = "overhead,cpu";
+	sort_order = "pid";
+
+	setup_sorting();
+
+	/*
+	 * expected output:
+	 *
+	 * Overhead  CPU  Command:  Pid
+	 * ========  ===  =============
+	 *   30.00%    1  perf   :  100
+	 *   10.00%    0  perf   :  100
+	 *   10.00%    2  perf   :  100
+	 *   20.00%    2  perf   :  200
+	 *   10.00%    0  bash   :  300
+	 *   10.00%    1  bash   :  300
+	 *   10.00%    3  bash   :  300
+	 */
+	err = add_hist_entries(hists, machine);
+	if (err < 0)
+		goto out;
+
+	hists__collapse_resort(hists, NULL);
+	hists__output_resort(hists);
+
+	if (verbose > 2) {
+		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
+		print_hists_out(hists);
+	}
+
+	root = &evsel->hists.entries;
+	node = rb_first(root);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 1 && PID(he) == 100 && he->stat.period == 300);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 0 && PID(he) == 100 && he->stat.period == 100);
+
+out:
+	del_hist_entries(hists);
+	reset_output_field();
+	return err;
+}
+
+/* fields only (no sort key) */
+static int test3(struct perf_evsel *evsel, struct machine *machine)
+{
+	int err;
+	struct hists *hists = &evsel->hists;
+	struct hist_entry *he;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	field_order = "comm,overhead,dso";
+	sort_order = NULL;
+
+	setup_sorting();
+
+	/*
+	 * expected output:
+	 *
+	 * Command  Overhead  Shared Object
+	 * =======  ========  =============
+	 *    bash    20.00%  bash
+	 *    bash    10.00%  [kernel]
+	 *    perf    30.00%  perf
+	 *    perf    20.00%  [kernel]
+	 *    perf    20.00%  libc
+	 */
+	err = add_hist_entries(hists, machine);
+	if (err < 0)
+		goto out;
+
+	hists__collapse_resort(hists, NULL);
+	hists__output_resort(hists);
+
+	if (verbose > 2) {
+		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
+		print_hists_out(hists);
+	}
+
+	root = &evsel->hists.entries;
+	node = rb_first(root);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "bash") &&
+			he->stat.period == 200);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "[kernel]") &&
+			he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "perf") &&
+			he->stat.period == 300);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "[kernel]") &&
+			he->stat.period == 200);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "libc") &&
+			he->stat.period == 200);
+
+out:
+	del_hist_entries(hists);
+	reset_output_field();
+	return err;
+}
+
+/* handle duplicate 'dso' field */
+static int test4(struct perf_evsel *evsel, struct machine *machine)
+{
+	int err;
+	struct hists *hists = &evsel->hists;
+	struct hist_entry *he;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	field_order = "dso,sym,comm,overhead,dso";
+	sort_order = "sym";
+
+	setup_sorting();
+
+	/*
+	 * expected output:
+	 *
+	 * Shared Object          Symbol  Command  Overhead
+	 * =============  ==============  =======  ========
+	 *          perf  [.] cmd_record     perf    10.00%
+	 *          libc  [.] free           perf    10.00%
+	 *          bash  [.] main           bash    10.00%
+	 *          perf  [.] main           perf    20.00%
+	 *          libc  [.] malloc         perf    10.00%
+	 *      [kernel]  [k] page_fault     bash    10.00%
+	 *      [kernel]  [k] page_fault     perf    10.00%
+	 *      [kernel]  [k] schedule       perf    10.00%
+	 *          bash  [.] xmalloc        bash    10.00%
+	 */
+	err = add_hist_entries(hists, machine);
+	if (err < 0)
+		goto out;
+
+	hists__collapse_resort(hists, NULL);
+	hists__output_resort(hists);
+
+	if (verbose > 2) {
+		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
+		print_hists_out(hists);
+	}
+
+	root = &evsel->hists.entries;
+	node = rb_first(root);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "perf") && !strcmp(SYM(he), "cmd_record") &&
+			!strcmp(COMM(he), "perf") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "libc") && !strcmp(SYM(he), "free") &&
+			!strcmp(COMM(he), "perf") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "bash") && !strcmp(SYM(he), "main") &&
+			!strcmp(COMM(he), "bash") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "perf") && !strcmp(SYM(he), "main") &&
+			!strcmp(COMM(he), "perf") && he->stat.period == 200);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "libc") && !strcmp(SYM(he), "malloc") &&
+			!strcmp(COMM(he), "perf") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "[kernel]") && !strcmp(SYM(he), "page_fault") &&
+			!strcmp(COMM(he), "bash") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "[kernel]") && !strcmp(SYM(he), "page_fault") &&
+			!strcmp(COMM(he), "perf") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "[kernel]") && !strcmp(SYM(he), "schedule") &&
+			!strcmp(COMM(he), "perf") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			!strcmp(DSO(he), "bash") && !strcmp(SYM(he), "xmalloc") &&
+			!strcmp(COMM(he), "bash") && he->stat.period == 100);
+
+out:
+	del_hist_entries(hists);
+	reset_output_field();
+	return err;
+}
+
+/* full sort keys w/o overhead field */
+static int test5(struct perf_evsel *evsel, struct machine *machine)
+{
+	int err;
+	struct hists *hists = &evsel->hists;
+	struct hist_entry *he;
+	struct rb_root *root;
+	struct rb_node *node;
+
+	field_order = "cpu,pid,comm,dso,sym";
+	sort_order = "dso,pid";
+
+	setup_sorting();
+
+	/*
+	 * expected output:
+	 *
+	 * CPU  Command:  Pid  Command  Shared Object          Symbol
+	 * ===  =============  =======  =============  ==============
+	 *   0     perf:  100     perf       [kernel]  [k] schedule
+	 *   2     perf:  200     perf       [kernel]  [k] page_fault
+	 *   1     bash:  300     bash       [kernel]  [k] page_fault
+	 *   0     bash:  300     bash           bash  [.] xmalloc
+	 *   3     bash:  300     bash           bash  [.] main
+	 *   1     perf:  100     perf           libc  [.] malloc
+	 *   2     perf:  100     perf           libc  [.] free
+	 *   1     perf:  100     perf           perf  [.] cmd_record
+	 *   1     perf:  100     perf           perf  [.] main
+	 *   2     perf:  200     perf           perf  [.] main
+	 */
+	err = add_hist_entries(hists, machine);
+	if (err < 0)
+		goto out;
+
+	hists__collapse_resort(hists, NULL);
+	hists__output_resort(hists);
+
+	if (verbose > 2) {
+		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
+		print_hists_out(hists);
+	}
+
+	root = &evsel->hists.entries;
+	node = rb_first(root);
+	he = rb_entry(node, struct hist_entry, rb_node);
+
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 0 && PID(he) == 100 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "[kernel]") &&
+			!strcmp(SYM(he), "schedule") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 2 && PID(he) == 200 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "[kernel]") &&
+			!strcmp(SYM(he), "page_fault") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 1 && PID(he) == 300 &&
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "[kernel]") &&
+			!strcmp(SYM(he), "page_fault") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 0 && PID(he) == 300 &&
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "bash") &&
+			!strcmp(SYM(he), "xmalloc") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 3 && PID(he) == 300 &&
+			!strcmp(COMM(he), "bash") && !strcmp(DSO(he), "bash") &&
+			!strcmp(SYM(he), "main") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 1 && PID(he) == 100 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "libc") &&
+			!strcmp(SYM(he), "malloc") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 2 && PID(he) == 100 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "libc") &&
+			!strcmp(SYM(he), "free") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 1 && PID(he) == 100 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "perf") &&
+			!strcmp(SYM(he), "cmd_record") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 1 && PID(he) == 100 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "perf") &&
+			!strcmp(SYM(he), "main") && he->stat.period == 100);
+
+	node = rb_next(node);
+	he = rb_entry(node, struct hist_entry, rb_node);
+	TEST_ASSERT_VAL("Invalid hist entry",
+			CPU(he) == 2 && PID(he) == 200 &&
+			!strcmp(COMM(he), "perf") && !strcmp(DSO(he), "perf") &&
+			!strcmp(SYM(he), "main") && he->stat.period == 100);
+
+out:
+	del_hist_entries(hists);
+	reset_output_field();
+	return err;
+}
+
+int test__hists_output(void)
+{
+	int err = TEST_FAIL;
+	struct machines machines;
+	struct machine *machine;
+	struct perf_evsel *evsel;
+	struct perf_evlist *evlist = perf_evlist__new();
+	size_t i;
+	test_fn_t testcases[] = {
+		test1,
+		test2,
+		test3,
+		test4,
+		test5,
+	};
+
+	TEST_ASSERT_VAL("No memory", evlist);
+
+	err = parse_events(evlist, "cpu-clock");
+	if (err)
+		goto out;
+
+	machines__init(&machines);
+
+	/* setup threads/dso/map/symbols also */
+	machine = setup_fake_machine(&machines);
+	if (!machine)
+		goto out;
+
+	if (verbose > 1)
+		machine__fprintf(machine, stderr);
+
+	evsel = perf_evlist__first(evlist);
+
+	for (i = 0; i < ARRAY_SIZE(testcases); i++) {
+		err = testcases[i](evsel, machine);
+		if (err < 0)
+			break;
+	}
+
+out:
+	/* tear down everything */
+	perf_evlist__delete(evlist);
+	machines__exit(&machines);
+
+	return err;
+}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 8f91fb0..d76c0e2 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -44,6 +44,7 @@ int test__dwarf_unwind(void);
 int test__hists_filter(void);
 int test__mmap_thread_lookup(void);
 int test__thread_mg_share(void);
+int test__hists_output(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 21/22] perf tools: Add cat as fallback pager
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (19 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 20/22] perf tests: Add a testcase for histogram output sorting Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-21 13:12 ` [PATCH 22/22] perf tools: Add automatic remapping of Android libraries Jiri Olsa
  2014-05-22  9:38 ` [GIT PULL 00/22] perf/core improvements and fixes Ingo Molnar
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Michael Lentine, Jiri Olsa

From: Michael Lentine <mlentine@google.com>

This patch adds a fallback to cat for the pager. This is useful
on environments, such as Android, where less does not exist.
It is better to default to cat than to abort.

Signed-off-by: Michael Lentine <mlentine@google.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1400579330-5043-2-git-send-email-eranian@google.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/pager.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
index 3322b84..31ee02d 100644
--- a/tools/perf/util/pager.c
+++ b/tools/perf/util/pager.c
@@ -57,13 +57,13 @@ void setup_pager(void)
 	}
 	if (!pager)
 		pager = getenv("PAGER");
-	if (!pager) {
-		if (!access("/usr/bin/pager", X_OK))
-			pager = "/usr/bin/pager";
-	}
+	if (!(pager || access("/usr/bin/pager", X_OK)))
+		pager = "/usr/bin/pager";
+	if (!(pager || access("/usr/bin/less", X_OK)))
+		pager = "/usr/bin/less";
 	if (!pager)
-		pager = "less";
-	else if (!*pager || !strcmp(pager, "cat"))
+		pager = "cat";
+	if (!*pager || !strcmp(pager, "cat"))
 		return;
 
 	spawned_pager = 1; /* means we are emitting to terminal */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 22/22] perf tools: Add automatic remapping of Android libraries
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (20 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 21/22] perf tools: Add cat as fallback pager Jiri Olsa
@ 2014-05-21 13:12 ` Jiri Olsa
  2014-05-22  9:38 ` [GIT PULL 00/22] perf/core improvements and fixes Ingo Molnar
  22 siblings, 0 replies; 36+ messages in thread
From: Jiri Olsa @ 2014-05-21 13:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Michael Lentine, Jiri Olsa

From: Michael Lentine <mlentine@google.com>

This patch automatically adjusts the path of MMAP records
associated with Android system libraries.

The Android system is organized with system libraries found in
/system/lib and user libraries in /data/app-lib. On the host system
(not running Android), system libraries can be found in the downloaded
NDK directory under ${NDK_ROOT}/platforms/${APP_PLATFORM}/arch-${ARCH}/usr/lib
and the user libraries are installed under libs/${APP_ABI} within
the apk build directory. This patch makes running the reporting
tools possible on the host system using the libraries from the NDK.

Signed-off-by: Michael Lentine <mlentine@google.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1400579330-5043-3-git-send-email-eranian@google.com
[ fixed 'space required before the open parenthesis' checkpatch.pl errors ]
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/map.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ba5f5c0c..8ccbb32 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -32,6 +32,93 @@ static inline int is_no_dso_memory(const char *filename)
 	       !strcmp(filename, "[heap]");
 }
 
+static inline int is_android_lib(const char *filename)
+{
+	return !strncmp(filename, "/data/app-lib", 13) ||
+	       !strncmp(filename, "/system/lib", 11);
+}
+
+static inline bool replace_android_lib(const char *filename, char *newfilename)
+{
+	const char *libname;
+	char *app_abi;
+	size_t app_abi_length, new_length;
+	size_t lib_length = 0;
+
+	libname  = strrchr(filename, '/');
+	if (libname)
+		lib_length = strlen(libname);
+
+	app_abi = getenv("APP_ABI");
+	if (!app_abi)
+		return false;
+
+	app_abi_length = strlen(app_abi);
+
+	if (!strncmp(filename, "/data/app-lib", 13)) {
+		char *apk_path;
+
+		if (!app_abi_length)
+			return false;
+
+		new_length = 7 + app_abi_length + lib_length;
+
+		apk_path = getenv("APK_PATH");
+		if (apk_path) {
+			new_length += strlen(apk_path) + 1;
+			if (new_length > PATH_MAX)
+				return false;
+			snprintf(newfilename, new_length,
+				 "%s/libs/%s/%s", apk_path, app_abi, libname);
+		} else {
+			if (new_length > PATH_MAX)
+				return false;
+			snprintf(newfilename, new_length,
+				 "libs/%s/%s", app_abi, libname);
+		}
+		return true;
+	}
+
+	if (!strncmp(filename, "/system/lib/", 11)) {
+		char *ndk, *app;
+		const char *arch;
+		size_t ndk_length;
+		size_t app_length;
+
+		ndk = getenv("NDK_ROOT");
+		app = getenv("APP_PLATFORM");
+
+		if (!(ndk && app))
+			return false;
+
+		ndk_length = strlen(ndk);
+		app_length = strlen(app);
+
+		if (!(ndk_length && app_length && app_abi_length))
+			return false;
+
+		arch = !strncmp(app_abi, "arm", 3) ? "arm" :
+		       !strncmp(app_abi, "mips", 4) ? "mips" :
+		       !strncmp(app_abi, "x86", 3) ? "x86" : NULL;
+
+		if (!arch)
+			return false;
+
+		new_length = 27 + ndk_length +
+			     app_length + lib_length
+			   + strlen(arch);
+
+		if (new_length > PATH_MAX)
+			return false;
+		snprintf(newfilename, new_length,
+			"%s/platforms/%s/arch-%s/usr/lib/%s",
+			ndk, app, arch, libname);
+
+		return true;
+	}
+	return false;
+}
+
 void map__init(struct map *map, enum map_type type,
 	       u64 start, u64 end, u64 pgoff, struct dso *dso)
 {
@@ -59,8 +146,9 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
 	if (map != NULL) {
 		char newfilename[PATH_MAX];
 		struct dso *dso;
-		int anon, no_dso, vdso;
+		int anon, no_dso, vdso, android;
 
+		android = is_android_lib(filename);
 		anon = is_anon_memory(filename);
 		vdso = is_vdso_map(filename);
 		no_dso = is_no_dso_memory(filename);
@@ -75,6 +163,11 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
 			filename = newfilename;
 		}
 
+		if (android) {
+			if (replace_android_lib(filename, newfilename))
+				filename = newfilename;
+		}
+
 		if (vdso) {
 			pgoff = 0;
 			dso = vdso__dso_findnew(dsos__list);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [GIT PULL 00/22] perf/core improvements and fixes
  2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
                   ` (21 preceding siblings ...)
  2014-05-21 13:12 ` [PATCH 22/22] perf tools: Add automatic remapping of Android libraries Jiri Olsa
@ 2014-05-22  9:38 ` Ingo Molnar
  22 siblings, 0 replies; 36+ messages in thread
From: Ingo Molnar @ 2014-05-22  9:38 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Frederic Weisbecker, Michael Lentine, Namhyung Kim,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian


* Jiri Olsa <jolsa@kernel.org> wrote:

> hi Ingo,
> please consider pulling
> 
> thanks,
> jirka
> 
> 
> The following changes since commit 6480c56130ba073df84d57d61062ec4118b10bbe:
> 
>   Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/core (2014-05-20 08:36:09 +0200)
> 
> are available in the git repository at:
> 
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git tags/perf-core-for-mingo
> 
> for you to fetch changes up to eca8183699964579ca8a0b8d116bd1f4da0136f7:
> 
>   perf tools: Add automatic remapping of Android libraries (2014-05-21 15:03:25 +0200)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> . Android related fixes for pager and map dso resolving (Michael Lentine)
> 
> . Add -F option for specifying output fields (Namhyung Kim)
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> 
> ----------------------------------------------------------------
> Michael Lentine (2):
>       perf tools: Add cat as fallback pager
>       perf tools: Add automatic remapping of Android libraries
> 
> Namhyung Kim (20):
>       perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt
>       perf tools: Convert sort entries to hpp formats
>       perf tools: Use hpp formats to sort hist entries
>       perf tools: Support event grouping in hpp ->sort()
>       perf tools: Use hpp formats to sort final output
>       perf tools: Consolidate output field handling to hpp format routines
>       perf ui: Get rid of callback from __hpp__fmt()
>       perf tools: Allow hpp fields to be sort keys
>       perf tools: Consolidate management of default sort orders
>       perf tools: Call perf_hpp__init() before setting up GUI browsers
>       perf report: Add -F option to specify output fields
>       perf tools: Add ->sort() member to struct sort_entry
>       perf report/tui: Fix a bug when --fields/sort is given
>       perf top: Add --fields option to specify output fields
>       perf tools: Skip elided sort entries
>       perf hists: Reset width of output fields with header length
>       perf tools: Get rid of obsolete hist_entry__sort_list
>       perf tools: Introduce reset_output_field()
>       perf tests: Factor out print_hists_*()
>       perf tests: Add a testcase for histogram output sorting
> 
>  tools/perf/Documentation/perf-diff.txt   |   5 +-
>  tools/perf/Documentation/perf-report.txt |  19 +
>  tools/perf/Documentation/perf-top.txt    |  14 +-
>  tools/perf/Makefile.perf                 |   1 +
>  tools/perf/builtin-diff.c                |   7 +-
>  tools/perf/builtin-report.c              |  41 +-
>  tools/perf/builtin-top.c                 |  20 +-
>  tools/perf/tests/builtin-test.c          |   4 +
>  tools/perf/tests/hists_common.c          |  57 +++
>  tools/perf/tests/hists_common.h          |   3 +
>  tools/perf/tests/hists_filter.c          |  38 +-
>  tools/perf/tests/hists_link.c            |  30 +-
>  tools/perf/tests/hists_output.c          | 618 +++++++++++++++++++++++++++++++
>  tools/perf/tests/tests.h                 |   1 +
>  tools/perf/ui/browsers/hists.c           | 104 +++---
>  tools/perf/ui/gtk/hists.c                |  41 +-
>  tools/perf/ui/hist.c                     | 244 +++++++++---
>  tools/perf/ui/setup.c                    |   2 -
>  tools/perf/ui/stdio/hist.c               |  79 ++--
>  tools/perf/util/hist.c                   |  83 ++---
>  tools/perf/util/hist.h                   |  27 +-
>  tools/perf/util/map.c                    |  95 ++++-
>  tools/perf/util/pager.c                  |  12 +-
>  tools/perf/util/sort.c                   | 436 ++++++++++++++++++++--
>  tools/perf/util/sort.h                   |   6 +
>  25 files changed, 1601 insertions(+), 386 deletions(-)
>  create mode 100644 tools/perf/tests/hists_output.c

Pulled, thanks a lot Jiri!

	Ingo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2018-11-30 18:26 Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-30 18:26 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Clark Williams, linux-kernel, linux-perf-users,
	Arnaldo Carvalho de Melo, Adrian Hunter, Alexander Shishkin,
	Alexei Starovoitov, Alexey Budankov, Andi Kleen, Anton Blanchard,
	Daniel Borkmann, David Ahern, David Howells, David S . Miller,
	Eric Saint-Etienne, Ivan Babrou, Jin Yao, Jiri Olsa,
	Julia Lawall, Leo Yan, Mathieu Poirier, Namhyung Kim,
	Peter Zijlstra, Ravi Bangoria, Slavomir Kaslev, Stephane Eranian,
	Steven Rostedt, Thomas Richter, Tzvetomir Stoyanov, Wang Nan,
	Wen Yang, yuzhoujian, zhong.weidong, Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling, more to come,

Regards,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit b1a9d7b0190119dad5b9b7841751b5a7586bbc8b:

  Merge tag 'perf-urgent-for-mingo-4.20-20181121' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2018-11-21 15:57:21 +0100)

are available in the Git repository at:

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

for you to fetch changes up to 09d3f015d1e1b4fee7e9bbdcf54201d239393391:

  uprobes: Fix handle_swbp() vs. unregister() + register() race once more (2018-11-23 08:31:19 +0100)

----------------------------------------------------------------
perf/core improvements and fixes:

- Introduce 'perf record --aio' to use asynchronous IO trace writing in
  'perf record' disabled by default, i.e. one needs to explicitly use
  'perf record --aio' to use it, in which case the number of AIO aiocb
  structs will be one, specify 'perf record --aio=N' to ask for more,
  according to your needs, related to the number of processors in your
  machine. Reports about the effectiveness of this option are welcome
  so that we can decide on making it the default mode of operation. Read
  the respective patches commit logs for further information (Alexey Budankov)

- Add fallback routines to be used in places where we don't have the cpu mode
  (kernel/user space/hypervisor) and thus must first fallback lookups looking
  at all map trees when trying to resolve symbols (Adrian Hunter)

- Introduce 'perf top --kallsyms file' to match 'perf report --kallsyms', useful
  when dealing with BPF, where symbol resolution happens via kallsyms, not via
  the default vmlinux ELF symtabs (Arnaldo Carvalho de Melo)

- Fix CSV mode column output for non-cgroup events in 'perf stat' (Stephane Eranian)

- Fix 'perf stat' shadow stats for clock events. (Ravi Bangoria)

- Fix error with config term "pt=0", where we should just force "pt=1" and
  warn the user about the former being non-sensical (Adrian Hunter)

- Fix 'perf test' entry where we expect 'sleep' to come in a PERF_RECORD_COMM
  but instead we get 'coreutils' when sleep is provided by some versions of
  the 'coreutils' package (Adrian Hunter)

- Remove needless rb_tree extra indirection from map__find() (Eric Saint-Etienne)

- Add sanity check to libtraceevent's is_timestamp_in_us() (Tzvetomir Stoyanov)

- Use ERR_CAST instead of ERR_PTR(PTR_ERR()) (Wen Yang)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Andrea Parri (1):
      uprobes: Fix handle_swbp() vs. unregister() + register() race once more

Jiri Olsa (3):
      perf/x86/intel: Move branch tracing setup to the Intel-specific source file
      perf/x86/intel: Add generic branch tracing check to intel_pmu_has_bts()
      perf/x86/intel: Disallow precise_ip on BTS events

 arch/x86/events/core.c       | 20 ----------------
 arch/x86/events/intel/core.c | 56 ++++++++++++++++++++++++++++++++++----------
 arch/x86/events/perf_event.h | 13 ++++++----
 kernel/events/uprobes.c      | 12 ++++++++--
 4 files changed, 63 insertions(+), 38 deletions(-)

Test results:

XXX: Investigation on the watchpoint and breakpoint 'perf test' failures is
     underway, doesn't look like related to patches in this batch.

The first ones are container (docker) based builds of tools/perf with
and without libelf support.  Where clang is available, it is also used
to build perf with/without libelf, and building with LIBCLANGLLVM=1
(built-in clang) with gcc and clang when clang and its devel libraries
are installed.

The objtool and samples/bpf/ builds are disabled now that I'm switching from
using the sources in a local volume to fetching them from a http server to
build it inside the container, to make it easier to build in a container cluster.
Those will come back later.

Several are cross builds, the ones with -x-ARCH and the android one, and those
may not have all the features built, due to lack of multi-arch devel packages,
available and being used so far on just a few, like
debian:experimental-x-{arm64,mipsel}.

The 'perf test' one will perform a variety of tests exercising
tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands
with a variety of command line event specifications to then intercept the
sys_perf_event syscall to check that the perf_event_attr fields are set up as
expected, among a variety of other unit tests.

Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/
with a variety of feature sets, exercising the build with an incomplete set of
features as well as with a complete one. It is planned to have it run on each
of the containers mentioned above, using some container orchestration
infrastructure. Get in contact if interested in helping having this in place.

  # dm
   1 alpine:3.4                    : Ok   gcc (Alpine 5.3.0) 5.3.0
   2 alpine:3.5                    : Ok   gcc (Alpine 6.2.1) 6.2.1 20160822
   3 alpine:3.6                    : Ok   gcc (Alpine 6.3.0) 6.3.0
   4 alpine:3.7                    : Ok   gcc (Alpine 6.4.0) 6.4.0
   5 alpine:3.8                    : Ok   gcc (Alpine 6.4.0) 6.4.0
   6 alpine:edge                   : Ok   gcc (Alpine 6.4.0) 6.4.0
   7 amazonlinux:1                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
   8 amazonlinux:2                 : Ok   gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
   9 android-ndk:r12b-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  10 android-ndk:r15c-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  11 centos:5                      : Ok   gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
  12 centos:6                      : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
  13 centos:7                      : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
  14 clearlinux:latest             : Ok   gcc (Clear Linux OS for Intel Architecture) 8.2.1 20180502
  15 debian:7                      : Ok   gcc (Debian 4.7.2-5) 4.7.2
  16 debian:8                      : Ok   gcc (Debian 4.9.2-10+deb8u1) 4.9.2
  17 debian:9                      : Ok   gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
  18 debian:experimental           : Ok   gcc (Debian 8.2.0-10) 8.2.0
  19 debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 8.2.0-10) 8.2.0
  20 debian:experimental-x-mips    : Ok   mips-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0
  21 debian:experimental-x-mips64  : Ok   mips64-linux-gnuabi64-gcc (Debian 8.2.0-10) 8.2.0
  22 debian:experimental-x-mipsel  : Ok   mipsel-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0
  23 fedora:20                     : Ok   gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
  24 fedora:21                     : Ok   gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
  25 fedora:22                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  26 fedora:23                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  27 fedora:24                     : Ok   gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
  28 fedora:24-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710
  29 fedora:25                     : Ok   gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
  30 fedora:26                     : Ok   gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
  31 fedora:27                     : Ok   gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
  32 fedora:28                     : Ok   gcc (GCC) 8.2.1 20181105 (Red Hat 8.2.1-5)
  33 fedora:29                     : Ok   gcc (GCC) 8.2.1 20181011 (Red Hat 8.2.1-4)
  34 fedora:rawhide                : Ok   gcc (GCC) 8.2.1 20181011 (Red Hat 8.2.1-4)
  35 gentoo-stage3-amd64:latest    : Ok   gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0
  36 mageia:5                      : Ok   gcc (GCC) 4.9.2
  37 mageia:6                      : Ok   gcc (Mageia 5.5.0-1.mga6) 5.5.0
  38 opensuse:13.2                 : Ok   gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064]
  39 opensuse:42.1                 : Ok   gcc (SUSE Linux) 4.8.5
  40 opensuse:42.2                 : Ok   gcc (SUSE Linux) 4.8.5
  41 opensuse:42.3                 : Ok   gcc (SUSE Linux) 4.8.5
  42 opensuse:tumbleweed           : Ok   gcc (SUSE Linux) 7.3.1 20180323 [gcc-7-branch revision 258812]
  43 oraclelinux:6                 : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
  44 oraclelinux:7                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36.0.1)
  45 ubuntu:12.04.5                : Ok   gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
  46 ubuntu:14.04.4                : Ok   gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
  47 ubuntu:14.04.4-x-linaro-arm64 : Ok   aarch64-linux-gnu-gcc (Linaro GCC 5.5-2017.10) 5.5.0
  48 ubuntu:16.04                  : Ok   gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
  49 ubuntu:16.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  50 ubuntu:16.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  51 ubuntu:16.04-x-powerpc        : Ok   powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  52 ubuntu:16.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  53 ubuntu:16.04-x-powerpc64el    : Ok   powerpc64le-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  54 ubuntu:16.04-x-s390           : Ok   s390x-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  55 ubuntu:16.10                  : Ok   gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
  56 ubuntu:17.10                  : Ok   gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0
  57 ubuntu:18.04                  : Ok   gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  58 ubuntu:18.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0
  59 ubuntu:18.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0
  60 ubuntu:18.04-x-m68k           : Ok   m68k-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  61 ubuntu:18.04-x-powerpc        : Ok   powerpc-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  62 ubuntu:18.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  63 ubuntu:18.04-x-powerpc64el    : Ok   powerpc64le-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  64 ubuntu:18.04-x-riscv64        : Ok   riscv64-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  65 ubuntu:18.04-x-s390           : Ok   s390x-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  66 ubuntu:18.04-x-sh4            : Ok   sh4-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  67 ubuntu:18.04-x-sparc64        : Ok   sparc64-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  68 ubuntu:18.10                  : Ok   gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0
  # 

  # uname -a
  Linux seventh 4.18.19-100.fc27.x86_64 #1 SMP Wed Nov 14 22:04:34 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  # git log --oneline -1
  ceed7c10bbb4 tools lib traceevent: Add sanity check to is_timestamp_in_us()
  # perf version --build-options
  perf version 4.20.rc3.gceed7c
                   dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
      dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                   glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                    gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
           syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_SUPPORT
                  libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                  libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
                 libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
  numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
                 libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
               libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
                libslang: [ on  ]  # HAVE_SLANG_SUPPORT
               libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
               libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
      libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                    zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                    lzma: [ on  ]  # HAVE_LZMA_SUPPORT
               get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                     bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
  # perf test
   1: vmlinux symtab matches kallsyms                       : Ok
   2: Detect openat syscall event                           : Ok
   3: Detect openat syscall event on all cpus               : Ok
   4: Read samples using the mmap interface                 : Ok
   5: Test data source output                               : Ok
   6: Parse event definition strings                        : Ok
   7: Simple expression parser                              : Ok
   8: PERF_RECORD_* events & perf_sample fields             : Ok
   9: Parse perf pmu format                                 : Ok
  10: DSO data read                                         : Ok
  11: DSO data cache                                        : Ok
  12: DSO data reopen                                       : Ok
  13: Roundtrip evsel->name                                 : Ok
  14: Parse sched tracepoints fields                        : Ok
  15: syscalls:sys_enter_openat event fields                : Ok
  16: Setup struct perf_event_attr                          : Ok
  17: Match and link multiple hists                         : Ok
  18: 'import perf' in python                               : Ok
  19: Breakpoint overflow signal handler                    : Ok
  20: Breakpoint overflow sampling                          : Ok
  21: Breakpoint accounting                                 : Ok
  22: Watchpoint                                            :
  22.1: Read Only Watchpoint                                : Skip
  22.2: Write Only Watchpoint                               : Ok
  22.3: Read / Write Watchpoint                             : Ok
  22.4: Modify Watchpoint                                   : FAILED!
  23: Number of exit events of a simple workload            : Ok
  24: Software clock events period values                   : Ok
  25: Object code reading                                   : Ok
  26: Sample parsing                                        : Ok
  27: Use a dummy software event to keep tracking           : Ok
  28: Parse with no sample_id_all bit set                   : Ok
  29: Filter hist entries                                   : Ok
  30: Lookup mmap thread                                    : Ok
  31: Share thread mg                                       : Ok
  32: Sort output of hist entries                           : Ok
  33: Cumulate child hist entries                           : Ok
  34: Track with sched_switch                               : Ok
  35: Filter fds with revents mask in a fdarray             : Ok
  36: Add fd to a fdarray, making it autogrow               : Ok
  37: kmod_path__parse                                      : Ok
  38: Thread map                                            : Ok
  39: LLVM search and compile                               :
  39.1: Basic BPF llvm compile                              : Ok
  39.2: kbuild searching                                    : Ok
  39.3: Compile source for BPF prologue generation          : Ok
  39.4: Compile source for BPF relocation                   : Ok
  40: Session topology                                      : Ok
  41: BPF filter                                            :
  41.1: Basic BPF filtering                                 : Ok
  41.2: BPF pinning                                         : Ok
  41.3: BPF prologue generation                             : Ok
  41.4: BPF relocation checker                              : Ok
  42: Synthesize thread map                                 : Ok
  43: Remove thread map                                     : Ok
  44: Synthesize cpu map                                    : Ok
  45: Synthesize stat config                                : Ok
  46: Synthesize stat                                       : Ok
  47: Synthesize stat round                                 : Ok
  48: Synthesize attr update                                : Ok
  49: Event times                                           : Ok
  50: Read backward ring buffer                             : Ok
  51: Print cpu map                                         : Ok
  52: Probe SDT events                                      : Ok
  53: is_printable_array                                    : Ok
  54: Print bitmap                                          : Ok
  55: perf hooks                                            : Ok
  56: builtin clang support                                 : Skip (not compiled in)
  57: unit_number__scnprintf                                : Ok
  58: mem2node                                              : Ok
  59: x86 rdpmc                                             : Ok
  60: Convert perf time to TSC                              : Ok
  61: DWARF unwind                                          : Ok
  62: x86 instruction decoder - new instructions            : Ok
  63: x86 bp modify                                         : FAILED!
  64: probe libc's inet_pton & backtrace it with ping       : Ok
  65: Check open filename arg using perf trace + vfs_getname: Ok
  66: Use vfs_getname probe to get syscall args filenames   : Ok
  67: Add vfs_getname probe to get syscall args filenames   : Ok

  $ make -C tools/perf build-test
  make: Entering directory '/home/acme/git/perf/tools/perf'
  - tarpkg: ./tests/perf-targz-src-pkg .
             make_util_map_o_O: make util/map.o
       make_util_pmu_bison_o_O: make util/pmu-bison.o
                   make_help_O: make help
         make_with_clangllvm_O: make LIBCLANGLLVM=1
         make_install_prefix_O: make install prefix=/tmp/krava
           make_no_libbionic_O: make NO_LIBBIONIC=1
                make_no_newt_O: make NO_NEWT=1
  make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
                make_install_O: make install
            make_no_auxtrace_O: make NO_AUXTRACE=1
                make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
                  make_debug_O: make DEBUG=1
                    make_doc_O: make doc
              make_no_libbpf_O: make NO_LIBBPF=1
              make_no_libelf_O: make NO_LIBELF=1
                make_no_gtk2_O: make NO_GTK2=1
               make_no_slang_O: make NO_SLANG=1
            make_no_libaudit_O: make NO_LIBAUDIT=1
            make_no_demangle_O: make NO_DEMANGLE=1
           make_no_libunwind_O: make NO_LIBUNWIND=1
           make_no_backtrace_O: make NO_BACKTRACE=1
             make_no_libnuma_O: make NO_LIBNUMA=1
        make_with_babeltrace_O: make LIBBABELTRACE=1
                  make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
                 make_perf_o_O: make perf.o
             make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
           make_no_libpython_O: make NO_LIBPYTHON=1
            make_install_bin_O: make install-bin
   make_install_prefix_slash_O: make install prefix=/tmp/krava/
                   make_pure_O: make
             make_no_libperl_O: make NO_LIBPERL=1
              make_clean_all_O: make clean all
                 make_static_O: make LDFLAGS=-static
                   make_tags_O: make tags
  OK
  make: Leaving directory '/home/acme/git/perf/tools/perf'
  $

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [GIT PULL 00/22] perf/core improvements and fixes
  2017-04-24 19:54 Arnaldo Carvalho de Melo
@ 2017-04-24 20:40 ` Ingo Molnar
  0 siblings, 0 replies; 36+ messages in thread
From: Ingo Molnar @ 2017-04-24 20:40 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Adrian Hunter, Al Viro, Andi Kleen, David Ahern,
	David Howells, Jiri Olsa, Kyle Huey, Namhyung Kim,
	Peter Zijlstra, Stephane Eranian, Taeung Song, Thomas Gleixner,
	Tony Luck, Wang Nan, Yao Jin, Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider applying,
> 
> - Arnaldo
> 
> Test results at the end of this message, as usual.
> 
> The following changes since commit 07590a7d4030c159b9a0d7171f81049a9ce23245:
> 
>   Merge tag 'perf-core-for-mingo-4.12-20170419' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-04-20 10:07:18 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.12-20170424
> 
> for you to fetch changes up to 9d43f5e8df6804ae271407500af9062e9278167a:
> 
>   perf tools: Fix the code to strip command name (2017-04-24 13:43:37 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Fix display of data source snoop indication in 'perf mem' (Andi Kleen)
> 
> - Fix the code to strip command name from /proc/PID/stat (Jiri Olsa)
> 
> Infrastructure:
> 
> - Continue the disentanglement of headers, specially util.h (Arnaldo Carvalho de Melo)
> 
> - Synchronize some header files with the kernel (Arnaldo Carvalho de Melo)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Andi Kleen (1):
>       perf mem: Fix display of data source snoop indication
> 
> Arnaldo Carvalho de Melo (20):
>       perf unwind: Provide only forward declarations for pointer types
>       perf tools: Add signal.h to places using its definitions
>       perf tools: Move units conversion/formatting routines to separate object
>       perf tools: Move timestamp routines from util.h to time-utils.h
>       perf kvm: Make function only used by 'perf kvm' static
>       perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h
>       perf tools: Add compress.h for the *_decompress_to_file() headers
>       perf callchain: Move callchain specific routines from util.[ch]
>       perf tools: Include sys/param.h where needed
>       perf tools: Remove a few more needless includes from util.h
>       perf tools: Remove sys/ioctl.h from util.h
>       perf tools: Remove string.h from util.h
>       perf tools: Remove stale prototypes from builtin.h
>       perf tools: Remove string.h, unistd.h and sys/stat.h from util.h
>       perf tools: Remove poll.h and wait.h from util.h
>       perf tools: Add the right header to obtain PERF_ALIGN()
>       perf tools: Use just forward declarations for struct thread where possible
>       tools: Update asm-generic/mman-common.h copy from the kernel
>       tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
>       tools arch x86: Sync cpufeatures.h
> 
> Jiri Olsa (1):
>       perf tools: Fix the code to strip command name
> 
>  tools/arch/x86/include/asm/cpufeatures.h  |   1 +
>  tools/arch/x86/lib/memcpy_64.S            |   2 +-
>  tools/include/uapi/linux/stat.h           |   5 +-
>  tools/lib/subcmd/help.h                   |   1 +
>  tools/perf/arch/arm/util/cs-etm.c         |   1 +
>  tools/perf/arch/arm/util/unwind-libdw.c   |   1 +
>  tools/perf/arch/arm64/util/dwarf-regs.c   |   1 +
>  tools/perf/arch/x86/tests/intel-cqm.c     |   2 +
>  tools/perf/arch/x86/util/unwind-libdw.c   |   1 +
>  tools/perf/builtin-buildid-cache.c        |   1 +
>  tools/perf/builtin-c2c.c                  |   2 +
>  tools/perf/builtin-ftrace.c               |   1 +
>  tools/perf/builtin-help.c                 |   4 +
>  tools/perf/builtin-inject.c               |   2 +
>  tools/perf/builtin-kvm.c                  |  17 +++
>  tools/perf/builtin-mem.c                  |   4 +
>  tools/perf/builtin-record.c               |   5 +
>  tools/perf/builtin-report.c               |   5 +
>  tools/perf/builtin-script.c               |   5 +
>  tools/perf/builtin-stat.c                 |   5 +
>  tools/perf/builtin-timechart.c            |   1 +
>  tools/perf/builtin-top.c                  |   1 +
>  tools/perf/builtin-trace.c                |   2 +
>  tools/perf/builtin-version.c              |   3 +-
>  tools/perf/builtin.h                      |   4 -
>  tools/perf/perf.c                         |   6 +-
>  tools/perf/tests/attr.c                   |   4 +
>  tools/perf/tests/bpf.c                    |   2 +
>  tools/perf/tests/builtin-test.c           |   1 +
>  tools/perf/tests/code-reading.c           |   1 +
>  tools/perf/tests/event-times.c            |   1 +
>  tools/perf/tests/parse-events.c           |   3 +
>  tools/perf/tests/unit_number__scnprintf.c |   2 +-
>  tools/perf/trace/beauty/signum.c          |   1 +
>  tools/perf/ui/browsers/hists.c            |   2 +
>  tools/perf/ui/gtk/annotate.c              |   1 +
>  tools/perf/ui/gtk/hists.c                 |   1 +
>  tools/perf/ui/stdio/hist.c                |   1 +
>  tools/perf/util/Build                     |   1 +
>  tools/perf/util/build-id.c                |   3 +
>  tools/perf/util/callchain.c               | 103 +++++++++++++++
>  tools/perf/util/color.h                   |   2 +
>  tools/perf/util/comm.c                    |   1 +
>  tools/perf/util/compress.h                |  12 ++
>  tools/perf/util/config.c                  |   4 +
>  tools/perf/util/debug.c                   |  33 ++++-
>  tools/perf/util/debug.h                   |   3 +
>  tools/perf/util/dso.c                     |   4 +
>  tools/perf/util/event.c                   |  12 +-
>  tools/perf/util/event.h                   |   2 +-
>  tools/perf/util/evlist.c                  |   3 +
>  tools/perf/util/evlist.h                  |   1 +
>  tools/perf/util/evsel.c                   |   1 +
>  tools/perf/util/header.c                  |   4 +
>  tools/perf/util/help-unknown-cmd.c        |   1 +
>  tools/perf/util/hist.c                    |   2 +
>  tools/perf/util/llvm-utils.c              |   1 +
>  tools/perf/util/lzma.c                    |   1 +
>  tools/perf/util/machine.c                 |   3 +
>  tools/perf/util/mem-events.c              |   2 +-
>  tools/perf/util/namespaces.c              |   1 +
>  tools/perf/util/parse-events.c            |   2 +
>  tools/perf/util/pmu.c                     |   1 +
>  tools/perf/util/probe-file.c              |   3 +
>  tools/perf/util/python-ext-sources        |   1 +
>  tools/perf/util/python.c                  |  13 ++
>  tools/perf/util/session.c                 |   1 +
>  tools/perf/util/session.h                 |   3 +-
>  tools/perf/util/sort.c                    |   1 +
>  tools/perf/util/sort.h                    |   3 +-
>  tools/perf/util/strlist.c                 |   1 +
>  tools/perf/util/time-utils.c              |  25 ++++
>  tools/perf/util/time-utils.h              |   7 +
>  tools/perf/util/top.h                     |   2 +-
>  tools/perf/util/units.c                   |  39 ++++++
>  tools/perf/util/units.h                   |  10 ++
>  tools/perf/util/unwind-libdw.h            |   6 +-
>  tools/perf/util/unwind.h                  |   9 +-
>  tools/perf/util/util.c                    | 211 +-----------------------------
>  tools/perf/util/util.h                    |  38 ------
>  tools/perf/util/xyarray.c                 |   2 +
>  tools/perf/util/zlib.c                    |   1 +
>  82 files changed, 412 insertions(+), 270 deletions(-)
>  create mode 100644 tools/perf/util/compress.h
>  create mode 100644 tools/perf/util/units.c
>  create mode 100644 tools/perf/util/units.h

Pulled, thanks a lot Arnaldo!

	Ingo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2017-04-24 19:54 Arnaldo Carvalho de Melo
  2017-04-24 20:40 ` Ingo Molnar
  0 siblings, 1 reply; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-04-24 19:54 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter, Al Viro,
	Andi Kleen, David Ahern, David Howells, Jiri Olsa, Kyle Huey,
	Namhyung Kim, Peter Zijlstra, Stephane Eranian, Taeung Song,
	Thomas Gleixner, Tony Luck, Wang Nan, Yao Jin,
	Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider applying,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit 07590a7d4030c159b9a0d7171f81049a9ce23245:

  Merge tag 'perf-core-for-mingo-4.12-20170419' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-04-20 10:07:18 +0200)

are available in the git repository at:

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

for you to fetch changes up to 9d43f5e8df6804ae271407500af9062e9278167a:

  perf tools: Fix the code to strip command name (2017-04-24 13:43:37 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Fix display of data source snoop indication in 'perf mem' (Andi Kleen)

- Fix the code to strip command name from /proc/PID/stat (Jiri Olsa)

Infrastructure:

- Continue the disentanglement of headers, specially util.h (Arnaldo Carvalho de Melo)

- Synchronize some header files with the kernel (Arnaldo Carvalho de Melo)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Andi Kleen (1):
      perf mem: Fix display of data source snoop indication

Arnaldo Carvalho de Melo (20):
      perf unwind: Provide only forward declarations for pointer types
      perf tools: Add signal.h to places using its definitions
      perf tools: Move units conversion/formatting routines to separate object
      perf tools: Move timestamp routines from util.h to time-utils.h
      perf kvm: Make function only used by 'perf kvm' static
      perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h
      perf tools: Add compress.h for the *_decompress_to_file() headers
      perf callchain: Move callchain specific routines from util.[ch]
      perf tools: Include sys/param.h where needed
      perf tools: Remove a few more needless includes from util.h
      perf tools: Remove sys/ioctl.h from util.h
      perf tools: Remove string.h from util.h
      perf tools: Remove stale prototypes from builtin.h
      perf tools: Remove string.h, unistd.h and sys/stat.h from util.h
      perf tools: Remove poll.h and wait.h from util.h
      perf tools: Add the right header to obtain PERF_ALIGN()
      perf tools: Use just forward declarations for struct thread where possible
      tools: Update asm-generic/mman-common.h copy from the kernel
      tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
      tools arch x86: Sync cpufeatures.h

Jiri Olsa (1):
      perf tools: Fix the code to strip command name

 tools/arch/x86/include/asm/cpufeatures.h  |   1 +
 tools/arch/x86/lib/memcpy_64.S            |   2 +-
 tools/include/uapi/linux/stat.h           |   5 +-
 tools/lib/subcmd/help.h                   |   1 +
 tools/perf/arch/arm/util/cs-etm.c         |   1 +
 tools/perf/arch/arm/util/unwind-libdw.c   |   1 +
 tools/perf/arch/arm64/util/dwarf-regs.c   |   1 +
 tools/perf/arch/x86/tests/intel-cqm.c     |   2 +
 tools/perf/arch/x86/util/unwind-libdw.c   |   1 +
 tools/perf/builtin-buildid-cache.c        |   1 +
 tools/perf/builtin-c2c.c                  |   2 +
 tools/perf/builtin-ftrace.c               |   1 +
 tools/perf/builtin-help.c                 |   4 +
 tools/perf/builtin-inject.c               |   2 +
 tools/perf/builtin-kvm.c                  |  17 +++
 tools/perf/builtin-mem.c                  |   4 +
 tools/perf/builtin-record.c               |   5 +
 tools/perf/builtin-report.c               |   5 +
 tools/perf/builtin-script.c               |   5 +
 tools/perf/builtin-stat.c                 |   5 +
 tools/perf/builtin-timechart.c            |   1 +
 tools/perf/builtin-top.c                  |   1 +
 tools/perf/builtin-trace.c                |   2 +
 tools/perf/builtin-version.c              |   3 +-
 tools/perf/builtin.h                      |   4 -
 tools/perf/perf.c                         |   6 +-
 tools/perf/tests/attr.c                   |   4 +
 tools/perf/tests/bpf.c                    |   2 +
 tools/perf/tests/builtin-test.c           |   1 +
 tools/perf/tests/code-reading.c           |   1 +
 tools/perf/tests/event-times.c            |   1 +
 tools/perf/tests/parse-events.c           |   3 +
 tools/perf/tests/unit_number__scnprintf.c |   2 +-
 tools/perf/trace/beauty/signum.c          |   1 +
 tools/perf/ui/browsers/hists.c            |   2 +
 tools/perf/ui/gtk/annotate.c              |   1 +
 tools/perf/ui/gtk/hists.c                 |   1 +
 tools/perf/ui/stdio/hist.c                |   1 +
 tools/perf/util/Build                     |   1 +
 tools/perf/util/build-id.c                |   3 +
 tools/perf/util/callchain.c               | 103 +++++++++++++++
 tools/perf/util/color.h                   |   2 +
 tools/perf/util/comm.c                    |   1 +
 tools/perf/util/compress.h                |  12 ++
 tools/perf/util/config.c                  |   4 +
 tools/perf/util/debug.c                   |  33 ++++-
 tools/perf/util/debug.h                   |   3 +
 tools/perf/util/dso.c                     |   4 +
 tools/perf/util/event.c                   |  12 +-
 tools/perf/util/event.h                   |   2 +-
 tools/perf/util/evlist.c                  |   3 +
 tools/perf/util/evlist.h                  |   1 +
 tools/perf/util/evsel.c                   |   1 +
 tools/perf/util/header.c                  |   4 +
 tools/perf/util/help-unknown-cmd.c        |   1 +
 tools/perf/util/hist.c                    |   2 +
 tools/perf/util/llvm-utils.c              |   1 +
 tools/perf/util/lzma.c                    |   1 +
 tools/perf/util/machine.c                 |   3 +
 tools/perf/util/mem-events.c              |   2 +-
 tools/perf/util/namespaces.c              |   1 +
 tools/perf/util/parse-events.c            |   2 +
 tools/perf/util/pmu.c                     |   1 +
 tools/perf/util/probe-file.c              |   3 +
 tools/perf/util/python-ext-sources        |   1 +
 tools/perf/util/python.c                  |  13 ++
 tools/perf/util/session.c                 |   1 +
 tools/perf/util/session.h                 |   3 +-
 tools/perf/util/sort.c                    |   1 +
 tools/perf/util/sort.h                    |   3 +-
 tools/perf/util/strlist.c                 |   1 +
 tools/perf/util/time-utils.c              |  25 ++++
 tools/perf/util/time-utils.h              |   7 +
 tools/perf/util/top.h                     |   2 +-
 tools/perf/util/units.c                   |  39 ++++++
 tools/perf/util/units.h                   |  10 ++
 tools/perf/util/unwind-libdw.h            |   6 +-
 tools/perf/util/unwind.h                  |   9 +-
 tools/perf/util/util.c                    | 211 +-----------------------------
 tools/perf/util/util.h                    |  38 ------
 tools/perf/util/xyarray.c                 |   2 +
 tools/perf/util/zlib.c                    |   1 +
 82 files changed, 412 insertions(+), 270 deletions(-)
 create mode 100644 tools/perf/util/compress.h
 create mode 100644 tools/perf/util/units.c
 create mode 100644 tools/perf/util/units.h

Test results:

The first ones are container (docker) based builds of tools/perf with and
without libelf support, objtool where it is supported and samples/bpf/, ditto.
Where clang is available, it is also used to build perf with/without libelf.

Several are cross builds, the ones with -x-ARCH, and the android one, and those
may not have all the features built, due to lack of multi-arch devel packages,
available and being used so far on just a few, like
debian:experimental-x-{arm64,mipsel}.

The 'perf test' one will perform a variety of tests exercising
tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands
with a variety of command line event specifications to then intercept the
sys_perf_event syscall to check that the perf_event_attr fields are set up as
expected, among a variety of other unit tests.

Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/
with a variety of feature sets, exercising the build with an incomplete set of
features as well as with a complete one. It is planned to have it run on each
of the containers mentioned above, using some container orchestration
infrastructure. Get in contact if interested in helping having this in place.

  # dm
   1 alpine:3.4: Ok
   2 alpine:3.5: Ok
   3 alpine:edge: Ok
   4 android-ndk:r12b-arm: Ok
   5 archlinux:latest: Ok
   6 centos:5: Ok
   7 centos:6: Ok
   8 centos:7: Ok
   9 debian:7: Ok
  10 debian:8: Ok
  11 debian:9: Ok
  12 debian:experimental: Ok
  13 debian:experimental-x-arm64: Ok
  14 debian:experimental-x-mips: Ok
  15 debian:experimental-x-mips64: Ok
  16 debian:experimental-x-mipsel: Ok
  17 fedora:20: Ok
  18 fedora:21: Ok
  19 fedora:22: Ok
  20 fedora:23: Ok
  21 fedora:24: Ok
  22 fedora:24-x-ARC-uClibc: Ok
  23 fedora:25: Ok
  24 fedora:rawhide: Ok
  25 mageia:5: Ok
  26 opensuse:13.2: Ok
  27 opensuse:42.1: Ok
  28 opensuse:tumbleweed: Ok
  29 ubuntu:12.04.5: Ok
  30 ubuntu:14.04.4: Ok
  31 ubuntu:14.04.4-x-linaro-arm64: Ok
  32 ubuntu:15.10: Ok
  33 ubuntu:16.04: Ok
  34 ubuntu:16.04-x-arm: Ok
  35 ubuntu:16.04-x-arm64: Ok
  36 ubuntu:16.04-x-powerpc: Ok
  37 ubuntu:16.04-x-powerpc64: Ok
  38 ubuntu:16.04-x-s390: Ok
  39 ubuntu:16.10: Ok
  40 ubuntu:17.04: Ok
  #

  # perf test
   1: vmlinux symtab matches kallsyms            : Ok
   2: Detect openat syscall event                : Ok
   3: Detect openat syscall event on all cpus    : Ok
   4: Read samples using the mmap interface      : Ok
   5: Parse event definition strings             : Ok
   6: Simple expression parser                   : Ok
   7: PERF_RECORD_* events & perf_sample fields  : Ok
   8: Parse perf pmu format                      : Ok
   9: DSO data read                              : Ok
  10: DSO data cache                             : Ok
  11: DSO data reopen                            : Ok
  12: Roundtrip evsel->name                      : Ok
  13: Parse sched tracepoints fields             : Ok
  14: syscalls:sys_enter_openat event fields     : Ok
  15: Setup struct perf_event_attr               : Ok
  16: Match and link multiple hists              : Ok
  17: 'import perf' in python                    : Ok
  18: Breakpoint overflow signal handler         : Ok
  19: Breakpoint overflow sampling               : Ok
  20: Number of exit events of a simple workload : Ok
  21: Software clock events period values        : Ok
  22: Object code reading                        : Ok
  23: Sample parsing                             : Ok
  24: Use a dummy software event to keep tracking: Ok
  25: Parse with no sample_id_all bit set        : Ok
  26: Filter hist entries                        : Ok
  27: Lookup mmap thread                         : Ok
  28: Share thread mg                            : Ok
  29: Sort output of hist entries                : Ok
  30: Cumulate child hist entries                : Ok
  31: Track with sched_switch                    : Ok
  32: Filter fds with revents mask in a fdarray  : Ok
  33: Add fd to a fdarray, making it autogrow    : Ok
  34: kmod_path__parse                           : Ok
  35: Thread map                                 : Ok
  36: LLVM search and compile                    :
  36.1: Basic BPF llvm compile                    : Ok
  36.2: kbuild searching                          : Ok
  36.3: Compile source for BPF prologue generation: Ok
  36.4: Compile source for BPF relocation         : Ok
  37: Session topology                           : Ok
  38: BPF filter                                 :
  38.1: Basic BPF filtering                      : Ok
  38.2: BPF pinning                              : Ok
  38.3: BPF prologue generation                  : Ok
  38.4: BPF relocation checker                   : Ok
  39: Synthesize thread map                      : Ok
  40: Remove thread map                          : Ok
  41: Synthesize cpu map                         : Ok
  42: Synthesize stat config                     : Ok
  43: Synthesize stat                            : Ok
  44: Synthesize stat round                      : Ok
  45: Synthesize attr update                     : Ok
  46: Event times                                : Ok
  47: Read backward ring buffer                  : Ok
  48: Print cpu map                              : Ok
  49: Probe SDT events                           : Ok
  50: is_printable_array                         : Ok
  51: Print bitmap                               : Ok
  52: perf hooks                                 : Ok
  53: builtin clang support                      : Skip (not compiled in)
  54: unit_number__scnprintf                     : Ok
  55: x86 rdpmc                                  : Ok
  56: Convert perf time to TSC                   : Ok
  57: DWARF unwind                               : Ok
  58: x86 instruction decoder - new instructions : Ok
  59: Intel cqm nmi context read                 : Skip
  #
  $ make -C tools/perf build-test
  make: Entering directory '/home/acme/git/linux/tools/perf'
  - tarpkg: ./tests/perf-targz-src-pkg .
  cd . && make FEATURE_DUMP_COPY=/home/acme/git/linux/tools/perf/BUILD_TEST_FEATURE_DUMP feature-dump
                    make_doc_O: && make doc
         make_install_prefix_O: && make install prefix=/tmp/krava
            make_no_libaudit_O: && make NO_LIBAUDIT=1
             make_util_map_o_O: && make util/map.o
              make_no_libelf_O: && make NO_LIBELF=1
             make_no_scripts_O: && make NO_LIBPYTHON=1 NO_LIBPERL=1
                make_no_gtk2_O: && make NO_GTK2=1
           make_no_backtrace_O: && make NO_BACKTRACE=1
                make_minimal_O: && make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
                  make_no_ui_O: && make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
            make_no_auxtrace_O: && make NO_AUXTRACE=1
                 make_perf_o_O: && make perf.o
   make_install_prefix_slash_O: && make install prefix=/tmp/krava/
        make_with_babeltrace_O: && make LIBBABELTRACE=1
                make_no_newt_O: && make NO_NEWT=1
             make_no_libperl_O: && make NO_LIBPERL=1
            make_no_demangle_O: && make NO_DEMANGLE=1
                  make_debug_O: && make DEBUG=1
           make_no_libunwind_O: && make NO_LIBUNWIND=1
                   make_tags_O: && make tags
            make_install_bin_O: && make install-bin
              make_no_libbpf_O: && make NO_LIBBPF=1
                   make_help_O: && make help
                   make_pure_O: && make
                 make_static_O: && make LDFLAGS=-static
         make_with_clangllvm_O: && make LIBCLANGLLVM=1
       make_util_pmu_bison_o_O: && make util/pmu-bison.o
           make_no_libbionic_O: && make NO_LIBBIONIC=1
               make_no_slang_O: && make NO_SLANG=1
           make_no_libpython_O: && make NO_LIBPYTHON=1
              make_clean_all_O: && make clean all
  make_no_libdw_dwarf_unwind_O: && make NO_LIBDW_DWARF_UNWIND=1
             make_no_libnuma_O: && make NO_LIBNUMA=1
                make_install_O: && make install
  OK
  make: Leaving directory '/home/acme/git/linux/tools/perf'
  $

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2016-12-13 15:09 Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-12-13 15:09 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexander Shishkin, Alexei Starovoitov, Alexis Berlemont,
	Andi Kleen, Daniel Borkmann, David Ahern, Hemant Kumar,
	Jiri Olsa, Joe Stringer, Masami Hiramatsu, Minchan Kim,
	Namhyung Kim, Peter Zijlstra, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Hi Ingo,

	Please consider pulling, I had most of this queued before your first
pull req to Linus for 4.10, most are fixes, with 'perf sched timehist --idle'
as a followup new feature to the 'perf sched timehist' command introduced in
this window.

Thanks,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit b0c1ef52959582144bbea9a2b37db7f4c9e399f7:

  perf/x86: Fix exclusion of BTS and LBR for Goldmont (2016-12-11 13:06:09 +0100)

are available in the git repository at:

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

for you to fetch changes up to a03f73547fb6e0f7f2942c46cce9b48df50238ba:

  samples/bpf: Drop unnecessary build targets. (2016-12-13 10:38:10 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

New features:

- Introduce 'perf sched timehist --idle', to analyse processes
  going to/from idle state (Namhyung Kim)

- Add scanning of SDT (Software Defined Tracing) probles arguments (Alexis Berlemont)

Fixes:

- Allow 'perf record -u user' to continue when facing races with threads
  going away after having scanned them via /proc (Jiri Olsa)

- Fix 'perf mem' --all-user/--all-kernel options (Jiri Olsa)

Infrastructure:

- Switch over samples/bpf/ to tools/lib/bpf, removing libbpf duplication (Joe Stringer)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Alexis Berlemont (1):
      perf sdt: Add scanning of sdt probles arguments

Arnaldo Carvalho de Melo (1):
      perf tools: Remove some needless __maybe_unused

Jiri Olsa (6):
      perf tools: Move headers check into bash script
      perf mem: Fix --all-user/--all-kernel options
      perf evsel: Use variable instead of repeating lengthy FD macro
      perf thread_map: Add thread_map__remove function
      perf evsel: Allow to ignore missing pid
      perf record: Force ignore_missing_thread for uid option

Joe Stringer (8):
      tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h
      tools lib bpf: use __u32 from linux/types.h
      tools lib bpf: Add flags to bpf_create_map()
      samples/bpf: Make samples more libbpf-centric
      samples/bpf: Switch over to libbpf
      samples/bpf: Remove perf_event_open() declaration
      samples/bpf: Move open_raw_sock to separate header
      samples/bpf: Drop unnecessary build targets.

Namhyung Kim (6):
      perf sched timehist: Split is_idle_sample()
      perf sched timehist: Introduce struct idle_time_data
      perf sched timehist: Save callchain when entering idle
      perf sched timehist: Skip non-idle events when necessary
      perf sched timehist: Add -I/--idle-hist option
      perf sched timehist: Show callchains for idle stat

 samples/bpf/Makefile                              |  60 ++---
 samples/bpf/README.rst                            |   4 +-
 samples/bpf/bpf_load.c                            |  20 +-
 samples/bpf/fds_example.c                         |  10 +-
 samples/bpf/lathist_user.c                        |   3 +-
 samples/bpf/libbpf.c                              | 155 -------------
 samples/bpf/libbpf.h                              |  25 +--
 samples/bpf/map_perf_test_user.c                  |   1 +
 samples/bpf/offwaketime_user.c                    |  10 +-
 samples/bpf/sampleip_user.c                       |   8 +-
 samples/bpf/sock_example.c                        |  11 +-
 samples/bpf/sock_example.h                        |  35 +++
 samples/bpf/sockex1_user.c                        |   9 +-
 samples/bpf/sockex2_user.c                        |   7 +-
 samples/bpf/sockex3_user.c                        |   7 +-
 samples/bpf/spintest_user.c                       |  10 +-
 samples/bpf/tc_l2_redirect_user.c                 |   4 +-
 samples/bpf/test_cgrp2_array_pin.c                |   4 +-
 samples/bpf/test_current_task_under_cgroup_user.c |  10 +-
 samples/bpf/test_maps.c                           | 142 ++++++------
 samples/bpf/test_overhead_user.c                  |   2 +
 samples/bpf/test_probe_write_user_user.c          |   4 +-
 samples/bpf/test_verifier.c                       |   8 +-
 samples/bpf/trace_event_user.c                    |  24 +-
 samples/bpf/trace_output_user.c                   |   6 +-
 samples/bpf/tracex1_user.c                        |   2 +
 samples/bpf/tracex2_user.c                        |  12 +-
 samples/bpf/tracex3_user.c                        |   6 +-
 samples/bpf/tracex4_user.c                        |   6 +-
 samples/bpf/tracex5_user.c                        |   2 +
 samples/bpf/tracex6_user.c                        |   7 +-
 samples/bpf/xdp1_user.c                           |   4 +-
 tools/include/uapi/linux/bpf.h                    |  51 +++++
 tools/lib/bpf/bpf.c                               |   7 +-
 tools/lib/bpf/bpf.h                               |   6 +-
 tools/lib/bpf/libbpf.c                            |   3 +-
 tools/perf/Documentation/perf-sched.txt           |   4 +
 tools/perf/Makefile.perf                          |  94 +-------
 tools/perf/builtin-c2c.c                          |  13 +-
 tools/perf/builtin-mem.c                          |   4 +-
 tools/perf/builtin-record.c                       |   3 +
 tools/perf/builtin-report.c                       |   2 +-
 tools/perf/builtin-sched.c                        | 261 +++++++++++++++++++---
 tools/perf/builtin-stat.c                         |   6 +-
 tools/perf/check-headers.sh                       |  59 +++++
 tools/perf/perf.h                                 |   1 +
 tools/perf/tests/builtin-test.c                   |   4 +
 tools/perf/tests/tests.h                          |   1 +
 tools/perf/tests/thread-map.c                     |  44 ++++
 tools/perf/util/evsel.c                           |  61 ++++-
 tools/perf/util/evsel.h                           |   1 +
 tools/perf/util/symbol-elf.c                      |  25 ++-
 tools/perf/util/symbol.h                          |   1 +
 tools/perf/util/thread_map.c                      |  22 ++
 tools/perf/util/thread_map.h                      |   1 +
 55 files changed, 786 insertions(+), 506 deletions(-)
 delete mode 100644 samples/bpf/libbpf.c
 create mode 100644 samples/bpf/sock_example.h
 create mode 100755 tools/perf/check-headers.sh

  # uname -a
  Linux jouet 4.9.0-rc8+ #1 SMP Mon Dec 12 11:20:49 BRT 2016 x86_64 x86_64 x86_64 GNU/Linux
  # perf test
   1: vmlinux symtab matches kallsyms            : Ok
   2: Detect openat syscall event                : Ok
   3: Detect openat syscall event on all cpus    : Ok
   4: Read samples using the mmap interface      : Ok
   5: Parse event definition strings             : Ok
   6: PERF_RECORD_* events & perf_sample fields  : Ok
   7: Parse perf pmu format                      : Ok
   8: DSO data read                              : Ok
   9: DSO data cache                             : Ok
  10: DSO data reopen                            : Ok
  11: Roundtrip evsel->name                      : Ok
  12: Parse sched tracepoints fields             : Ok
  13: syscalls:sys_enter_openat event fields     : Ok
  14: Setup struct perf_event_attr               : Ok
  15: Match and link multiple hists              : Ok
  16: 'import perf' in python                    : Ok
  17: Breakpoint overflow signal handler         : Ok
  18: Breakpoint overflow sampling               : Ok
  19: Number of exit events of a simple workload : Ok
  20: Software clock events period values        : Ok
  21: Object code reading                        : Ok
  22: Sample parsing                             : Ok
  23: Use a dummy software event to keep tracking: Ok
  24: Parse with no sample_id_all bit set        : Ok
  25: Filter hist entries                        : Ok
  26: Lookup mmap thread                         : Ok
  27: Share thread mg                            : Ok
  28: Sort output of hist entries                : Ok
  29: Cumulate child hist entries                : Ok
  30: Track with sched_switch                    : Ok
  31: Filter fds with revents mask in a fdarray  : Ok
  32: Add fd to a fdarray, making it autogrow    : Ok
  33: kmod_path__parse                           : Ok
  34: Thread map                                 : Ok
  35: LLVM search and compile                    :
  35.1: Basic BPF llvm compile                    : Ok
  35.2: kbuild searching                          : Ok
  35.3: Compile source for BPF prologue generation: Ok
  35.4: Compile source for BPF relocation         : Ok
  36: Session topology                           : Ok
  37: BPF filter                                 :
  37.1: Basic BPF filtering                      : Ok
  37.2: BPF prologue generation                  : Ok
  37.3: BPF relocation checker                   : Ok
  38: Synthesize thread map                      : Ok
  39: Remove thread map                          : Ok
  40: Synthesize cpu map                         : Ok
  41: Synthesize stat config                     : Ok
  42: Synthesize stat                            : Ok
  43: Synthesize stat round                      : Ok
  44: Synthesize attr update                     : Ok
  45: Event times                                : Ok
  46: Read backward ring buffer                  : Ok
  47: Print cpu map                              : Ok
  48: Probe SDT events                           : Ok
  49: is_printable_array                         : Ok
  50: Print bitmap                               : Ok
  51: perf hooks                                 : Ok
  52: builtin clang support                      : Skip (not compiled in)
  53: x86 rdpmc                                  : Ok
  54: Convert perf time to TSC                   : Ok
  55: DWARF unwind                               : Ok
  56: x86 instruction decoder - new instructions : Ok
  57: Intel cqm nmi context read                 : Skip
  #
  # time dm
     1 alpine:3.4: Ok
     2 android-ndk:r12b-arm: Ok
     3 archlinux:latest: Ok
     4 centos:5: Ok
     5 centos:6: Ok
     6 centos:7: Ok
     7 debian:7: Ok
     8 debian:8: Ok
     9 debian:experimental: Ok
    10 debian:experimental-x-mips64: Ok
    11 fedora:20: Ok
    12 fedora:21: Ok
    13 fedora:22: Ok
    14 fedora:23: Ok
    15 fedora:24: Ok
    16 fedora:24-x-ARC-uClibc: Ok
    17 fedora:25: Ok
    18 fedora:rawhide: Ok
    19 mageia:5: Ok
    20 opensuse:13.2: Ok
    21 opensuse:42.1: Ok
    22 opensuse:tumbleweed: Ok
    23 ubuntu:12.04.5: Ok
    24 ubuntu:14.04.4-x-linaro-arm64: Ok
    25 ubuntu:16.04: Ok
    26 ubuntu:16.04-x-arm: Ok
    27 ubuntu:16.04-x-arm64: Ok
    28 ubuntu:16.04-x-powerpc: Ok
    29 ubuntu:16.04-x-powerpc64: Ok
    30 ubuntu:16.04-x-powerpc64el: Ok
    31 ubuntu:16.04-x-s390: Ok
    32 ubuntu:16.10: Ok
  #
  [acme@felicio linux]$ make -C tools/perf build-test
  make: Entering directory `/home/acme/git/linux/tools/perf'
  - tarpkg: ./tests/perf-targz-src-pkg .
        make_with_babeltrace_O: make LIBBABELTRACE=1
         make_with_clangllvm_O: make LIBCLANGLLVM=1
                    make_doc_O: make doc
                 make_cscope_O: make cscope
                  make_debug_O: make DEBUG=1
             make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
                 make_perf_o_O: make perf.o
            make_install_bin_O: make install-bin
                make_no_newt_O: make NO_NEWT=1
               make_no_slang_O: make NO_SLANG=1
              make_clean_all_O: make clean all
                   make_help_O: make help
           make_no_libbionic_O: make NO_LIBBIONIC=1
  make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
            make_no_demangle_O: make NO_DEMANGLE=1
              make_no_libelf_O: make NO_LIBELF=1
                   make_pure_O: make
             make_no_libnuma_O: make NO_LIBNUMA=1
              make_no_libbpf_O: make NO_LIBBPF=1
                make_no_gtk2_O: make NO_GTK2=1
           make_no_libpython_O: make NO_LIBPYTHON=1
             make_no_libperl_O: make NO_LIBPERL=1
            make_no_libaudit_O: make NO_LIBAUDIT=1
                 make_static_O: make LDFLAGS=-static
             make_util_map_o_O: make util/map.o
   make_install_prefix_slash_O: make install prefix=/tmp/krava/
         make_install_prefix_O: make install prefix=/tmp/krava
       make_util_pmu_bison_o_O: make util/pmu-bison.o
                   make_tags_O: make tags
                  make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
                make_install_O: make install
            make_no_auxtrace_O: make NO_AUXTRACE=1
           make_no_backtrace_O: make NO_BACKTRACE=1
                make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
           make_no_libunwind_O: make NO_LIBUNWIND=1
  OK
  make: Leaving directory `/home/acme/git/linux/tools/perf'
  [acme@felicio linux]$

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [GIT PULL 00/22] perf/core improvements and fixes
  2016-10-04  2:36 Arnaldo Carvalho de Melo
@ 2016-10-04  8:07 ` Ingo Molnar
  0 siblings, 0 replies; 36+ messages in thread
From: Ingo Molnar @ 2016-10-04  8:07 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Linux Weekly News, Adrian Hunter,
	Alexander Shishkin, Andi Kleen, Colin Ian King, David Ahern,
	Jiri Olsa, linuxppc-dev, Madhavan Srinivasan, Masami Hiramatsu,
	Namhyung Kim, Peter Zijlstra, Ravi Bangoria, Sukadev Bhattiprolu,
	Wang Nan, Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> Build and test stats at the end of the message.
> 
> The following changes since commit 41aad2a6d4fcdda8d73c9739daf7a9f3f49499d6:
> 
>   Merge tag 'perf-core-for-mingo-20160929' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-09-29 19:09:58 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20161003
> 
> for you to fetch changes up to b42c7369e3f451e22c2b0be5d193955498d37546:
> 
>   perf pmu-events: Add Skylake frontend MSR support (2016-10-03 21:52:01 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> - Allow vendors to provide JSON files describing PMU events, that then
>   get parsed to generate C tables that are linked against perf, allowing
>   the use of the names in their documentations, such as:
> 
>   # perf list l1d
> 
>   List of pre-defined events (to be used in -e):
> 
>   Cache:
>     l1d.replacement
>          [L1D data line replacements]
>     l1d_pend_miss.fb_full
>          [Cycles a demand request was blocked due to Fill Buffers inavailability]
>     l1d_pend_miss.pending
>          [L1D miss oustandings duration in cycles]
>     l1d_pend_miss.pending_cycles
>          [Cycles with L1D load Misses outstanding]
>     l1d_pend_miss.pending_cycles_any
>          [Cycles with L1D load Misses outstanding from any thread on physical core]
>     l2_trans.l1d_wb
>          [L1D writebacks that access L2 cache]
> 
>   Pipeline:
>     cycle_activity.cycles_l1d_miss
>          [Cycles while L1 cache miss demand load is outstanding]
>     cycle_activity.cycles_l1d_pending
>          [Cycles while L1 cache miss demand load is outstanding]
>     cycle_activity.stalls_l1d_miss
>          [Execution stalls while L1 cache miss demand load is outstanding]
>     cycle_activity.stalls_l1d_pending
>          [Execution stalls while L1 cache miss demand load is outstanding]
> 
>   The above example was done on a Broadwell based ThinkPad t450s after
>   downloading and installing such JSON files which will be added to the
>   tools/perf/pmu-events/ directory in a subsequent patchkit.
> 
>   Now one can use those names with -e/--event in all 'perf tools'.
>   (Andi Kleen, Sukadev Bhattiprolu)
> 
> - Add a missing pointer dereference in 'perf probe' (Colin Ian King)
> 
> - Add support for building host programs to be used in generating files
>   to be used in the build process, such as fixdep and jevents, fixing
>   the usage of these features in a cross compilation setup (Jiri Olsa)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Andi Kleen (12):
>       perf tools: Add jsmn `jasmine' JSON parser
>       perf jevents: Program to convert JSON file
>       perf tools: Support CPU id matching for x86 v2
>       perf jevents: Handle header line in mapfile
>       perf pmu: Support alias descriptions
>       perf tools: Query terminal width and use in perf list
>       perf list: Add a --no-desc flag
>       perf pmu: Add override support for event list CPUID
>       perf list jevents: Add support for event list topics
>       perf tools: Make alias matching case-insensitive
>       perf pmu-events: Fix fixed counters on Intel
>       perf pmu-events: Add Skylake frontend MSR support
> 
> Arnaldo Carvalho de Melo (1):
>       perf tools: Experiment with cppcheck
> 
> Colin Ian King (1):
>       perf probe: Check if *ptr2 is zero and not ptr2
> 
> Jiri Olsa (2):
>       tools build: Add support for host programs format
>       tools build: Make fixdep a hostprog
> 
> Sukadev Bhattiprolu (6):
>       perf pmu: Use pmu_events table to create aliases
>       perf powerpc: Support CPU ID matching for Powerpc
>       perf jevents: Add support for long descriptions
>       perf list: Support long jevents descriptions
>       perf tools: Add README for info on parsing JSON/map files
>       perf tools: Allow period= in perf stat CPU event descriptions.
> 
>  tools/build/Build                      |   2 +
>  tools/build/Build.include              |   5 +
>  tools/build/Makefile                   |   8 +-
>  tools/build/Makefile.build             |  19 +-
>  tools/build/Makefile.include           |   4 -
>  tools/lib/subcmd/pager.c               |  16 +
>  tools/lib/subcmd/pager.h               |   1 +
>  tools/perf/Documentation/perf-list.txt |  12 +-
>  tools/perf/Makefile.perf               |  34 +-
>  tools/perf/arch/powerpc/util/header.c  |  11 +
>  tools/perf/arch/x86/util/header.c      |  24 +-
>  tools/perf/builtin-list.c              |  20 +-
>  tools/perf/pmu-events/Build            |  13 +
>  tools/perf/pmu-events/README           | 147 ++++++
>  tools/perf/pmu-events/jevents.c        | 812 +++++++++++++++++++++++++++++++++
>  tools/perf/pmu-events/jevents.h        |  18 +
>  tools/perf/pmu-events/jsmn.c           | 313 +++++++++++++
>  tools/perf/pmu-events/jsmn.h           |  67 +++
>  tools/perf/pmu-events/json.c           | 162 +++++++
>  tools/perf/pmu-events/json.h           |  38 ++
>  tools/perf/pmu-events/pmu-events.h     |  37 ++
>  tools/perf/util/evlist.c               |  12 +-
>  tools/perf/util/evsel.c                |   3 +-
>  tools/perf/util/header.h               |   1 +
>  tools/perf/util/machine.c              |   6 +-
>  tools/perf/util/parse-events.c         |   8 +-
>  tools/perf/util/parse-events.h         |   3 +-
>  tools/perf/util/pmu.c                  | 176 ++++++-
>  tools/perf/util/pmu.h                  |   6 +-
>  tools/perf/util/probe-event.c          |   2 +-
>  tools/perf/util/strbuf.h               |   3 +-
>  tools/perf/util/thread.c               |   9 +-
>  32 files changed, 1926 insertions(+), 66 deletions(-)
>  create mode 100644 tools/perf/pmu-events/Build
>  create mode 100644 tools/perf/pmu-events/README
>  create mode 100644 tools/perf/pmu-events/jevents.c
>  create mode 100644 tools/perf/pmu-events/jevents.h
>  create mode 100644 tools/perf/pmu-events/jsmn.c
>  create mode 100644 tools/perf/pmu-events/jsmn.h
>  create mode 100644 tools/perf/pmu-events/json.c
>  create mode 100644 tools/perf/pmu-events/json.h
>  create mode 100644 tools/perf/pmu-events/pmu-events.h
> 
>   # time dm
>    1 alpine:3.4: Ok
>    2 android-ndk:r12b-arm: Ok
>    3 archlinux:latest: Ok
>    4 centos:5: Ok
>    5 centos:6: Ok
>    6 centos:7: Ok
>    7 debian:7: Ok
>    8 debian:8: Ok
>    9 debian:experimental: Ok
>   10 fedora:20: Ok
>   11 fedora:21: Ok
>   12 fedora:22: Ok
>   13 fedora:23: Ok
>   14 fedora:24: Ok
>   15 fedora:24-x-ARC-uClibc: Ok
>   16 fedora:rawhide: Ok
>   17 mageia:5: Ok
>   18 opensuse:13.2: Ok
>   19 opensuse:42.1: Ok
>   20 opensuse:tumbleweed: Ok
>   21 ubuntu:12.04.5: Ok
>   22 ubuntu:14.04: Ok
>   23 ubuntu:14.04.4: Ok
>   24 ubuntu:15.10: Ok
>   25 ubuntu:16.04: Ok
>   26 ubuntu:16.04-x-arm: Ok
>   27 ubuntu:16.04-x-arm64: Ok
>   28 ubuntu:16.04-x-powerpc: Ok
>   29 ubuntu:16.04-x-powerpc64: Ok
>   30 ubuntu:16.04-x-powerpc64el: Ok
>   31 ubuntu:16.04-x-s390: Ok
>   32 ubuntu:16.10: Ok
> 
>   real	33m23.855s
>   user	0m2.128s
>   sys	0m2.305s
>   #
> 
>   # perf test
>    1: vmlinux symtab matches kallsyms                          : Ok
>    2: detect openat syscall event                              : Ok
>    3: detect openat syscall event on all cpus                  : Ok
>    4: read samples using the mmap interface                    : Ok
>    5: parse events tests                                       : Ok
>    6: Validate PERF_RECORD_* events & perf_sample fields       : Ok
>    7: Test perf pmu format parsing                             : Ok
>    8: Test dso data read                                       : Ok
>    9: Test dso data cache                                      : Ok
>   10: Test dso data reopen                                     : Ok
>   11: roundtrip evsel->name check                              : Ok
>   12: Check parsing of sched tracepoints fields                : Ok
>   13: Generate and check syscalls:sys_enter_openat event fields: Ok
>   14: struct perf_event_attr setup                             : Ok
>   15: Test matching and linking multiple hists                 : Ok
>   16: Try 'import perf' in python, checking link problems      : Ok
>   17: Test breakpoint overflow signal handler                  : Ok
>   18: Test breakpoint overflow sampling                        : Ok
>   19: Test number of exit event of a simple workload           : Ok
>   20: Test software clock events have valid period values      : Ok
>   21: Test object code reading                                 : Ok
>   22: Test sample parsing                                      : Ok
>   23: Test using a dummy software event to keep tracking       : Ok
>   24: Test parsing with no sample_id_all bit set               : Ok
>   25: Test filtering hist entries                              : Ok
>   26: Test mmap thread lookup                                  : Ok
>   27: Test thread mg sharing                                   : Ok
>   28: Test output sorting of hist entries                      : Ok
>   29: Test cumulation of child hist entries                    : Ok
>   30: Test tracking with sched_switch                          : Ok
>   31: Filter fds with revents mask in a fdarray                : Ok
>   32: Add fd to a fdarray, making it autogrow                  : Ok
>   33: Test kmod_path__parse function                           : Ok
>   34: Test thread map                                          : Ok
>   35: Test LLVM searching and compiling                        :
>   35.1: Basic BPF llvm compiling test                          : Ok
>   35.2: Test kbuild searching                                  : Ok
>   35.3: Compile source for BPF prologue generation test        : Ok
>   35.4: Compile source for BPF relocation test                 : Ok
>   36: Test topology in session                                 : Ok
>   37: Test BPF filter                                          :
>   37.1: Test basic BPF filtering                               : Ok
>   37.2: Test BPF prologue generation                           : Ok
>   37.3: Test BPF relocation checker                            : Ok
>   38: Test thread map synthesize                               : Ok
>   39: Test cpu map synthesize                                  : Ok
>   40: Test stat config synthesize                              : Ok
>   41: Test stat synthesize                                     : Ok
>   42: Test stat round synthesize                               : Ok
>   43: Test attr update synthesize                              : Ok
>   44: Test events times                                        : Ok
>   45: Test backward reading from ring buffer                   : Ok
>   46: Test cpu map print                                       : Ok
>   47: Test SDT event probing                                   : Ok
>   48: Test is_printable_array function                         : Ok
>   49: Test bitmap print                                        : Ok
>   50: x86 rdpmc test                                           : Ok
>   51: Test converting perf time to TSC                         : Ok
>   52: Test dwarf unwind                                        : Ok
>   53: Test x86 instruction decoder - new instructions          : Ok
>   54: Test intel cqm nmi context read                          : Skip
>   # 
> 
>   $ make -C tools/perf build-test
>   make: Entering directory '/home/acme/git/linux/tools/perf'
>                       - tarpkg: ./tests/perf-targz-src-pkg .
>              make_no_libperl_O: make NO_LIBPERL=1
>                 make_no_newt_O: make NO_NEWT=1
>                make_no_slang_O: make NO_SLANG=1
>              make_no_libnuma_O: make NO_LIBNUMA=1
>         make_with_babeltrace_O: make LIBBABELTRACE=1
>    make_install_prefix_slash_O: make install prefix=/tmp/krava/
>               make_no_libbpf_O: make NO_LIBBPF=1
>             make_no_demangle_O: make NO_DEMANGLE=1
>             make_install_bin_O: make install-bin
>                 make_install_O: make install
>            make_no_libbionic_O: make NO_LIBBIONIC=1
>            make_no_libunwind_O: make NO_LIBUNWIND=1
>             make_no_libaudit_O: make NO_LIBAUDIT=1
>            make_no_libpython_O: make NO_LIBPYTHON=1
>                    make_tags_O: make tags
>                  make_perf_o_O: make perf.o
>                  make_static_O: make LDFLAGS=-static
>               make_clean_all_O: make clean all
>          make_install_prefix_O: make install prefix=/tmp/krava
>                    make_help_O: make help
>              make_util_map_o_O: make util/map.o
>                   make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
>   make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
>                 make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1
>            make_no_backtrace_O: make NO_BACKTRACE=1
>                   make_debug_O: make DEBUG=1
>               make_no_libelf_O: make NO_LIBELF=1
>              make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
>             make_no_auxtrace_O: make NO_AUXTRACE=1
>                     make_doc_O: make doc
>        make_util_pmu_bison_o_O: make util/pmu-bison.o
>                 make_no_gtk2_O: make NO_GTK2=1
>   OK

Pulled, thanks a lot Arnaldo!

	Ingo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2016-10-04  2:36 Arnaldo Carvalho de Melo
  2016-10-04  8:07 ` Ingo Molnar
  0 siblings, 1 reply; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-04  2:36 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Linux Weekly News, Arnaldo Carvalho de Melo,
	Adrian Hunter, Alexander Shishkin, Andi Kleen, Colin Ian King,
	David Ahern, Jiri Olsa, linuxppc-dev, Madhavan Srinivasan,
	Masami Hiramatsu, Namhyung Kim, Peter Zijlstra, Ravi Bangoria,
	Sukadev Bhattiprolu, Wang Nan, Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling,

- Arnaldo

Build and test stats at the end of the message.

The following changes since commit 41aad2a6d4fcdda8d73c9739daf7a9f3f49499d6:

  Merge tag 'perf-core-for-mingo-20160929' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-09-29 19:09:58 +0200)

are available in the git repository at:

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

for you to fetch changes up to b42c7369e3f451e22c2b0be5d193955498d37546:

  perf pmu-events: Add Skylake frontend MSR support (2016-10-03 21:52:01 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

- Allow vendors to provide JSON files describing PMU events, that then
  get parsed to generate C tables that are linked against perf, allowing
  the use of the names in their documentations, such as:

  # perf list l1d

  List of pre-defined events (to be used in -e):

  Cache:
    l1d.replacement
         [L1D data line replacements]
    l1d_pend_miss.fb_full
         [Cycles a demand request was blocked due to Fill Buffers inavailability]
    l1d_pend_miss.pending
         [L1D miss oustandings duration in cycles]
    l1d_pend_miss.pending_cycles
         [Cycles with L1D load Misses outstanding]
    l1d_pend_miss.pending_cycles_any
         [Cycles with L1D load Misses outstanding from any thread on physical core]
    l2_trans.l1d_wb
         [L1D writebacks that access L2 cache]

  Pipeline:
    cycle_activity.cycles_l1d_miss
         [Cycles while L1 cache miss demand load is outstanding]
    cycle_activity.cycles_l1d_pending
         [Cycles while L1 cache miss demand load is outstanding]
    cycle_activity.stalls_l1d_miss
         [Execution stalls while L1 cache miss demand load is outstanding]
    cycle_activity.stalls_l1d_pending
         [Execution stalls while L1 cache miss demand load is outstanding]

  The above example was done on a Broadwell based ThinkPad t450s after
  downloading and installing such JSON files which will be added to the
  tools/perf/pmu-events/ directory in a subsequent patchkit.

  Now one can use those names with -e/--event in all 'perf tools'.
  (Andi Kleen, Sukadev Bhattiprolu)

- Add a missing pointer dereference in 'perf probe' (Colin Ian King)

- Add support for building host programs to be used in generating files
  to be used in the build process, such as fixdep and jevents, fixing
  the usage of these features in a cross compilation setup (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Andi Kleen (12):
      perf tools: Add jsmn `jasmine' JSON parser
      perf jevents: Program to convert JSON file
      perf tools: Support CPU id matching for x86 v2
      perf jevents: Handle header line in mapfile
      perf pmu: Support alias descriptions
      perf tools: Query terminal width and use in perf list
      perf list: Add a --no-desc flag
      perf pmu: Add override support for event list CPUID
      perf list jevents: Add support for event list topics
      perf tools: Make alias matching case-insensitive
      perf pmu-events: Fix fixed counters on Intel
      perf pmu-events: Add Skylake frontend MSR support

Arnaldo Carvalho de Melo (1):
      perf tools: Experiment with cppcheck

Colin Ian King (1):
      perf probe: Check if *ptr2 is zero and not ptr2

Jiri Olsa (2):
      tools build: Add support for host programs format
      tools build: Make fixdep a hostprog

Sukadev Bhattiprolu (6):
      perf pmu: Use pmu_events table to create aliases
      perf powerpc: Support CPU ID matching for Powerpc
      perf jevents: Add support for long descriptions
      perf list: Support long jevents descriptions
      perf tools: Add README for info on parsing JSON/map files
      perf tools: Allow period= in perf stat CPU event descriptions.

 tools/build/Build                      |   2 +
 tools/build/Build.include              |   5 +
 tools/build/Makefile                   |   8 +-
 tools/build/Makefile.build             |  19 +-
 tools/build/Makefile.include           |   4 -
 tools/lib/subcmd/pager.c               |  16 +
 tools/lib/subcmd/pager.h               |   1 +
 tools/perf/Documentation/perf-list.txt |  12 +-
 tools/perf/Makefile.perf               |  34 +-
 tools/perf/arch/powerpc/util/header.c  |  11 +
 tools/perf/arch/x86/util/header.c      |  24 +-
 tools/perf/builtin-list.c              |  20 +-
 tools/perf/pmu-events/Build            |  13 +
 tools/perf/pmu-events/README           | 147 ++++++
 tools/perf/pmu-events/jevents.c        | 812 +++++++++++++++++++++++++++++++++
 tools/perf/pmu-events/jevents.h        |  18 +
 tools/perf/pmu-events/jsmn.c           | 313 +++++++++++++
 tools/perf/pmu-events/jsmn.h           |  67 +++
 tools/perf/pmu-events/json.c           | 162 +++++++
 tools/perf/pmu-events/json.h           |  38 ++
 tools/perf/pmu-events/pmu-events.h     |  37 ++
 tools/perf/util/evlist.c               |  12 +-
 tools/perf/util/evsel.c                |   3 +-
 tools/perf/util/header.h               |   1 +
 tools/perf/util/machine.c              |   6 +-
 tools/perf/util/parse-events.c         |   8 +-
 tools/perf/util/parse-events.h         |   3 +-
 tools/perf/util/pmu.c                  | 176 ++++++-
 tools/perf/util/pmu.h                  |   6 +-
 tools/perf/util/probe-event.c          |   2 +-
 tools/perf/util/strbuf.h               |   3 +-
 tools/perf/util/thread.c               |   9 +-
 32 files changed, 1926 insertions(+), 66 deletions(-)
 create mode 100644 tools/perf/pmu-events/Build
 create mode 100644 tools/perf/pmu-events/README
 create mode 100644 tools/perf/pmu-events/jevents.c
 create mode 100644 tools/perf/pmu-events/jevents.h
 create mode 100644 tools/perf/pmu-events/jsmn.c
 create mode 100644 tools/perf/pmu-events/jsmn.h
 create mode 100644 tools/perf/pmu-events/json.c
 create mode 100644 tools/perf/pmu-events/json.h
 create mode 100644 tools/perf/pmu-events/pmu-events.h

  # time dm
   1 alpine:3.4: Ok
   2 android-ndk:r12b-arm: Ok
   3 archlinux:latest: Ok
   4 centos:5: Ok
   5 centos:6: Ok
   6 centos:7: Ok
   7 debian:7: Ok
   8 debian:8: Ok
   9 debian:experimental: Ok
  10 fedora:20: Ok
  11 fedora:21: Ok
  12 fedora:22: Ok
  13 fedora:23: Ok
  14 fedora:24: Ok
  15 fedora:24-x-ARC-uClibc: Ok
  16 fedora:rawhide: Ok
  17 mageia:5: Ok
  18 opensuse:13.2: Ok
  19 opensuse:42.1: Ok
  20 opensuse:tumbleweed: Ok
  21 ubuntu:12.04.5: Ok
  22 ubuntu:14.04: Ok
  23 ubuntu:14.04.4: Ok
  24 ubuntu:15.10: Ok
  25 ubuntu:16.04: Ok
  26 ubuntu:16.04-x-arm: Ok
  27 ubuntu:16.04-x-arm64: Ok
  28 ubuntu:16.04-x-powerpc: Ok
  29 ubuntu:16.04-x-powerpc64: Ok
  30 ubuntu:16.04-x-powerpc64el: Ok
  31 ubuntu:16.04-x-s390: Ok
  32 ubuntu:16.10: Ok

  real	33m23.855s
  user	0m2.128s
  sys	0m2.305s
  #

  # perf test
   1: vmlinux symtab matches kallsyms                          : Ok
   2: detect openat syscall event                              : Ok
   3: detect openat syscall event on all cpus                  : Ok
   4: read samples using the mmap interface                    : Ok
   5: parse events tests                                       : Ok
   6: Validate PERF_RECORD_* events & perf_sample fields       : Ok
   7: Test perf pmu format parsing                             : Ok
   8: Test dso data read                                       : Ok
   9: Test dso data cache                                      : Ok
  10: Test dso data reopen                                     : Ok
  11: roundtrip evsel->name check                              : Ok
  12: Check parsing of sched tracepoints fields                : Ok
  13: Generate and check syscalls:sys_enter_openat event fields: Ok
  14: struct perf_event_attr setup                             : Ok
  15: Test matching and linking multiple hists                 : Ok
  16: Try 'import perf' in python, checking link problems      : Ok
  17: Test breakpoint overflow signal handler                  : Ok
  18: Test breakpoint overflow sampling                        : Ok
  19: Test number of exit event of a simple workload           : Ok
  20: Test software clock events have valid period values      : Ok
  21: Test object code reading                                 : Ok
  22: Test sample parsing                                      : Ok
  23: Test using a dummy software event to keep tracking       : Ok
  24: Test parsing with no sample_id_all bit set               : Ok
  25: Test filtering hist entries                              : Ok
  26: Test mmap thread lookup                                  : Ok
  27: Test thread mg sharing                                   : Ok
  28: Test output sorting of hist entries                      : Ok
  29: Test cumulation of child hist entries                    : Ok
  30: Test tracking with sched_switch                          : Ok
  31: Filter fds with revents mask in a fdarray                : Ok
  32: Add fd to a fdarray, making it autogrow                  : Ok
  33: Test kmod_path__parse function                           : Ok
  34: Test thread map                                          : Ok
  35: Test LLVM searching and compiling                        :
  35.1: Basic BPF llvm compiling test                          : Ok
  35.2: Test kbuild searching                                  : Ok
  35.3: Compile source for BPF prologue generation test        : Ok
  35.4: Compile source for BPF relocation test                 : Ok
  36: Test topology in session                                 : Ok
  37: Test BPF filter                                          :
  37.1: Test basic BPF filtering                               : Ok
  37.2: Test BPF prologue generation                           : Ok
  37.3: Test BPF relocation checker                            : Ok
  38: Test thread map synthesize                               : Ok
  39: Test cpu map synthesize                                  : Ok
  40: Test stat config synthesize                              : Ok
  41: Test stat synthesize                                     : Ok
  42: Test stat round synthesize                               : Ok
  43: Test attr update synthesize                              : Ok
  44: Test events times                                        : Ok
  45: Test backward reading from ring buffer                   : Ok
  46: Test cpu map print                                       : Ok
  47: Test SDT event probing                                   : Ok
  48: Test is_printable_array function                         : Ok
  49: Test bitmap print                                        : Ok
  50: x86 rdpmc test                                           : Ok
  51: Test converting perf time to TSC                         : Ok
  52: Test dwarf unwind                                        : Ok
  53: Test x86 instruction decoder - new instructions          : Ok
  54: Test intel cqm nmi context read                          : Skip
  # 

  $ make -C tools/perf build-test
  make: Entering directory '/home/acme/git/linux/tools/perf'
                      - tarpkg: ./tests/perf-targz-src-pkg .
             make_no_libperl_O: make NO_LIBPERL=1
                make_no_newt_O: make NO_NEWT=1
               make_no_slang_O: make NO_SLANG=1
             make_no_libnuma_O: make NO_LIBNUMA=1
        make_with_babeltrace_O: make LIBBABELTRACE=1
   make_install_prefix_slash_O: make install prefix=/tmp/krava/
              make_no_libbpf_O: make NO_LIBBPF=1
            make_no_demangle_O: make NO_DEMANGLE=1
            make_install_bin_O: make install-bin
                make_install_O: make install
           make_no_libbionic_O: make NO_LIBBIONIC=1
           make_no_libunwind_O: make NO_LIBUNWIND=1
            make_no_libaudit_O: make NO_LIBAUDIT=1
           make_no_libpython_O: make NO_LIBPYTHON=1
                   make_tags_O: make tags
                 make_perf_o_O: make perf.o
                 make_static_O: make LDFLAGS=-static
              make_clean_all_O: make clean all
         make_install_prefix_O: make install prefix=/tmp/krava
                   make_help_O: make help
             make_util_map_o_O: make util/map.o
                  make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
  make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
                make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1
           make_no_backtrace_O: make NO_BACKTRACE=1
                  make_debug_O: make DEBUG=1
              make_no_libelf_O: make NO_LIBELF=1
             make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
            make_no_auxtrace_O: make NO_AUXTRACE=1
                    make_doc_O: make doc
       make_util_pmu_bison_o_O: make util/pmu-bison.o
                make_no_gtk2_O: make NO_GTK2=1
  OK

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [GIT PULL 00/22] perf/core improvements and fixes
  2016-09-20 20:03 Arnaldo Carvalho de Melo
@ 2016-09-20 21:34 ` Ingo Molnar
  0 siblings, 0 replies; 36+ messages in thread
From: Ingo Molnar @ 2016-09-20 21:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Adrian Hunter, Alexander Shishkin, Andi Kleen,
	Chris Riyder, David Ahern, Don Zickus, Hemant Kumar, Jiri Olsa,
	Joe Mario, Kim Phillips, Markus Trippelsdorf, Masami Hiramatsu,
	Mathieu Poirier, Michael Ellerman, Milian Wolff, Namhyung Kim,
	Naveen N . Rao, Pawel Moll, Peter Zijlstra, pi3orama,
	Ravi Bangoria, Russell King, Taeung Song, Wang Nan, Zefan Li,
	Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit cd34cd97b7b4336aa2c623c37daffab264c7c6ce:
> 
>   perf/x86/intel/uncore: Add Skylake server uncore support (2016-09-10 11:18:52 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160920
> 
> for you to fetch changes up to 3c028a0cb5b71f47d523bc8ad2c597cb257f41fb:
> 
>   perf symbols: Do not open device files (2016-09-20 16:20:21 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Support event group view with hierarchy mode in 'perf top' and 'perf report'
>   (Namhyung Kim)
> 
>   e.g.:
> 
>   $ perf record -e '{cycles,instructions}' make
>   $ perf report --hierarchy --stdio
>   ...
>   #               Overhead  Command / Shared Object / Symbol
>   # ......................  ..................................
>   ...
>       25.74%  27.18%        sh
>          19.96%  24.14%        libc-2.24.so
>             9.55%  14.64%        [.] __strcmp_sse2
>             1.54%   0.00%        [.] __tfind
>             1.07%   1.13%        [.] _int_malloc
>             0.95%   0.00%        [.] __strchr_sse2
>             0.89%   1.39%        [.] __tsearch
>             0.76%   0.00%        [.] strlen
> 
> - Fix the dwarf regs table for x86_64, adding a missing % to the "%di"
>   register, noticed with a failing 'perf test bpf' (Arnaldo Carvalho de Melo)
> 
> - Fix handling of mmap parameters in the 'perf trace' beautifier in
>   architectures that don't have the same mappings as x86_64 (Wang Nan)
> 
> - Handle hugetbl mappings in older systems running new kernels (Wang Nan)
> 
> - Resolve 'call' operands in 'annotate', that when using /proc/kcore
>   were appearing just as hexadecimal addresses, to function names
>   (Arnaldo Carvalho de Melo)
> 
> - Fix width computation for srcline sort entry (Jiri Olsa)
> 
> - Do not ignore call instruction with indirect target in 'annotate'
>   (Ravi Bangoria)
> 
> - Handle MADV_FREE in the madvise 'trace' beautifier (Wang Nan)
> 
> - Fix build of 'perf trace' mman beautifier in !x86_64 (Wang Nan)
> 
> Infrastructure:
> 
> - Add infrastructure for PMU specific configuration, allowing to pass
>   config variables directly to the kernel PMU driver, prefixing those
>   variables with a '@', part of a larger series to support Coresight (Mathieu Poirier)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> Build stats at the end of this message.
> 
> ----------------------------------------------------------------
> Arnaldo Carvalho de Melo (5):
>       perf probe: Fix dwarf regs table for x86_64
>       perf trace beauty mmap: Fix defines for non !x86_64
>       perf tools: Do hugetlb handling in more systems
>       perf annotate: Pass the symbol's map/dso to the instruction parsers
>       perf annotate: Resolve 'call' operands to function names
> 
> Jiri Olsa (2):
>       perf hists: Fix width computation for srcline sort entry
>       perf symbols: Do not open device files
> 
> Mathieu Poirier (1):
>       perf tools: Add infrastructure for PMU specific configuration
> 
> Namhyung Kim (9):
>       perf hists browser: Fix event group display
>       perf hists: Introduce hists__match_hierarchy()
>       perf hists: Introduce hists__link_hierarchy()
>       perf hist: Initialize hierarchy tree explicitly
>       perf ui/stdio: Always reset output width for hierarchy
>       perf ui/stdio: Rename print_hierarchy_header()
>       perf report: Enable group view with hierarchy
>       perf ui/tui: Reset output width for hierarchy
>       perf hists: Factor out hists__reset_column_width()
> 
> Ravi Bangoria (1):
>       perf annotate: Do not ignore call instruction with indirect target
> 
> Wang Nan (4):
>       tools include: Add uapi mman.h for each architecture
>       perf build: Compare mman.h related headers against kernel originals
>       perf trace beauty mmap: Add missing MADV_FREE
>       tools include: Add mman macros needed by perf for all arch
> 
>  tools/arch/alpha/include/uapi/asm/mman.h       |  47 ++++++++
>  tools/arch/arc/include/uapi/asm/mman.h         |   6 +
>  tools/arch/arm/include/uapi/asm/mman.h         |   6 +
>  tools/arch/arm64/include/uapi/asm/mman.h       |   6 +
>  tools/arch/frv/include/uapi/asm/mman.h         |   6 +
>  tools/arch/h8300/include/uapi/asm/mman.h       |   6 +
>  tools/arch/hexagon/include/uapi/asm/mman.h     |   6 +
>  tools/arch/ia64/include/uapi/asm/mman.h        |   6 +
>  tools/arch/m32r/include/uapi/asm/mman.h        |   6 +
>  tools/arch/microblaze/include/uapi/asm/mman.h  |   6 +
>  tools/arch/mips/include/uapi/asm/mman.h        |  46 ++++++++
>  tools/arch/mn10300/include/uapi/asm/mman.h     |   6 +
>  tools/arch/parisc/include/uapi/asm/mman.h      |  47 ++++++++
>  tools/arch/powerpc/include/uapi/asm/mman.h     |  15 +++
>  tools/arch/s390/include/uapi/asm/mman.h        |   6 +
>  tools/arch/score/include/uapi/asm/mman.h       |   6 +
>  tools/arch/sh/include/uapi/asm/mman.h          |   6 +
>  tools/arch/sparc/include/uapi/asm/mman.h       |  15 +++
>  tools/arch/tile/include/uapi/asm/mman.h        |  15 +++
>  tools/arch/x86/include/uapi/asm/mman.h         |   5 +
>  tools/arch/xtensa/include/uapi/asm/mman.h      |  47 ++++++++
>  tools/include/uapi/asm-generic/mman-common.h   |  75 ++++++++++++
>  tools/include/uapi/asm-generic/mman.h          |  22 ++++
>  tools/include/uapi/linux/mman.h                |  13 +++
>  tools/perf/Documentation/perf-record.txt       |  12 ++
>  tools/perf/MANIFEST                            |   4 +
>  tools/perf/Makefile.perf                       |   9 ++
>  tools/perf/arch/x86/include/dwarf-regs-table.h |   2 +-
>  tools/perf/builtin-report.c                    |   1 -
>  tools/perf/trace/beauty/mmap.c                 |  72 +-----------
>  tools/perf/ui/browsers/hists.c                 |   7 +-
>  tools/perf/ui/hist.c                           |  15 +++
>  tools/perf/ui/stdio/hist.c                     |  25 +---
>  tools/perf/util/annotate.c                     |  37 +++---
>  tools/perf/util/annotate.h                     |   2 +-
>  tools/perf/util/dso.c                          |   3 +
>  tools/perf/util/event.c                        |   7 +-
>  tools/perf/util/evsel.h                        |   2 +
>  tools/perf/util/hist.c                         | 154 ++++++++++++++++++++++++-
>  tools/perf/util/hist.h                         |   1 +
>  tools/perf/util/map.c                          |   9 +-
>  tools/perf/util/parse-events.c                 |   7 +-
>  tools/perf/util/parse-events.h                 |   1 +
>  tools/perf/util/parse-events.l                 |  22 ++++
>  tools/perf/util/parse-events.y                 |  11 ++
>  tools/perf/util/sort.h                         |   1 +
>  46 files changed, 698 insertions(+), 131 deletions(-)
>  create mode 100644 tools/arch/alpha/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/arc/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/arm/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/arm64/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/frv/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/h8300/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/hexagon/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/ia64/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/m32r/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/microblaze/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/mips/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/mn10300/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/parisc/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/powerpc/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/s390/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/score/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/sh/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/sparc/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/tile/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/x86/include/uapi/asm/mman.h
>  create mode 100644 tools/arch/xtensa/include/uapi/asm/mman.h
>  create mode 100644 tools/include/uapi/asm-generic/mman-common.h
>  create mode 100644 tools/include/uapi/asm-generic/mman.h
>  create mode 100644 tools/include/uapi/linux/mman.h
> 
>   [root@jouet ~]# perf test
>    1: vmlinux symtab matches kallsyms                          : Ok
>    2: detect openat syscall event                              : Ok
>    3: detect openat syscall event on all cpus                  : Ok
>    4: read samples using the mmap interface                    : Ok
>    5: parse events tests                                       : Ok
>    6: Validate PERF_RECORD_* events & perf_sample fields       : Ok
>    7: Test perf pmu format parsing                             : Ok
>    8: Test dso data read                                       : Ok
>    9: Test dso data cache                                      : Ok
>   10: Test dso data reopen                                     : Ok
>   11: roundtrip evsel->name check                              : Ok
>   12: Check parsing of sched tracepoints fields                : Ok
>   13: Generate and check syscalls:sys_enter_openat event fields: Ok
>   14: struct perf_event_attr setup                             : Ok
>   15: Test matching and linking multiple hists                 : Ok
>   16: Try 'import perf' in python, checking link problems      : Ok
>   17: Test breakpoint overflow signal handler                  : Ok
>   18: Test breakpoint overflow sampling                        : Ok
>   19: Test number of exit event of a simple workload           : Ok
>   20: Test software clock events have valid period values      : Ok
>   21: Test object code reading                                 : Ok
>   22: Test sample parsing                                      : Ok
>   23: Test using a dummy software event to keep tracking       : Ok
>   24: Test parsing with no sample_id_all bit set               : Ok
>   25: Test filtering hist entries                              : Ok
>   26: Test mmap thread lookup                                  : Ok
>   27: Test thread mg sharing                                   : Ok
>   28: Test output sorting of hist entries                      : Ok
>   29: Test cumulation of child hist entries                    : Ok
>   30: Test tracking with sched_switch                          : Ok
>   31: Filter fds with revents mask in a fdarray                : Ok
>   32: Add fd to a fdarray, making it autogrow                  : Ok
>   33: Test kmod_path__parse function                           : Ok
>   34: Test thread map                                          : Ok
>   35: Test LLVM searching and compiling                        :
>   35.1: Basic BPF llvm compiling test                          : Ok
>   35.2: Test kbuild searching                                  : Ok
>   35.3: Compile source for BPF prologue generation test        : Ok
>   35.4: Compile source for BPF relocation test                 : Ok
>   36: Test topology in session                                 : Ok
>   37: Test BPF filter                                          :
>   37.1: Test basic BPF filtering                               : Ok
>   37.2: Test BPF prologue generation                           : Ok
>   37.3: Test BPF relocation checker                            : Ok
>   38: Test thread map synthesize                               : Ok
>   39: Test cpu map synthesize                                  : Ok
>   40: Test stat config synthesize                              : Ok
>   41: Test stat synthesize                                     : Ok
>   42: Test stat round synthesize                               : Ok
>   43: Test attr update synthesize                              : Ok
>   44: Test events times                                        : Ok
>   45: Test backward reading from ring buffer                   : Ok
>   46: Test cpu map print                                       : Ok
>   47: Test SDT event probing                                   : Ok
>   48: Test is_printable_array function                         : Ok
>   49: Test bitmap print                                        : Ok
>   50: x86 rdpmc test                                           : Ok
>   51: Test converting perf time to TSC                         : Ok
>   52: Test dwarf unwind                                        : Ok
>   53: Test x86 instruction decoder - new instructions          : Ok
>   54: Test intel cqm nmi context read                          : Skip
>   [root@jouet ~]# 
> 
> Build stats:
> 
>   # time dm
>    1 74.534 alpine:3.4: Ok
>    2 25.636 android-ndk:r12b-arm: Ok
>    3 78.066 archlinux:latest: Ok
>    4 41.189 centos:5: Ok
>    5 64.550 centos:6: Ok
>    6 74.689 centos:7: Ok
>    7 68.580 debian:7: Ok
>    8 75.115 debian:8: Ok
>    9 75.288 fedora:20: Ok
>   10 79.294 fedora:21: Ok
>   11 76.839 fedora:22: Ok
>   12 76.695 fedora:23: Ok
>   13 82.058 fedora:24: Ok
>   14 31.649 fedora:24-x-ARC-uClibc: Ok
>   15 85.826 fedora:rawhide: Ok
>   16 83.272 mageia:5: Ok
>   17 76.883 opensuse:13.2: Ok
>   18 78.530 opensuse:42.1: Ok
>   19 85.315 opensuse:tumbleweed: Ok
>   20 63.436 ubuntu:12.04.5: Ok
>   21 40.909 ubuntu:14.04: Ok
>   22 72.689 ubuntu:14.04.4: Ok
>   23 76.374 ubuntu:15.10: Ok
>   24 70.309 ubuntu:16.04: Ok
>   25 59.159 ubuntu:16.04-x-arm: Ok
>   26 56.011 ubuntu:16.04-x-arm64: Ok
>   27 56.913 ubuntu:16.04-x-powerpc64: Ok
>   28 57.442 ubuntu:16.04-x-powerpc64el: Ok
>   29 80.282 ubuntu:16.10: Ok
>   30 60.964 ubuntu:16.10-x-arm64: Ok
>   31 61.390 ubuntu:16.10-x-powerpc: Ok
>   32 63.167 ubuntu:16.10-x-s390: Ok
> 
>   real	35m54.027s
>   user	0m2.855s
>   sys	0m2.652s

Pulled, thanks a lot Arnaldo!

	Ingo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2016-09-20 20:03 Arnaldo Carvalho de Melo
  2016-09-20 21:34 ` Ingo Molnar
  0 siblings, 1 reply; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-09-20 20:03 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexander Shishkin, Andi Kleen, Chris Riyder, David Ahern,
	Don Zickus, Hemant Kumar, Jiri Olsa, Joe Mario, Kim Phillips,
	Markus Trippelsdorf, Masami Hiramatsu, Mathieu Poirier,
	Michael Ellerman, Milian Wolff, Namhyung Kim, Naveen N . Rao,
	Pawel Moll, Peter Zijlstra, pi3orama, Ravi Bangoria,
	Russell King, Taeung Song, Wang Nan, Zefan Li,
	Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit cd34cd97b7b4336aa2c623c37daffab264c7c6ce:

  perf/x86/intel/uncore: Add Skylake server uncore support (2016-09-10 11:18:52 +0200)

are available in the git repository at:

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

for you to fetch changes up to 3c028a0cb5b71f47d523bc8ad2c597cb257f41fb:

  perf symbols: Do not open device files (2016-09-20 16:20:21 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Support event group view with hierarchy mode in 'perf top' and 'perf report'
  (Namhyung Kim)

  e.g.:

  $ perf record -e '{cycles,instructions}' make
  $ perf report --hierarchy --stdio
  ...
  #               Overhead  Command / Shared Object / Symbol
  # ......................  ..................................
  ...
      25.74%  27.18%        sh
         19.96%  24.14%        libc-2.24.so
            9.55%  14.64%        [.] __strcmp_sse2
            1.54%   0.00%        [.] __tfind
            1.07%   1.13%        [.] _int_malloc
            0.95%   0.00%        [.] __strchr_sse2
            0.89%   1.39%        [.] __tsearch
            0.76%   0.00%        [.] strlen

- Fix the dwarf regs table for x86_64, adding a missing % to the "%di"
  register, noticed with a failing 'perf test bpf' (Arnaldo Carvalho de Melo)

- Fix handling of mmap parameters in the 'perf trace' beautifier in
  architectures that don't have the same mappings as x86_64 (Wang Nan)

- Handle hugetbl mappings in older systems running new kernels (Wang Nan)

- Resolve 'call' operands in 'annotate', that when using /proc/kcore
  were appearing just as hexadecimal addresses, to function names
  (Arnaldo Carvalho de Melo)

- Fix width computation for srcline sort entry (Jiri Olsa)

- Do not ignore call instruction with indirect target in 'annotate'
  (Ravi Bangoria)

- Handle MADV_FREE in the madvise 'trace' beautifier (Wang Nan)

- Fix build of 'perf trace' mman beautifier in !x86_64 (Wang Nan)

Infrastructure:

- Add infrastructure for PMU specific configuration, allowing to pass
  config variables directly to the kernel PMU driver, prefixing those
  variables with a '@', part of a larger series to support Coresight (Mathieu Poirier)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Build stats at the end of this message.

----------------------------------------------------------------
Arnaldo Carvalho de Melo (5):
      perf probe: Fix dwarf regs table for x86_64
      perf trace beauty mmap: Fix defines for non !x86_64
      perf tools: Do hugetlb handling in more systems
      perf annotate: Pass the symbol's map/dso to the instruction parsers
      perf annotate: Resolve 'call' operands to function names

Jiri Olsa (2):
      perf hists: Fix width computation for srcline sort entry
      perf symbols: Do not open device files

Mathieu Poirier (1):
      perf tools: Add infrastructure for PMU specific configuration

Namhyung Kim (9):
      perf hists browser: Fix event group display
      perf hists: Introduce hists__match_hierarchy()
      perf hists: Introduce hists__link_hierarchy()
      perf hist: Initialize hierarchy tree explicitly
      perf ui/stdio: Always reset output width for hierarchy
      perf ui/stdio: Rename print_hierarchy_header()
      perf report: Enable group view with hierarchy
      perf ui/tui: Reset output width for hierarchy
      perf hists: Factor out hists__reset_column_width()

Ravi Bangoria (1):
      perf annotate: Do not ignore call instruction with indirect target

Wang Nan (4):
      tools include: Add uapi mman.h for each architecture
      perf build: Compare mman.h related headers against kernel originals
      perf trace beauty mmap: Add missing MADV_FREE
      tools include: Add mman macros needed by perf for all arch

 tools/arch/alpha/include/uapi/asm/mman.h       |  47 ++++++++
 tools/arch/arc/include/uapi/asm/mman.h         |   6 +
 tools/arch/arm/include/uapi/asm/mman.h         |   6 +
 tools/arch/arm64/include/uapi/asm/mman.h       |   6 +
 tools/arch/frv/include/uapi/asm/mman.h         |   6 +
 tools/arch/h8300/include/uapi/asm/mman.h       |   6 +
 tools/arch/hexagon/include/uapi/asm/mman.h     |   6 +
 tools/arch/ia64/include/uapi/asm/mman.h        |   6 +
 tools/arch/m32r/include/uapi/asm/mman.h        |   6 +
 tools/arch/microblaze/include/uapi/asm/mman.h  |   6 +
 tools/arch/mips/include/uapi/asm/mman.h        |  46 ++++++++
 tools/arch/mn10300/include/uapi/asm/mman.h     |   6 +
 tools/arch/parisc/include/uapi/asm/mman.h      |  47 ++++++++
 tools/arch/powerpc/include/uapi/asm/mman.h     |  15 +++
 tools/arch/s390/include/uapi/asm/mman.h        |   6 +
 tools/arch/score/include/uapi/asm/mman.h       |   6 +
 tools/arch/sh/include/uapi/asm/mman.h          |   6 +
 tools/arch/sparc/include/uapi/asm/mman.h       |  15 +++
 tools/arch/tile/include/uapi/asm/mman.h        |  15 +++
 tools/arch/x86/include/uapi/asm/mman.h         |   5 +
 tools/arch/xtensa/include/uapi/asm/mman.h      |  47 ++++++++
 tools/include/uapi/asm-generic/mman-common.h   |  75 ++++++++++++
 tools/include/uapi/asm-generic/mman.h          |  22 ++++
 tools/include/uapi/linux/mman.h                |  13 +++
 tools/perf/Documentation/perf-record.txt       |  12 ++
 tools/perf/MANIFEST                            |   4 +
 tools/perf/Makefile.perf                       |   9 ++
 tools/perf/arch/x86/include/dwarf-regs-table.h |   2 +-
 tools/perf/builtin-report.c                    |   1 -
 tools/perf/trace/beauty/mmap.c                 |  72 +-----------
 tools/perf/ui/browsers/hists.c                 |   7 +-
 tools/perf/ui/hist.c                           |  15 +++
 tools/perf/ui/stdio/hist.c                     |  25 +---
 tools/perf/util/annotate.c                     |  37 +++---
 tools/perf/util/annotate.h                     |   2 +-
 tools/perf/util/dso.c                          |   3 +
 tools/perf/util/event.c                        |   7 +-
 tools/perf/util/evsel.h                        |   2 +
 tools/perf/util/hist.c                         | 154 ++++++++++++++++++++++++-
 tools/perf/util/hist.h                         |   1 +
 tools/perf/util/map.c                          |   9 +-
 tools/perf/util/parse-events.c                 |   7 +-
 tools/perf/util/parse-events.h                 |   1 +
 tools/perf/util/parse-events.l                 |  22 ++++
 tools/perf/util/parse-events.y                 |  11 ++
 tools/perf/util/sort.h                         |   1 +
 46 files changed, 698 insertions(+), 131 deletions(-)
 create mode 100644 tools/arch/alpha/include/uapi/asm/mman.h
 create mode 100644 tools/arch/arc/include/uapi/asm/mman.h
 create mode 100644 tools/arch/arm/include/uapi/asm/mman.h
 create mode 100644 tools/arch/arm64/include/uapi/asm/mman.h
 create mode 100644 tools/arch/frv/include/uapi/asm/mman.h
 create mode 100644 tools/arch/h8300/include/uapi/asm/mman.h
 create mode 100644 tools/arch/hexagon/include/uapi/asm/mman.h
 create mode 100644 tools/arch/ia64/include/uapi/asm/mman.h
 create mode 100644 tools/arch/m32r/include/uapi/asm/mman.h
 create mode 100644 tools/arch/microblaze/include/uapi/asm/mman.h
 create mode 100644 tools/arch/mips/include/uapi/asm/mman.h
 create mode 100644 tools/arch/mn10300/include/uapi/asm/mman.h
 create mode 100644 tools/arch/parisc/include/uapi/asm/mman.h
 create mode 100644 tools/arch/powerpc/include/uapi/asm/mman.h
 create mode 100644 tools/arch/s390/include/uapi/asm/mman.h
 create mode 100644 tools/arch/score/include/uapi/asm/mman.h
 create mode 100644 tools/arch/sh/include/uapi/asm/mman.h
 create mode 100644 tools/arch/sparc/include/uapi/asm/mman.h
 create mode 100644 tools/arch/tile/include/uapi/asm/mman.h
 create mode 100644 tools/arch/x86/include/uapi/asm/mman.h
 create mode 100644 tools/arch/xtensa/include/uapi/asm/mman.h
 create mode 100644 tools/include/uapi/asm-generic/mman-common.h
 create mode 100644 tools/include/uapi/asm-generic/mman.h
 create mode 100644 tools/include/uapi/linux/mman.h

  [root@jouet ~]# perf test
   1: vmlinux symtab matches kallsyms                          : Ok
   2: detect openat syscall event                              : Ok
   3: detect openat syscall event on all cpus                  : Ok
   4: read samples using the mmap interface                    : Ok
   5: parse events tests                                       : Ok
   6: Validate PERF_RECORD_* events & perf_sample fields       : Ok
   7: Test perf pmu format parsing                             : Ok
   8: Test dso data read                                       : Ok
   9: Test dso data cache                                      : Ok
  10: Test dso data reopen                                     : Ok
  11: roundtrip evsel->name check                              : Ok
  12: Check parsing of sched tracepoints fields                : Ok
  13: Generate and check syscalls:sys_enter_openat event fields: Ok
  14: struct perf_event_attr setup                             : Ok
  15: Test matching and linking multiple hists                 : Ok
  16: Try 'import perf' in python, checking link problems      : Ok
  17: Test breakpoint overflow signal handler                  : Ok
  18: Test breakpoint overflow sampling                        : Ok
  19: Test number of exit event of a simple workload           : Ok
  20: Test software clock events have valid period values      : Ok
  21: Test object code reading                                 : Ok
  22: Test sample parsing                                      : Ok
  23: Test using a dummy software event to keep tracking       : Ok
  24: Test parsing with no sample_id_all bit set               : Ok
  25: Test filtering hist entries                              : Ok
  26: Test mmap thread lookup                                  : Ok
  27: Test thread mg sharing                                   : Ok
  28: Test output sorting of hist entries                      : Ok
  29: Test cumulation of child hist entries                    : Ok
  30: Test tracking with sched_switch                          : Ok
  31: Filter fds with revents mask in a fdarray                : Ok
  32: Add fd to a fdarray, making it autogrow                  : Ok
  33: Test kmod_path__parse function                           : Ok
  34: Test thread map                                          : Ok
  35: Test LLVM searching and compiling                        :
  35.1: Basic BPF llvm compiling test                          : Ok
  35.2: Test kbuild searching                                  : Ok
  35.3: Compile source for BPF prologue generation test        : Ok
  35.4: Compile source for BPF relocation test                 : Ok
  36: Test topology in session                                 : Ok
  37: Test BPF filter                                          :
  37.1: Test basic BPF filtering                               : Ok
  37.2: Test BPF prologue generation                           : Ok
  37.3: Test BPF relocation checker                            : Ok
  38: Test thread map synthesize                               : Ok
  39: Test cpu map synthesize                                  : Ok
  40: Test stat config synthesize                              : Ok
  41: Test stat synthesize                                     : Ok
  42: Test stat round synthesize                               : Ok
  43: Test attr update synthesize                              : Ok
  44: Test events times                                        : Ok
  45: Test backward reading from ring buffer                   : Ok
  46: Test cpu map print                                       : Ok
  47: Test SDT event probing                                   : Ok
  48: Test is_printable_array function                         : Ok
  49: Test bitmap print                                        : Ok
  50: x86 rdpmc test                                           : Ok
  51: Test converting perf time to TSC                         : Ok
  52: Test dwarf unwind                                        : Ok
  53: Test x86 instruction decoder - new instructions          : Ok
  54: Test intel cqm nmi context read                          : Skip
  [root@jouet ~]# 

Build stats:

  # time dm
   1 74.534 alpine:3.4: Ok
   2 25.636 android-ndk:r12b-arm: Ok
   3 78.066 archlinux:latest: Ok
   4 41.189 centos:5: Ok
   5 64.550 centos:6: Ok
   6 74.689 centos:7: Ok
   7 68.580 debian:7: Ok
   8 75.115 debian:8: Ok
   9 75.288 fedora:20: Ok
  10 79.294 fedora:21: Ok
  11 76.839 fedora:22: Ok
  12 76.695 fedora:23: Ok
  13 82.058 fedora:24: Ok
  14 31.649 fedora:24-x-ARC-uClibc: Ok
  15 85.826 fedora:rawhide: Ok
  16 83.272 mageia:5: Ok
  17 76.883 opensuse:13.2: Ok
  18 78.530 opensuse:42.1: Ok
  19 85.315 opensuse:tumbleweed: Ok
  20 63.436 ubuntu:12.04.5: Ok
  21 40.909 ubuntu:14.04: Ok
  22 72.689 ubuntu:14.04.4: Ok
  23 76.374 ubuntu:15.10: Ok
  24 70.309 ubuntu:16.04: Ok
  25 59.159 ubuntu:16.04-x-arm: Ok
  26 56.011 ubuntu:16.04-x-arm64: Ok
  27 56.913 ubuntu:16.04-x-powerpc64: Ok
  28 57.442 ubuntu:16.04-x-powerpc64el: Ok
  29 80.282 ubuntu:16.10: Ok
  30 60.964 ubuntu:16.10-x-arm64: Ok
  31 61.390 ubuntu:16.10-x-powerpc: Ok
  32 63.167 ubuntu:16.10-x-s390: Ok

  real	35m54.027s
  user	0m2.855s
  sys	0m2.652s

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [GIT PULL 00/22] perf/core improvements and fixes
  2016-02-19 22:41 Arnaldo Carvalho de Melo
@ 2016-02-20 10:56 ` Ingo Molnar
  0 siblings, 0 replies; 36+ messages in thread
From: Ingo Molnar @ 2016-02-20 10:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Adrian Hunter, Alexei Starovoitov, Andi Kleen,
	Brendan Gregg, Cody P Schafer, David Ahern, Frederic Weisbecker,
	He Kuang, Jeremie Galarneau, Jiri Olsa, Kirill Smelkov, Li Zefan,
	Masami Hiramatsu, Namhyung Kim, Peter Zijlstra, pi3orama,
	Stephane Eranian, Steven Noonan, Wang Nan,
	Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit 3b364d7b587db0f0eeafde0f271e0698187de776:
> 
>   perf/core: Remove unused arguments from a bunch of functions (2016-02-17 10:37:48 +0100)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
> 
> for you to fetch changes up to 5b2ea6f2f6ac81a230e6cc68e1473e796a583f00:
> 
>   perf report: Check error during report__collapse_hists() (2016-02-19 19:17:50 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Add 'perf record' --all-user/--all-kernel options, so that one can tell
>   that all the events in the command line should be restricted to the user
>   or kernel levels (Jiri Olsa), i.e.:
> 
> 	perf record -e cycles:u,instructions:u
> 
>   is equivalent to:
> 
>         perf record --all-user -e cycles,instructions
> 
> - Fix percentage update on key press, due to the buffering code
>   (that creates hist_entries that will later be consumed) touching
>   per hists state that is used by the display thread (Namhyung Kim)
> 
> - Bail out when event modifiers not supported by 'perf stat' are
>   specified, i.e.: (Wang Nan)
> 
>   # perf stat -e cycles/no-inherit/ usleep 1
>   event syntax error: 'cycles/no-inherit/'
>                        \___ 'no-inherit' is not usable in 'perf stat'
>   # perf stat -e cycles/foo/ usleep 1
>   event syntax error: 'cycles/foo/'
>                               \___ unknown term
> 
>   valid terms: config,config1,config2,name
>   #
> 
> - Enable setting names for legacy cache, raw and numeric events, e.g: (Wang Nan)
> 
>   # perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
>   [ perf record: Woken up 1 times to write data ]
>   [ perf record: Captured and wrote 1.659 MB perf.data (844 samples) ]
>   # perf evlist
>   cycles
>   evtx
>   #
> 
> Miscelaneous/Infrastructure:
> 
> - Handled scaled == -1 case for counters in 'perf stat', fixing
>   recent, only in perf/core, regression (Andi Kleen)
> 
> - Reference count the cpu and thread maps at set_maps(), fixing the
>   'object code reading' 'perf test' entry when it was requesting a
>   perf_event_attr.sample_freq > /proc/sys/kernel/perf_event_max_sample_rate
>   (Arnaldo Carvalho de Melo)
> 
> - Improve perf_evlist__strerror_open() to provide hints for -EINVAL due
>   to perf_event_attr.sample_freq > /proc/sys/kernel/perf_event_max_sample_rate
>   (Arnaldo Carvalho de Melo)
> 
> - Add checks to various callchain and histogram routines (Namhyung Kim)
> 
> - Fix checking asprintf return value when parsing additional event config terms (Wang Nan)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Andi Kleen (1):
>       perf stat: Handled scaled == -1 case for counters
> 
> Arnaldo Carvalho de Melo (5):
>       perf evlist: Reference count the cpu and thread maps at set_maps()
>       perf evlist: Handle -EINVAL for sample_freq > max_sample_rate in strerror_open()
>       perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq
>       perf test: Reduce the sample_freq for the 'object code reading' test
>       perf tools: Introduce opt_event_config nonterminal
> 
> Jiri Olsa (1):
>       perf record: Add --all-user/--all-kernel options
> 
> Namhyung Kim (8):
>       perf hists browser: Fix percentage update on key press
>       perf callchain: Check return value of add_child()
>       perf callchain: Check return value of fill_node()
>       perf callchain: Add enum match_result for match_chain()
>       perf callchain: Check return value of split_add_child()
>       perf callchain: Check return value of append_chain_children()
>       perf hists: Return error from hists__collapse_resort()
>       perf report: Check error during report__collapse_hists()
> 
> Wang Nan (7):
>       perf bpf: Rename bpf_prog_priv__clear() to clear_prog_priv()
>       perf tools: Fix checking asprintf return value
>       perf tools: Create config_term_names array
>       perf stat: Bail out on unsupported event config modifiers
>       perf tools: Rename and move pmu_event_name to get_config_name
>       perf tools: Enable config raw and numeric events
>       perf tools: Enable config and setting names for legacy cache events
> 
>  tools/perf/Documentation/perf-record.txt |   6 ++
>  tools/perf/builtin-record.c              |   6 ++
>  tools/perf/builtin-report.c              |  14 ++-
>  tools/perf/builtin-stat.c                |   3 +-
>  tools/perf/perf.h                        |   2 +
>  tools/perf/tests/code-reading.c          |  10 +-
>  tools/perf/tests/parse-events.c          |  52 ++++++++++
>  tools/perf/util/bpf-loader.c             |   6 +-
>  tools/perf/util/callchain.c              | 102 +++++++++++++-----
>  tools/perf/util/evlist.c                 |  24 ++++-
>  tools/perf/util/evsel.c                  |  10 ++
>  tools/perf/util/hist.c                   |  55 +++++++---
>  tools/perf/util/hist.h                   |   6 +-
>  tools/perf/util/parse-events.c           | 173 ++++++++++++++++++++++++++-----
>  tools/perf/util/parse-events.h           |   8 +-
>  tools/perf/util/parse-events.l           |   3 +-
>  tools/perf/util/parse-events.y           |  75 +++++++-------
>  17 files changed, 426 insertions(+), 129 deletions(-)

Pulled, thanks a lot Arnaldo!

	Ingo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2016-02-19 22:41 Arnaldo Carvalho de Melo
  2016-02-20 10:56 ` Ingo Molnar
  0 siblings, 1 reply; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-19 22:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexei Starovoitov, Andi Kleen, Brendan Gregg, Cody P Schafer,
	David Ahern, Frederic Weisbecker, He Kuang, Jeremie Galarneau,
	Jiri Olsa, Kirill Smelkov, Li Zefan, Masami Hiramatsu,
	Namhyung Kim, Peter Zijlstra, pi3orama, Stephane Eranian,
	Steven Noonan, Wang Nan, Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit 3b364d7b587db0f0eeafde0f271e0698187de776:

  perf/core: Remove unused arguments from a bunch of functions (2016-02-17 10:37:48 +0100)

are available in the git repository at:

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

for you to fetch changes up to 5b2ea6f2f6ac81a230e6cc68e1473e796a583f00:

  perf report: Check error during report__collapse_hists() (2016-02-19 19:17:50 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Add 'perf record' --all-user/--all-kernel options, so that one can tell
  that all the events in the command line should be restricted to the user
  or kernel levels (Jiri Olsa), i.e.:

	perf record -e cycles:u,instructions:u

  is equivalent to:

        perf record --all-user -e cycles,instructions

- Fix percentage update on key press, due to the buffering code
  (that creates hist_entries that will later be consumed) touching
  per hists state that is used by the display thread (Namhyung Kim)

- Bail out when event modifiers not supported by 'perf stat' are
  specified, i.e.: (Wang Nan)

  # perf stat -e cycles/no-inherit/ usleep 1
  event syntax error: 'cycles/no-inherit/'
                       \___ 'no-inherit' is not usable in 'perf stat'
  # perf stat -e cycles/foo/ usleep 1
  event syntax error: 'cycles/foo/'
                              \___ unknown term

  valid terms: config,config1,config2,name
  #

- Enable setting names for legacy cache, raw and numeric events, e.g: (Wang Nan)

  # perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.659 MB perf.data (844 samples) ]
  # perf evlist
  cycles
  evtx
  #

Miscelaneous/Infrastructure:

- Handled scaled == -1 case for counters in 'perf stat', fixing
  recent, only in perf/core, regression (Andi Kleen)

- Reference count the cpu and thread maps at set_maps(), fixing the
  'object code reading' 'perf test' entry when it was requesting a
  perf_event_attr.sample_freq > /proc/sys/kernel/perf_event_max_sample_rate
  (Arnaldo Carvalho de Melo)

- Improve perf_evlist__strerror_open() to provide hints for -EINVAL due
  to perf_event_attr.sample_freq > /proc/sys/kernel/perf_event_max_sample_rate
  (Arnaldo Carvalho de Melo)

- Add checks to various callchain and histogram routines (Namhyung Kim)

- Fix checking asprintf return value when parsing additional event config terms (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Andi Kleen (1):
      perf stat: Handled scaled == -1 case for counters

Arnaldo Carvalho de Melo (5):
      perf evlist: Reference count the cpu and thread maps at set_maps()
      perf evlist: Handle -EINVAL for sample_freq > max_sample_rate in strerror_open()
      perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq
      perf test: Reduce the sample_freq for the 'object code reading' test
      perf tools: Introduce opt_event_config nonterminal

Jiri Olsa (1):
      perf record: Add --all-user/--all-kernel options

Namhyung Kim (8):
      perf hists browser: Fix percentage update on key press
      perf callchain: Check return value of add_child()
      perf callchain: Check return value of fill_node()
      perf callchain: Add enum match_result for match_chain()
      perf callchain: Check return value of split_add_child()
      perf callchain: Check return value of append_chain_children()
      perf hists: Return error from hists__collapse_resort()
      perf report: Check error during report__collapse_hists()

Wang Nan (7):
      perf bpf: Rename bpf_prog_priv__clear() to clear_prog_priv()
      perf tools: Fix checking asprintf return value
      perf tools: Create config_term_names array
      perf stat: Bail out on unsupported event config modifiers
      perf tools: Rename and move pmu_event_name to get_config_name
      perf tools: Enable config raw and numeric events
      perf tools: Enable config and setting names for legacy cache events

 tools/perf/Documentation/perf-record.txt |   6 ++
 tools/perf/builtin-record.c              |   6 ++
 tools/perf/builtin-report.c              |  14 ++-
 tools/perf/builtin-stat.c                |   3 +-
 tools/perf/perf.h                        |   2 +
 tools/perf/tests/code-reading.c          |  10 +-
 tools/perf/tests/parse-events.c          |  52 ++++++++++
 tools/perf/util/bpf-loader.c             |   6 +-
 tools/perf/util/callchain.c              | 102 +++++++++++++-----
 tools/perf/util/evlist.c                 |  24 ++++-
 tools/perf/util/evsel.c                  |  10 ++
 tools/perf/util/hist.c                   |  55 +++++++---
 tools/perf/util/hist.h                   |   6 +-
 tools/perf/util/parse-events.c           | 173 ++++++++++++++++++++++++++-----
 tools/perf/util/parse-events.h           |   8 +-
 tools/perf/util/parse-events.l           |   3 +-
 tools/perf/util/parse-events.y           |  75 +++++++-------
 17 files changed, 426 insertions(+), 129 deletions(-)

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [GIT PULL 00/22] perf/core improvements and fixes
  2015-08-26 15:57 Arnaldo Carvalho de Melo
@ 2015-08-28  6:24 ` Ingo Molnar
  0 siblings, 0 replies; 36+ messages in thread
From: Ingo Molnar @ 2015-08-28  6:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Adrian Hunter, Borislav Petkov, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Masami Hiramatsu, Namhyung Kim,
	pi3orama, Stephane Eranian, Steven Rostedt, Sukadev Bhattiprolu,
	Wang Nan, Zefan Li, Arnaldo Carvalho de Melo, Peter Zijlstra


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling, this replaces the previous perf-core-for-mingo
> pull req, replacing the last patch in that series and adding a few more fixes from
> Jiri and Wang,
> 
> Thanks,
> 
> - Arnaldo
> 
> The following changes since commit 0e53909a1cf0153736fb52c216558a65530d8c40:
> 
>   Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-08-22 08:45:46 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
> 
> for you to fetch changes up to a2fb3382edbea83c6f2bf6ac15e3673b2e254aad:
> 
>   tracing/uprobes: Do not print '0x (null)' when offset is 0 (2015-08-26 10:43:01 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Add support for using several Intel PT features (CYC, MTC packets), the
>   relevant documentation was updated: tools/perf/Documentation/intel-pt.txt,
>   briefly describing those packets, its purposes, how to configure them in
>   the event config terms and relevant external documentation for further
>   reading. (Adrian Hunter)
> 
> - Introduce support for probing at an absolute address, for user and kernel
>   'perf probe's, useful when one have the symbol maps on a developer machine
>   but not on an embedded system (Wang Nan)
> 
> - Fix 'perf probe' list results when a symbol can't be found or the
>   address is zero and when an offset is provided without a function (Wang Nan)
> 
> - Do not print '0x (null)' in uprobes when offset is zero (Wang Nan)
> 
> - Clear the progress bar at the end of a ordered_events flush, fixing
>   an UI artifact when, after ordering the events the screen doesn't get
>   completely redraw, for instance, when an error window covers just the
>   center of the screen and waits for user input. (Arnaldo Carvalho de Melo)
> 
> - Fix 'annotate' segfault by resetting the dso find_symbol cache when removing
>   symbols (Arnaldo Carvalho de Melo)
> 
> Infrastructure:
> 
> - Allow duplicate objects in the object list, just like it is possible to have
>   things like this, in the kernel: (Jiri Olsa)
> 
>   drivers/Makefile:obj-$(CONFIG_PCI)        += usb/
>   drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/
> 
> - Fix Intel PT 'instructions' sample period (Adrian Hunter)
> 
> - Prevent segfault when reading probe point with absolute address (Wang Nan)
> 
> Build fixes:
> 
> - Fix tarball build broken by pt/bts (Adrian Hunter)
> 
> - Remove export.h from MANIFEST, fixing the perf tarball make target (Jiri Olsa)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Adrian Hunter (11):
>       perf tools: Fix tarball build broken by pt/bts
>       perf tools: Fix Intel PT 'instructions' sample period
>       perf tools: Add Intel PT support for PSB periods
>       perf tools: Add new Intel PT packet definitions
>       perf tools: Pass Intel PT information for decoding MTC and CYC
>       perf tools: Add Intel PT support for decoding MTC packets
>       perf tools: Add Intel PT support for using MTC packets
>       perf tools: Add Intel PT support for decoding CYC packets
>       perf tools: Add Intel PT support for using CYC packets
>       perf tools: Add Intel PT support for decoding TRACESTOP packets
>       perf tools: Update Intel PT documentation
> 
> Arnaldo Carvalho de Melo (3):
>       perf annotate: Reset the dso find_symbol cache when removing symbols
>       perf ui tui progress: Implement the ui_progress_ops->finish() method
>       perf ordered_events: Clear the progress bar at the end of a flush
> 
> Jiri Olsa (2):
>       perf tools: Remove export.h from MANIFEST
>       tools build: Allow duplicate objects in the object list
> 
> Wang Nan (6):
>       perf probe: Prevent segfault when reading probe point with absolute address
>       perf probe: Fix list result when symbol can't be found
>       perf probe: Fix list result when address is zero
>       perf probe: Fix error reported when offset without function
>       perf probe: Support probing at absolute address
>       tracing/uprobes: Do not print '0x (null)' when offset is 0
> 
>  kernel/trace/trace_uprobe.c                        |  17 +-
>  tools/build/Documentation/Build.txt                |   1 +
>  tools/build/Makefile.build                         |   2 +-
>  tools/build/tests/ex/Build                         |   1 +
>  tools/perf/Documentation/intel-pt.txt              | 194 ++++++-
>  tools/perf/MANIFEST                                |   1 -
>  tools/perf/arch/x86/util/intel-pt.c                | 271 +++++++++-
>  tools/perf/builtin-annotate.c                      |   1 +
>  tools/perf/ui/tui/progress.c                       |  19 +-
>  tools/perf/util/dso.h                              |   2 +
>  tools/perf/util/intel-pt-decoder/inat.c            |   2 +-
>  tools/perf/util/intel-pt-decoder/inat.h            |   2 +-
>  tools/perf/util/intel-pt-decoder/inat_types.h      |  29 ++
>  tools/perf/util/intel-pt-decoder/insn.c            |   4 +-
>  tools/perf/util/intel-pt-decoder/insn.h            |   2 +-
>  .../perf/util/intel-pt-decoder/intel-pt-decoder.c  | 555 ++++++++++++++++++++-
>  .../perf/util/intel-pt-decoder/intel-pt-decoder.h  |   5 +
>  .../util/intel-pt-decoder/intel-pt-insn-decoder.c  |   2 +-
>  .../util/intel-pt-decoder/intel-pt-pkt-decoder.c   | 142 +++++-
>  .../util/intel-pt-decoder/intel-pt-pkt-decoder.h   |   6 +
>  tools/perf/util/intel-pt.c                         |  67 ++-
>  tools/perf/util/intel-pt.h                         |   5 +
>  tools/perf/util/ordered-events.c                   |   3 +
>  tools/perf/util/probe-event.c                      | 210 +++++++-
>  tools/perf/util/probe-event.h                      |   4 +
>  tools/perf/util/probe-finder.c                     |  21 +-
>  tools/perf/util/symbol.c                           |  10 +
>  27 files changed, 1481 insertions(+), 97 deletions(-)
>  create mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h

Pulled, thanks a lot Arnaldo!

	Ingo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [GIT PULL 00/22] perf/core improvements and fixes
@ 2015-08-26 15:57 Arnaldo Carvalho de Melo
  2015-08-28  6:24 ` Ingo Molnar
  0 siblings, 1 reply; 36+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-08-26 15:57 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Masami Hiramatsu, Namhyung Kim, pi3orama, Stephane Eranian,
	Steven Rostedt, Sukadev Bhattiprolu, Wang Nan, Zefan Li,
	Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling, this replaces the previous perf-core-for-mingo
pull req, replacing the last patch in that series and adding a few more fixes from
Jiri and Wang,

Thanks,

- Arnaldo

The following changes since commit 0e53909a1cf0153736fb52c216558a65530d8c40:

  Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-08-22 08:45:46 +0200)

are available in the git repository at:

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

for you to fetch changes up to a2fb3382edbea83c6f2bf6ac15e3673b2e254aad:

  tracing/uprobes: Do not print '0x (null)' when offset is 0 (2015-08-26 10:43:01 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Add support for using several Intel PT features (CYC, MTC packets), the
  relevant documentation was updated: tools/perf/Documentation/intel-pt.txt,
  briefly describing those packets, its purposes, how to configure them in
  the event config terms and relevant external documentation for further
  reading. (Adrian Hunter)

- Introduce support for probing at an absolute address, for user and kernel
  'perf probe's, useful when one have the symbol maps on a developer machine
  but not on an embedded system (Wang Nan)

- Fix 'perf probe' list results when a symbol can't be found or the
  address is zero and when an offset is provided without a function (Wang Nan)

- Do not print '0x (null)' in uprobes when offset is zero (Wang Nan)

- Clear the progress bar at the end of a ordered_events flush, fixing
  an UI artifact when, after ordering the events the screen doesn't get
  completely redraw, for instance, when an error window covers just the
  center of the screen and waits for user input. (Arnaldo Carvalho de Melo)

- Fix 'annotate' segfault by resetting the dso find_symbol cache when removing
  symbols (Arnaldo Carvalho de Melo)

Infrastructure:

- Allow duplicate objects in the object list, just like it is possible to have
  things like this, in the kernel: (Jiri Olsa)

  drivers/Makefile:obj-$(CONFIG_PCI)        += usb/
  drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/

- Fix Intel PT 'instructions' sample period (Adrian Hunter)

- Prevent segfault when reading probe point with absolute address (Wang Nan)

Build fixes:

- Fix tarball build broken by pt/bts (Adrian Hunter)

- Remove export.h from MANIFEST, fixing the perf tarball make target (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Adrian Hunter (11):
      perf tools: Fix tarball build broken by pt/bts
      perf tools: Fix Intel PT 'instructions' sample period
      perf tools: Add Intel PT support for PSB periods
      perf tools: Add new Intel PT packet definitions
      perf tools: Pass Intel PT information for decoding MTC and CYC
      perf tools: Add Intel PT support for decoding MTC packets
      perf tools: Add Intel PT support for using MTC packets
      perf tools: Add Intel PT support for decoding CYC packets
      perf tools: Add Intel PT support for using CYC packets
      perf tools: Add Intel PT support for decoding TRACESTOP packets
      perf tools: Update Intel PT documentation

Arnaldo Carvalho de Melo (3):
      perf annotate: Reset the dso find_symbol cache when removing symbols
      perf ui tui progress: Implement the ui_progress_ops->finish() method
      perf ordered_events: Clear the progress bar at the end of a flush

Jiri Olsa (2):
      perf tools: Remove export.h from MANIFEST
      tools build: Allow duplicate objects in the object list

Wang Nan (6):
      perf probe: Prevent segfault when reading probe point with absolute address
      perf probe: Fix list result when symbol can't be found
      perf probe: Fix list result when address is zero
      perf probe: Fix error reported when offset without function
      perf probe: Support probing at absolute address
      tracing/uprobes: Do not print '0x (null)' when offset is 0

 kernel/trace/trace_uprobe.c                        |  17 +-
 tools/build/Documentation/Build.txt                |   1 +
 tools/build/Makefile.build                         |   2 +-
 tools/build/tests/ex/Build                         |   1 +
 tools/perf/Documentation/intel-pt.txt              | 194 ++++++-
 tools/perf/MANIFEST                                |   1 -
 tools/perf/arch/x86/util/intel-pt.c                | 271 +++++++++-
 tools/perf/builtin-annotate.c                      |   1 +
 tools/perf/ui/tui/progress.c                       |  19 +-
 tools/perf/util/dso.h                              |   2 +
 tools/perf/util/intel-pt-decoder/inat.c            |   2 +-
 tools/perf/util/intel-pt-decoder/inat.h            |   2 +-
 tools/perf/util/intel-pt-decoder/inat_types.h      |  29 ++
 tools/perf/util/intel-pt-decoder/insn.c            |   4 +-
 tools/perf/util/intel-pt-decoder/insn.h            |   2 +-
 .../perf/util/intel-pt-decoder/intel-pt-decoder.c  | 555 ++++++++++++++++++++-
 .../perf/util/intel-pt-decoder/intel-pt-decoder.h  |   5 +
 .../util/intel-pt-decoder/intel-pt-insn-decoder.c  |   2 +-
 .../util/intel-pt-decoder/intel-pt-pkt-decoder.c   | 142 +++++-
 .../util/intel-pt-decoder/intel-pt-pkt-decoder.h   |   6 +
 tools/perf/util/intel-pt.c                         |  67 ++-
 tools/perf/util/intel-pt.h                         |   5 +
 tools/perf/util/ordered-events.c                   |   3 +
 tools/perf/util/probe-event.c                      | 210 +++++++-
 tools/perf/util/probe-event.h                      |   4 +
 tools/perf/util/probe-finder.c                     |  21 +-
 tools/perf/util/symbol.c                           |  10 +
 27 files changed, 1481 insertions(+), 97 deletions(-)
 create mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2018-11-30 18:27 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-21 13:12 [GIT PULL 00/22] perf/core improvements and fixes Jiri Olsa
2014-05-21 13:12 ` [PATCH 01/22] perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt Jiri Olsa
2014-05-21 13:12 ` [PATCH 02/22] perf tools: Convert sort entries to hpp formats Jiri Olsa
2014-05-21 13:12 ` [PATCH 03/22] perf tools: Use hpp formats to sort hist entries Jiri Olsa
2014-05-21 13:12 ` [PATCH 04/22] perf tools: Support event grouping in hpp ->sort() Jiri Olsa
2014-05-21 13:12 ` [PATCH 05/22] perf tools: Use hpp formats to sort final output Jiri Olsa
2014-05-21 13:12 ` [PATCH 06/22] perf tools: Consolidate output field handling to hpp format routines Jiri Olsa
2014-05-21 13:12 ` [PATCH 07/22] perf ui: Get rid of callback from __hpp__fmt() Jiri Olsa
2014-05-21 13:12 ` [PATCH 08/22] perf tools: Allow hpp fields to be sort keys Jiri Olsa
2014-05-21 13:12 ` [PATCH 09/22] perf tools: Consolidate management of default sort orders Jiri Olsa
2014-05-21 13:12 ` [PATCH 10/22] perf tools: Call perf_hpp__init() before setting up GUI browsers Jiri Olsa
2014-05-21 13:12 ` [PATCH 11/22] perf report: Add -F option to specify output fields Jiri Olsa
2014-05-21 13:12 ` [PATCH 12/22] perf tools: Add ->sort() member to struct sort_entry Jiri Olsa
2014-05-21 13:12 ` [PATCH 13/22] perf report/tui: Fix a bug when --fields/sort is given Jiri Olsa
2014-05-21 13:12 ` [PATCH 14/22] perf top: Add --fields option to specify output fields Jiri Olsa
2014-05-21 13:12 ` [PATCH 15/22] perf tools: Skip elided sort entries Jiri Olsa
2014-05-21 13:12 ` [PATCH 16/22] perf hists: Reset width of output fields with header length Jiri Olsa
2014-05-21 13:12 ` [PATCH 17/22] perf tools: Get rid of obsolete hist_entry__sort_list Jiri Olsa
2014-05-21 13:12 ` [PATCH 18/22] perf tools: Introduce reset_output_field() Jiri Olsa
2014-05-21 13:12 ` [PATCH 19/22] perf tests: Factor out print_hists_*() Jiri Olsa
2014-05-21 13:12 ` [PATCH 20/22] perf tests: Add a testcase for histogram output sorting Jiri Olsa
2014-05-21 13:12 ` [PATCH 21/22] perf tools: Add cat as fallback pager Jiri Olsa
2014-05-21 13:12 ` [PATCH 22/22] perf tools: Add automatic remapping of Android libraries Jiri Olsa
2014-05-22  9:38 ` [GIT PULL 00/22] perf/core improvements and fixes Ingo Molnar
2015-08-26 15:57 Arnaldo Carvalho de Melo
2015-08-28  6:24 ` Ingo Molnar
2016-02-19 22:41 Arnaldo Carvalho de Melo
2016-02-20 10:56 ` Ingo Molnar
2016-09-20 20:03 Arnaldo Carvalho de Melo
2016-09-20 21:34 ` Ingo Molnar
2016-10-04  2:36 Arnaldo Carvalho de Melo
2016-10-04  8:07 ` Ingo Molnar
2016-12-13 15:09 Arnaldo Carvalho de Melo
2017-04-24 19:54 Arnaldo Carvalho de Melo
2017-04-24 20:40 ` Ingo Molnar
2018-11-30 18:26 Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).