linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: rostedt@goodmis.org, linux-kernel@vger.kernel.org,
	andi@firstfloor.org, namhyung@kernel.org, wangnan0@huawei.com,
	acme@redhat.com, dsahern@gmail.com, fweisbec@gmail.com,
	jolsa@kernel.org, mingo@kernel.org, hpa@zytor.com,
	tglx@linutronix.de, peterz@infradead.org
Subject: [tip:perf/core] perf tools: Skip dynamic fields not defined for current event
Date: Sat, 9 Jan 2016 08:25:50 -0800	[thread overview]
Message-ID: <tip-361459f163fa1ec7ff4700ec876c3b7ff5f36cc6@git.kernel.org> (raw)
In-Reply-To: <1450804030-29193-12-git-send-email-namhyung@kernel.org>

Commit-ID:  361459f163fa1ec7ff4700ec876c3b7ff5f36cc6
Gitweb:     http://git.kernel.org/tip/361459f163fa1ec7ff4700ec876c3b7ff5f36cc6
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 23 Dec 2015 02:07:08 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:12 -0300

perf tools: Skip dynamic fields not defined for current event

When there are multiple events, each dynamic sort key is defined just
for one event.  In this case other events will always show "N/A" for
those fields.  But they are meaningless and consume precious screen
width.

Let's skip those undefined dynamic fields.

  $ perf record -e kmem:kmalloc,kmem:kfree -a sleep 1

  $ perf report -s 'comm,kmalloc.*' --stdio
  # To display the perf.data header info, please use --header/--header-only options.
  #
  #
  # Total Lost Samples: 0
  #
  # Samples: 20K of event 'kmem:kmalloc'
  # Event count (approx.): 20533
  #
  # Overhead  Command           call_site                 ptr  bytes_req  bytes_alloc            gfp_flags
  # ........  .......  ..................  ..................  .........  ...........  ...................
  #
      99.89%  perf       ffffffffa01d4396  0xffff8803ffb79720         96           96    GFP_NOFS|GFP_ZERO
       0.06%  sleep      ffffffff8114e1cd  0xffff8803d228a000       4096         4096           GFP_KERNEL
       0.03%  perf       ffffffff811d6ae6  0xffff8803f7678f00        240          256  GFP_KERNEL|GFP_ZERO
       0.00%  perf       ffffffff812263c1  0xffff880406172380        128          128           GFP_KERNEL
       0.00%  perf       ffffffff812264b9  0xffff8803ffac1600        504          512           GFP_KERNEL
       0.00%  perf       ffffffff81226634  0xffff880401dc5280         28           32           GFP_KERNEL
       0.00%  sleep      ffffffff81226da9  0xffff8803ffac3a00        392          512           GFP_KERNEL

  # Samples: 20K of event 'kmem:kfree'
  # Event count (approx.): 20597
  #
  # Overhead  Command
  # ........  ..............
  #
      99.63%  perf
       0.14%  sleep
       0.11%  irq/36-iwlwifi
       0.11%  kworker/u16:0
       0.01%  Xorg
       0.00%  firefox

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1450804030-29193-12-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c |  7 ++++---
 tools/perf/ui/gtk/hists.c      |  4 ++--
 tools/perf/ui/hist.c           |  2 +-
 tools/perf/ui/stdio/hist.c     |  6 +++---
 tools/perf/util/hist.c         |  2 +-
 tools/perf/util/hist.h         | 14 ++++++++++++--
 tools/perf/util/sort.c         | 20 ++++++++++++++------
 7 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ec33196..901d481 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1041,7 +1041,8 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 		hist_browser__gotorc(browser, row, 0);
 
 		perf_hpp__for_each_format(fmt) {
-			if (perf_hpp__should_skip(fmt) || column++ < browser->b.horiz_scroll)
+			if (perf_hpp__should_skip(fmt, entry->hists) ||
+			    column++ < browser->b.horiz_scroll)
 				continue;
 
 			if (current_entry && browser->b.navkeypressed) {
@@ -1144,7 +1145,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *
 	}
 
 	perf_hpp__for_each_format(fmt) {
-		if (perf_hpp__should_skip(fmt)  || column++ < browser->b.horiz_scroll)
+		if (perf_hpp__should_skip(fmt, hists)  || column++ < browser->b.horiz_scroll)
 			continue;
 
 		ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
@@ -1414,7 +1415,7 @@ 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))
+		if (perf_hpp__should_skip(fmt, he->hists))
 			continue;
 
 		if (!first) {
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 4677172..0f8dcfd 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -318,7 +318,7 @@ 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))
+		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
 		/*
@@ -368,7 +368,7 @@ 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))
+			if (perf_hpp__should_skip(fmt, h->hists))
 				continue;
 
 			if (fmt->color)
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 5029ba2..8263c0e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -619,7 +619,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
 	struct perf_hpp dummy_hpp;
 
 	perf_hpp__for_each_format(fmt) {
-		if (perf_hpp__should_skip(fmt))
+		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
 		if (first)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 7ebc661..387110d 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -385,7 +385,7 @@ 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))
+		if (perf_hpp__should_skip(fmt, he->hists))
 			continue;
 
 		/*
@@ -464,7 +464,7 @@ 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))
+		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
 		if (!first)
@@ -490,7 +490,7 @@ 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))
+		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
 		if (!first)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index fdb97e1..afc9b8f 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1112,7 +1112,7 @@ 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))
+		if (perf_hpp__should_skip(fmt, a->hists))
 			continue;
 
 		cmp = fmt->sort(fmt, a, b);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 15b22c5..cb8f373 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -262,10 +262,20 @@ 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__is_dynamic_entry(struct perf_hpp_fmt *format);
+bool perf_hpp__defined_dynamic_entry(struct perf_hpp_fmt *fmt, struct hists *hists);
 
-static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format)
+static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format,
+					 struct hists *hists)
 {
-	return format->elide;
+	if (format->elide)
+		return true;
+
+	if (perf_hpp__is_dynamic_entry(format) &&
+	    !perf_hpp__defined_dynamic_entry(format, hists))
+		return true;
+
+	return false;
 }
 
 void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index f6aef15..fd56223 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1698,6 +1698,15 @@ static int __sort__hde_width(struct perf_hpp_fmt *fmt,
 	return len;
 }
 
+bool perf_hpp__defined_dynamic_entry(struct perf_hpp_fmt *fmt, struct hists *hists)
+{
+	struct hpp_dynamic_entry *hde;
+
+	hde = container_of(fmt, struct hpp_dynamic_entry, hpp);
+
+	return hists_to_evsel(hists) == hde->evsel;
+}
+
 static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 			     struct hist_entry *he)
 {
@@ -1714,9 +1723,6 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 	if (!len)
 		len = hde_width(hde);
 
-	if (hists_to_evsel(he->hists) != hde->evsel)
-		return scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, "N/A");
-
 	if (hde->raw_trace)
 		goto raw_field;
 
@@ -1769,9 +1775,6 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
 
 	hde = container_of(fmt, struct hpp_dynamic_entry, hpp);
 
-	if (hists_to_evsel(a->hists) != hde->evsel)
-		return 0;
-
 	field = hde->field;
 	if (field->flags & FIELD_IS_DYNAMIC) {
 		unsigned long long dyn;
@@ -1794,6 +1797,11 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
 	return memcmp(a->raw_data + offset, b->raw_data + offset, size);
 }
 
+bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *fmt)
+{
+	return fmt->cmp == __sort__hde_cmp;
+}
+
 static struct hpp_dynamic_entry *
 __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)
 {

  reply	other threads:[~2016-01-09 16:26 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 17:06 [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v4) Namhyung Kim
2015-12-22 17:06 ` [PATCH 01/13] perf hist: Pass struct sample to __hists__add_entry() Namhyung Kim
2016-01-09 16:22   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:06 ` [PATCH 02/13] perf hist: Save raw_data/size for tracepoint events Namhyung Kim
2015-12-23 21:43   ` Arnaldo Carvalho de Melo
2015-12-24  0:45     ` Namhyung Kim
2015-12-24  1:19       ` Arnaldo Carvalho de Melo
2015-12-24  1:05     ` [PATCH v4.1 " Namhyung Kim
2015-12-24  1:39       ` Arnaldo Carvalho de Melo
2015-12-24  2:16         ` [PATCH v4.2 " Namhyung Kim
2016-01-09 16:22           ` [tip:perf/core] perf hist: Save raw_data/ size " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 03/13] tools lib traceevent: Factor out and export print_event_field[s] Namhyung Kim
2015-12-23  8:50   ` Wangnan (F)
2015-12-23 13:08   ` [PATCH v4.1 " Namhyung Kim
2016-01-04 15:31     ` Steven Rostedt
2016-01-04 18:34       ` Arnaldo Carvalho de Melo
2016-01-09 16:22     ` [tip:perf/core] tools lib traceevent: Factor out and export print_event_field[s]() tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 04/13] perf tools: Pass evlist to setup_sorting() Namhyung Kim
2016-01-09 16:23   ` [tip:perf/core] perf top: Create the evlist sooner tip-bot for Namhyung Kim
2016-01-09 16:23   ` [tip:perf/core] perf tools: Pass evlist to setup_sorting() tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 05/13] perf tools: Add dynamic sort key for tracepoint events Namhyung Kim
2016-01-04 15:04   ` Arnaldo Carvalho de Melo
2016-01-09 16:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 06/13] perf tools: Try to show pretty printed output for dynamic sort keys Namhyung Kim
2016-01-04 15:16   ` Arnaldo Carvalho de Melo
2016-01-09 16:24   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 07/13] perf tools: Add 'trace' sort key Namhyung Kim
2016-01-09 16:24   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 08/13] perf tools: Add --raw-trace option Namhyung Kim
2016-01-09 16:24   ` [tip:perf/core] perf report/top: " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 09/13] perf tools: Support shortcuts for events in dynamic sort keys Namhyung Kim
2016-01-09 16:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 10/13] perf tools: Support '<event>.*' dynamic sort key Namhyung Kim
2016-01-09 16:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 11/13] perf tools: Skip dynamic fields not defined for current event Namhyung Kim
2016-01-09 16:25   ` tip-bot for Namhyung Kim [this message]
2015-12-22 17:07 ` [PATCH 12/13] perf tools: Add 'trace_fields' dynamic sort key Namhyung Kim
2016-01-05 10:58   ` [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name Namhyung Kim
2016-01-05 14:20       ` Jiri Olsa
2016-01-09 16:28       ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 3/5] perf tools: Add document for dynamic sort keys Namhyung Kim
2016-01-09 16:28       ` [tip:perf/core] perf report: Add documentation " tip-bot for Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields Namhyung Kim
2016-01-05 22:16       ` Arnaldo Carvalho de Melo
2016-01-05 23:57         ` Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields Namhyung Kim
2016-01-05 22:23       ` Arnaldo Carvalho de Melo
2016-01-06  0:00         ` Namhyung Kim
2016-01-06  1:52           ` Arnaldo Carvalho de Melo
2016-01-05 21:50     ` [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields Arnaldo Carvalho de Melo
2016-01-05 23:39       ` Namhyung Kim
2016-01-09 16:26     ` [tip:perf/core] perf tools: Add 'trace_fields' dynamic sort key tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 13/13] perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events Namhyung Kim
2016-01-09 16:26   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-23  8:46 ` [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v4) Jiri Olsa
2015-12-23 13:10   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-361459f163fa1ec7ff4700ec876c3b7ff5f36cc6@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).