All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL 0/2] perf/core improvements
@ 2010-08-21 17:45 Arnaldo Carvalho de Melo
  2010-08-21 17:45 ` [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-21 17:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Christoph Hellwig,
	Frederic Weisbecker, Ingo Molnar, Kirill A . Shutemov,
	Mike Galbraith, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Hi Ingo,

        Please pull from:

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

Regards,

- Arnaldo

Arnaldo Carvalho de Melo (1):
  perf tools: Add --tui and --stdio to choose the UI

Kirill A. Shutemov (1):
  perf tools: add test for strlcpy()

 tools/perf/Documentation/perf-annotate.txt |   11 +++++++++--
 tools/perf/Documentation/perf-report.txt   |    7 +++++++
 tools/perf/Makefile                        |    9 +++++++++
 tools/perf/builtin-annotate.c              |    9 ++++++++-
 tools/perf/builtin-report.c                |   11 ++++++++++-
 tools/perf/feature-tests.mak               |   11 +++++++++++
 tools/perf/util/cache.h                    |    2 ++
 tools/perf/util/path.c                     |    3 ++-
 8 files changed, 58 insertions(+), 5 deletions(-)


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

* [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI
  2010-08-21 17:45 [GIT PULL 0/2] perf/core improvements Arnaldo Carvalho de Melo
@ 2010-08-21 17:45 ` Arnaldo Carvalho de Melo
  2010-08-21 17:47   ` Christoph Hellwig
  2010-08-21 17:45 ` [PATCH 2/2] perf tools: add test for strlcpy() Arnaldo Carvalho de Melo
  2010-08-21 19:15 ` [GIT PULL 0/2] perf/core improvements Ingo Molnar
  2 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-21 17:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Christoph Hellwig,
	Frederic Weisbecker, Mike Galbraith, Peter Zijlstra,
	Stephane Eranian

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

Relying just on ~/.perfconfig or rebuilding the tool disabling support
for the TUI is too cumbersome, so allow specifying which UI to use and
make the command line switch override whatever is in ~/.perfconfig.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-annotate.txt |   11 +++++++++--
 tools/perf/Documentation/perf-report.txt   |    7 +++++++
 tools/perf/builtin-annotate.c              |    9 ++++++++-
 tools/perf/builtin-report.c                |   11 ++++++++++-
 4 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 5164a65..b2c6330 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -8,7 +8,7 @@ perf-annotate - Read perf.data (created by perf record) and display annotated co
 SYNOPSIS
 --------
 [verse]
-'perf annotate' [-i <file> | --input=file] symbol_name
+'perf annotate' [-i <file> | --input=file] [symbol_name]
 
 DESCRIPTION
 -----------
@@ -24,6 +24,13 @@ OPTIONS
 --input=::
         Input file name. (default: perf.data)
 
+--stdio:: Use the stdio interface.
+
+--tui:: Use the TUI interface Use of --tui requires a tty, if one is not
+	present, as when piping to other commands, the stdio interface is
+	used. This interfaces starts by centering on the line with more
+	samples, TAB/UNTAB cycles thru the lines with more samples.
+
 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 abfabe9..12052c9 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -65,6 +65,13 @@ OPTIONS
 		 the tree is considered as a new profiled object. +
 	Default: fractal,0.5.
 
+--stdio:: Use the stdio interface.
+
+--tui:: Use the TUI interface, that is integrated with annotate and allows
+        zooming into DSOs or threads, among other features. Use of --tui
+	requires a tty, if one is not present, as when piping to other
+	commands, the stdio interface is used.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1]
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 20ee21d..6d5604d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -28,7 +28,7 @@
 
 static char		const *input_name = "perf.data";
 
-static bool		force;
+static bool		force, use_tui, use_stdio;
 
 static bool		full_paths;
 
@@ -427,6 +427,8 @@ static const struct option options[] = {
 		    "be more verbose (show symbol address, etc)"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
+	OPT_BOOLEAN(0, "tui", &use_tui, "Use the TUI interface"),
+	OPT_BOOLEAN(0, "stdio", &use_stdio, "Use the stdio interface"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
 		   "file", "vmlinux pathname"),
 	OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
@@ -442,6 +444,11 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
 {
 	argc = parse_options(argc, argv, options, annotate_usage, 0);
 
+	if (use_stdio)
+		use_browser = 0;
+	else if (use_tui)
+		use_browser = 1;
+
 	setup_browser();
 
 	symbol_conf.priv_size = sizeof(struct sym_priv);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 55fc1f4..7d35a71 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -32,7 +32,7 @@
 
 static char		const *input_name = "perf.data";
 
-static bool		force;
+static bool		force, use_tui, use_stdio;
 static bool		hide_unresolved;
 static bool		dont_use_callchains;
 
@@ -450,6 +450,8 @@ static const struct option options[] = {
 		    "Show per-thread event counters"),
 	OPT_STRING(0, "pretty", &pretty_printing_style, "key",
 		   "pretty printing style key: normal raw"),
+	OPT_BOOLEAN(0, "tui", &use_tui, "Use the TUI interface"),
+	OPT_BOOLEAN(0, "stdio", &use_stdio, "Use the stdio interface"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent"),
 	OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
@@ -482,8 +484,15 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
 {
 	argc = parse_options(argc, argv, options, report_usage, 0);
 
+	if (use_stdio)
+		use_browser = 0;
+	else if (use_tui)
+		use_browser = 1;
+
 	if (strcmp(input_name, "-") != 0)
 		setup_browser();
+	else
+		use_browser = 0;
 	/*
 	 * Only in the newt browser we are doing integrated annotation,
 	 * so don't allocate extra space that won't be used in the stdio
-- 
1.6.2.5


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

* [PATCH 2/2] perf tools: add test for strlcpy()
  2010-08-21 17:45 [GIT PULL 0/2] perf/core improvements Arnaldo Carvalho de Melo
  2010-08-21 17:45 ` [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI Arnaldo Carvalho de Melo
@ 2010-08-21 17:45 ` Arnaldo Carvalho de Melo
  2010-08-21 19:15 ` [GIT PULL 0/2] perf/core improvements Ingo Molnar
  2 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-21 17:45 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Kirill A. Shutemov, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo

From: Kirill A. Shutemov <kirill@shutemov.name>

Some Linux distributions like ALT Linux provides patched glibc with
contains strlcpy(). It's confilcts with strlcpy() from perf.

Let's add check for strlcpy().

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1282351101-8879-1-git-send-email-kirill@shutemov.name>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile          |    9 +++++++++
 tools/perf/feature-tests.mak |   11 +++++++++++
 tools/perf/util/cache.h      |    2 ++
 tools/perf/util/path.c       |    3 ++-
 4 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index dcb9700..7473de0 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -647,6 +647,15 @@ else
 	endif
 endif
 
+
+ifdef NO_STRLCPY
+	BASIC_CFLAGS += -DNO_STRLCPY
+else
+	ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
+		BASIC_CFLAGS += -DNO_STRLCPY
+	endif
+endif
+
 ifndef CC_LD_DYNPATH
 	ifdef NO_R_TO_GCC_LINKER
 		# Some gcc does not accept and pass -R to the linker to specify
diff --git a/tools/perf/feature-tests.mak b/tools/perf/feature-tests.mak
index ddb68e6..ef3d0d6 100644
--- a/tools/perf/feature-tests.mak
+++ b/tools/perf/feature-tests.mak
@@ -110,6 +110,17 @@ int main(void)
 }
 endef
 
+define SOURCE_STRLCPY
+#include <stdlib.h>
+extern size_t strlcpy(char *dest, const char *src, size_t size);
+
+int main(void)
+{
+	strlcpy(NULL, NULL, 0);
+	return 0;
+}
+endef
+
 # try-cc
 # Usage: option = $(call try-cc, source-to-build, cc-options)
 try-cc = $(shell sh -c						  \
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 27e9ebe..a772979 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -82,6 +82,8 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
 extern char *perf_pathdup(const char *fmt, ...)
 	__attribute__((format (printf, 1, 2)));
 
+#ifdef NO_STRLCPY
 extern size_t strlcpy(char *dest, const char *src, size_t size);
+#endif
 
 #endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 58a470d..bd74977 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -22,6 +22,7 @@ static const char *get_perf_dir(void)
 	return ".";
 }
 
+#ifdef NO_STRLCPY
 size_t strlcpy(char *dest, const char *src, size_t size)
 {
 	size_t ret = strlen(src);
@@ -33,7 +34,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
 	}
 	return ret;
 }
-
+#endif
 
 static char *get_pathname(void)
 {
-- 
1.6.2.5


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

* Re: [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI
  2010-08-21 17:45 ` [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI Arnaldo Carvalho de Melo
@ 2010-08-21 17:47   ` Christoph Hellwig
  2010-08-21 18:26     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2010-08-21 17:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, linux-kernel, Arnaldo Carvalho de Melo,
	Christoph Hellwig, Frederic Weisbecker, Mike Galbraith,
	Peter Zijlstra, Stephane Eranian

On Sat, Aug 21, 2010 at 02:45:11PM -0300, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> Relying just on ~/.perfconfig or rebuilding the tool disabling support
> for the TUI is too cumbersome, so allow specifying which UI to use and
> make the command line switch override whatever is in ~/.perfconfig.

Much better than the current situation, thanks!

I still thinks commands like perf report should not be overloaded for
two different user interfaces, that is a

	perf report

should always be the line oriented interface, and the newt UI should be
something like

	perf treport

Btw, am I the only one that doesn't find the next interface too helpful?
In general the line oriented interface seem to present the information
much better, and in the cases where it gets too complicated the newt
interface doesn't really helper either.  A real gtk/qt interface with
a proper tree widget would seem like the more useful interface for that.


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

* Re: [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI
  2010-08-21 17:47   ` Christoph Hellwig
@ 2010-08-21 18:26     ` Arnaldo Carvalho de Melo
  2010-08-22  8:20       ` Christoph Hellwig
  0 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-21 18:26 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ingo Molnar, linux-kernel, Frederic Weisbecker, Mike Galbraith,
	Peter Zijlstra, Stephane Eranian

Em Sat, Aug 21, 2010 at 01:47:54PM -0400, Christoph Hellwig escreveu:
> On Sat, Aug 21, 2010 at 02:45:11PM -0300, Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <acme@redhat.com>
> > 
> > Relying just on ~/.perfconfig or rebuilding the tool disabling support
> > for the TUI is too cumbersome, so allow specifying which UI to use and
> > make the command line switch override whatever is in ~/.perfconfig.
> 
> Much better than the current situation, thanks!
> 
> I still thinks commands like perf report should not be overloaded for
> two different user interfaces, that is a
> 
> 	perf report
> 
> should always be the line oriented interface, and the newt UI should be
> something like
> 
> 	perf treport
> 
> Btw, am I the only one that doesn't find the next interface too helpful?
> In general the line oriented interface seem to present the information
> much better, and in the cases where it gets too complicated the newt

Much better how, exactly?

> interface doesn't really helper either.  A real gtk/qt interface with
> a proper tree widget would seem like the more useful interface for that.

What would a gtk/qt interface buy us that is not present on the TUI
right now?

I'm not saying it wouldn't buy something, just interested in what is
this something :)

And yes, gtk/qt interfaces should be added. The experience with the TUI
is helping organize the data structures for that.

- Arnaldo

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

* Re: [GIT PULL 0/2] perf/core improvements
  2010-08-21 17:45 [GIT PULL 0/2] perf/core improvements Arnaldo Carvalho de Melo
  2010-08-21 17:45 ` [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI Arnaldo Carvalho de Melo
  2010-08-21 17:45 ` [PATCH 2/2] perf tools: add test for strlcpy() Arnaldo Carvalho de Melo
@ 2010-08-21 19:15 ` Ingo Molnar
  2 siblings, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2010-08-21 19:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Christoph Hellwig, Frederic Weisbecker,
	Kirill A . Shutemov, Mike Galbraith, Paul Mackerras,
	Peter Zijlstra, Stephane Eranian


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

> Hi Ingo,
> 
>         Please pull from:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core
> 
> Regards,
> 
> - Arnaldo
> 
> Arnaldo Carvalho de Melo (1):
>   perf tools: Add --tui and --stdio to choose the UI
> 
> Kirill A. Shutemov (1):
>   perf tools: add test for strlcpy()
> 
>  tools/perf/Documentation/perf-annotate.txt |   11 +++++++++--
>  tools/perf/Documentation/perf-report.txt   |    7 +++++++
>  tools/perf/Makefile                        |    9 +++++++++
>  tools/perf/builtin-annotate.c              |    9 ++++++++-
>  tools/perf/builtin-report.c                |   11 ++++++++++-
>  tools/perf/feature-tests.mak               |   11 +++++++++++
>  tools/perf/util/cache.h                    |    2 ++
>  tools/perf/util/path.c                     |    3 ++-
>  8 files changed, 58 insertions(+), 5 deletions(-)

Pulled, thanks a lot Arnaldo!

	Ingo

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

* Re: [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI
  2010-08-21 18:26     ` Arnaldo Carvalho de Melo
@ 2010-08-22  8:20       ` Christoph Hellwig
  2010-08-22 14:11         ` Arnaldo Carvalho de Melo
  2010-09-13 17:51         ` [tip:perf/core] perf ui browser: Don't use windows, slang is enough tip-bot for Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 9+ messages in thread
From: Christoph Hellwig @ 2010-08-22  8:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Christoph Hellwig, Ingo Molnar, linux-kernel,
	Frederic Weisbecker, Mike Galbraith, Peter Zijlstra,
	Stephane Eranian

On Sat, Aug 21, 2010 at 03:26:58PM -0300, Arnaldo Carvalho de Melo wrote:
> > Btw, am I the only one that doesn't find the next interface too helpful?
> > In general the line oriented interface seem to present the information
> > much better, and in the cases where it gets too complicated the newt
> 
> Much better how, exactly?

 - it uses the space available in a terminal window much more
   efficiently.  Output starts in row 0, column 0 and expands all the
   way that's needed.
 - it incluses a descruption of what the columns of output mean
 - it provides percentages for the individual callchains parts after
   branching out
 - in graph/fractal modes there are lines that show how the parts
   are connected, making it possible to read the output, unlinke
   the TUI mode where the "expanind" nodes are very hard to follow.
 - just running perf reports gets an overview of all callchains instead
   of having to expand dozens of things
 - the colour scheme is the normal shell one (light gray on black for
   me) instead of one hurting the eyes


> > interface doesn't really helper either.  A real gtk/qt interface with
> > a proper tree widget would seem like the more useful interface for that.
> 
> What would a gtk/qt interface buy us that is not present on the TUI
> right now?

Generally for tree/graph like data structures a real X GUI provides much
nicer rendering.  It'll allow to render the connected lines just as in
the line oriented interface, but in a nicer way using real thin lines
in a tree widget.  It'll also genereally allow better text placement
in the window compared to the single centered window in the newt
interface.   Also the GUI programs follow the common color scheme of the
rest of the desktop instead of hurting your eye.  In addition to that
scrollbars (horizontal / vertical) are a lot more intuitive in a typical
X GUI than in newt.


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

* Re: [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI
  2010-08-22  8:20       ` Christoph Hellwig
@ 2010-08-22 14:11         ` Arnaldo Carvalho de Melo
  2010-09-13 17:51         ` [tip:perf/core] perf ui browser: Don't use windows, slang is enough tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-22 14:11 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ingo Molnar, linux-kernel, Frederic Weisbecker, Mike Galbraith,
	Peter Zijlstra, Stephane Eranian

Em Sun, Aug 22, 2010 at 04:20:03AM -0400, Christoph Hellwig escreveu:
> On Sat, Aug 21, 2010 at 03:26:58PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Btw, am I the only one that doesn't find the next interface too helpful?
> > > In general the line oriented interface seem to present the information
> > > much better, and in the cases where it gets too complicated the newt

> > Much better how, exactly?

>  - it uses the space available in a terminal window much more
>    efficiently.  Output starts in row 0, column 0 and expands all the
>    way that's needed.
>  - it incluses a descruption of what the columns of output mean
>  - it provides percentages for the individual callchains parts after
>    branching out
>  - in graph/fractal modes there are lines that show how the parts
>    are connected, making it possible to read the output, unlinke
>    the TUI mode where the "expanind" nodes are very hard to follow.
>  - just running perf reports gets an overview of all callchains instead
>    of having to expand dozens of things
>  - the colour scheme is the normal shell one (light gray on black for
>    me) instead of one hurting the eyes

All good points, will work on them, thanks for pointing them out!
 
> 
> > > interface doesn't really helper either.  A real gtk/qt interface with
> > > a proper tree widget would seem like the more useful interface for that.
> > 
> > What would a gtk/qt interface buy us that is not present on the TUI
> > right now?
> 
> Generally for tree/graph like data structures a real X GUI provides much
> nicer rendering.  It'll allow to render the connected lines just as in
> the line oriented interface, but in a nicer way using real thin lines

Cool, connected lines is something that indeed has to happen, just like
mutt in threaded mode, will work on that.

> in a tree widget.  It'll also genereally allow better text placement
> in the window compared to the single centered window in the newt
> interface.   Also the GUI programs follow the common color scheme of the
> rest of the desktop instead of hurting your eye.  In addition to that

Lets stop hurting eyes!

> scrollbars (horizontal / vertical) are a lot more intuitive in a typical
> X GUI than in newt.

Ok, thanks for the detailed description of the problems.

- Arnaldo

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

* [tip:perf/core] perf ui browser: Don't use windows, slang is enough
  2010-08-22  8:20       ` Christoph Hellwig
  2010-08-22 14:11         ` Arnaldo Carvalho de Melo
@ 2010-09-13 17:51         ` tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2010-09-13 17:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, eranian, paulus, acme, hpa, mingo, tzanussi,
	peterz, efault, hch, fweisbec, tglx, mingo

Commit-ID:  469917ce8717b9f8c5298bf279fa138859baab8d
Gitweb:     http://git.kernel.org/tip/469917ce8717b9f8c5298bf279fa138859baab8d
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Mon, 13 Sep 2010 10:25:04 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 13 Sep 2010 10:25:04 -0300

perf ui browser: Don't use windows, slang is enough

They are useless and take away precious columns and lines, so stop using
windows.

One more step in removing newt code, that after all is not being useful
at all for the coalescing TUI model in perf.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20100822082003.GB7365@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/ui/browser.c        |   24 +++++++++-----------
 tools/perf/util/ui/browsers/hists.c |   41 ++++++++++++++++------------------
 tools/perf/util/ui/browsers/map.c   |    9 +++----
 3 files changed, 34 insertions(+), 40 deletions(-)

diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index 930c4ac..6d0df80 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -130,13 +130,10 @@ void ui_browser__refresh_dimensions(struct ui_browser *self)
 	int cols, rows;
 	newtGetScreenSize(&cols, &rows);
 
-	if (self->width > cols - 4)
-		self->width = cols - 4;
-	self->height = rows - 5;
-	if (self->height > self->nr_entries)
-		self->height = self->nr_entries;
-	self->y  = (rows - self->height) / 2;
-	self->x = (cols - self->width) / 2;
+	self->width = cols - 1;
+	self->height = rows - 2;
+	self->y = 1;
+	self->x = 0;
 }
 
 void ui_browser__reset_index(struct ui_browser *self)
@@ -168,22 +165,24 @@ int ui_browser__show(struct ui_browser *self, const char *title,
 		       NEWT_KEY_PGDN, NEWT_KEY_HOME, NEWT_KEY_END, ' ',
 		       NEWT_KEY_LEFT, NEWT_KEY_ESCAPE, 'q', CTRL('c'), 0 };
 
-	if (self->form != NULL) {
+	if (self->form != NULL)
 		newtFormDestroy(self->form);
-		newtPopWindow();
-	}
+
 	ui_browser__refresh_dimensions(self);
-	newtCenteredWindow(self->width, self->height, title);
 	self->form = newtForm(NULL, NULL, 0);
 	if (self->form == NULL)
 		return -1;
 
-	self->sb = newtVerticalScrollbar(self->width, 0, self->height,
+	self->sb = newtVerticalScrollbar(self->width, 1, self->height,
 					 HE_COLORSET_NORMAL,
 					 HE_COLORSET_SELECTED);
 	if (self->sb == NULL)
 		return -1;
 
+	SLsmg_gotorc(0, 0);
+	ui_browser__set_color(self, NEWT_COLORSET_ROOT);
+	slsmg_write_nstring(title, self->width);
+
 	ui_browser__add_exit_keys(self, keys);
 	newtFormAddComponent(self->form, self->sb);
 
@@ -196,7 +195,6 @@ int ui_browser__show(struct ui_browser *self, const char *title,
 void ui_browser__hide(struct ui_browser *self)
 {
 	newtFormDestroy(self->form);
-	newtPopWindow();
 	self->form = NULL;
 	ui_helpline__pop();
 }
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 2fc1ba3..ebda8c3 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -293,19 +293,12 @@ static int hist_browser__run(struct hist_browser *self, const char *title)
 	int key;
 	int exit_keys[] = { 'a', '?', 'h', 'C', 'd', 'D', 'E', 't',
 			    NEWT_KEY_ENTER, NEWT_KEY_RIGHT, NEWT_KEY_LEFT, 0, };
-	char str[256], unit;
-	unsigned long nr_events = self->hists->stats.nr_events[PERF_RECORD_SAMPLE];
 
 	self->b.entries = &self->hists->entries;
 	self->b.nr_entries = self->hists->nr_entries;
 
 	hist_browser__refresh_dimensions(self);
 
-	nr_events = convert_unit(nr_events, &unit);
-	snprintf(str, sizeof(str), "Events: %lu%c                            ",
-		 nr_events, unit);
-	newtDrawRootText(0, 0, str);
-
 	if (ui_browser__show(&self->b, title,
 			     "Press '?' for help on key bindings") < 0)
 		return -1;
@@ -782,21 +775,26 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *self)
 	return self->he_selection->thread;
 }
 
-static int hist_browser__title(char *bf, size_t size, const char *ev_name,
-			       const struct dso *dso, const struct thread *thread)
+static int hists__browser_title(struct hists *self, char *bf, size_t size,
+				const char *ev_name, const struct dso *dso,
+				const struct thread *thread)
 {
-	int printed = 0;
+	char unit;
+	int printed;
+	unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
+
+	nr_events = convert_unit(nr_events, &unit);
+	printed = snprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
 
 	if (thread)
 		printed += snprintf(bf + printed, size - printed,
-				    "Thread: %s(%d)",
-				    (thread->comm_set ?  thread->comm : ""),
+				    ", Thread: %s(%d)",
+				    (thread->comm_set ? thread->comm : ""),
 				    thread->pid);
 	if (dso)
 		printed += snprintf(bf + printed, size - printed,
-				    "%sDSO: %s", thread ? " " : "",
-				    dso->short_name);
-	return printed ?: snprintf(bf, size, "Event: %s", ev_name);
+				    ", DSO: %s", dso->short_name);
+	return printed;
 }
 
 int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
@@ -817,9 +815,8 @@ int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
 
 	ui_helpline__push(helpline);
 
-	hist_browser__title(msg, sizeof(msg), ev_name,
-			    dso_filter, thread_filter);
-
+	hists__browser_title(self, msg, sizeof(msg), ev_name,
+			     dso_filter, thread_filter);
 	while (1) {
 		const struct thread *thread;
 		const struct dso *dso;
@@ -957,8 +954,8 @@ zoom_out_dso:
 				pstack__push(fstack, &dso_filter);
 			}
 			hists__filter_by_dso(self, dso_filter);
-			hist_browser__title(msg, sizeof(msg), ev_name,
-					    dso_filter, thread_filter);
+			hists__browser_title(self, msg, sizeof(msg), ev_name,
+					     dso_filter, thread_filter);
 			hist_browser__reset(browser);
 		} else if (choice == zoom_thread) {
 zoom_thread:
@@ -975,8 +972,8 @@ zoom_out_thread:
 				pstack__push(fstack, &thread_filter);
 			}
 			hists__filter_by_thread(self, thread_filter);
-			hist_browser__title(msg, sizeof(msg), ev_name,
-					    dso_filter, thread_filter);
+			hists__browser_title(self, msg, sizeof(msg), ev_name,
+					     dso_filter, thread_filter);
 			hist_browser__reset(browser);
 		}
 	}
diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c
index 1bf0979..e35437d 100644
--- a/tools/perf/util/ui/browsers/map.c
+++ b/tools/perf/util/ui/browsers/map.c
@@ -46,7 +46,6 @@ out_free_form:
 struct map_browser {
 	struct ui_browser b;
 	struct map	  *map;
-	u16		  namelen;
 	u8		  addrlen;
 };
 
@@ -55,13 +54,16 @@ static void map_browser__write(struct ui_browser *self, void *nd, int row)
 	struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
 	struct map_browser *mb = container_of(self, struct map_browser, b);
 	bool current_entry = ui_browser__is_current_entry(self, row);
+	int width;
 
 	ui_browser__set_percent_color(self, 0, current_entry);
 	slsmg_printf("%*llx %*llx %c ",
 		     mb->addrlen, sym->start, mb->addrlen, sym->end,
 		     sym->binding == STB_GLOBAL ? 'g' :
 		     sym->binding == STB_LOCAL  ? 'l' : 'w');
-	slsmg_write_nstring(sym->name, mb->namelen);
+	width = self->width - ((mb->addrlen * 2) + 4);
+	if (width > 0)
+		slsmg_write_nstring(sym->name, width);
 }
 
 /* FIXME uber-kludgy, see comment on cmd_report... */
@@ -139,8 +141,6 @@ int map__browse(struct map *self)
 	for (nd = rb_first(mb.b.entries); nd; nd = rb_next(nd)) {
 		struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
 
-		if (mb.namelen < pos->namelen)
-			mb.namelen = pos->namelen;
 		if (maxaddr < pos->end)
 			maxaddr = pos->end;
 		if (verbose) {
@@ -151,6 +151,5 @@ int map__browse(struct map *self)
 	}
 
 	mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr);
-	mb.b.width += mb.addrlen * 2 + 4 + mb.namelen;
 	return map_browser__run(&mb);
 }

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

end of thread, other threads:[~2010-09-13 17:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-21 17:45 [GIT PULL 0/2] perf/core improvements Arnaldo Carvalho de Melo
2010-08-21 17:45 ` [PATCH 1/2] perf tools: Add --tui and --stdio to choose the UI Arnaldo Carvalho de Melo
2010-08-21 17:47   ` Christoph Hellwig
2010-08-21 18:26     ` Arnaldo Carvalho de Melo
2010-08-22  8:20       ` Christoph Hellwig
2010-08-22 14:11         ` Arnaldo Carvalho de Melo
2010-09-13 17:51         ` [tip:perf/core] perf ui browser: Don't use windows, slang is enough tip-bot for Arnaldo Carvalho de Melo
2010-08-21 17:45 ` [PATCH 2/2] perf tools: add test for strlcpy() Arnaldo Carvalho de Melo
2010-08-21 19:15 ` [GIT PULL 0/2] perf/core improvements Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.