linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL v2 0/2] Allow disabling TUI per command in ~/.perfconfig
@ 2010-05-21  1:08 Arnaldo Carvalho de Melo
  2010-05-21  1:08 ` [PATCH 1/2] perf record: remove unneeded gettimeofday() call Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-21  1:08 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo,
	Frédéric Weisbecker, Mike Galbraith, Paul Mackerras,
	Peter Zijlstra, Russ Anderson, Stephane Eranian, Tom Zanussi

Hi Ingo,

	I noticed some problems in the previous TUI disabling patch, fixed
in this v2 series, that also includes a removal of some gettimeofday calls of
little utility submitted by Russ.

        Please pull from:

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

Regards,

- Arnaldo


Arnaldo Carvalho de Melo (1):
  perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig

Russ Anderson (1):
  perf record: remove unneeded gettimeofday() call

 tools/perf/builtin-record.c |   17 +----------------
 tools/perf/builtin-report.c |    8 ++++----
 tools/perf/perf.c           |   25 +++++++++++++++++++++++--
 tools/perf/util/cache.h     |    2 +-
 tools/perf/util/newt.c      |    9 ++++++---
 5 files changed, 35 insertions(+), 26 deletions(-)


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

* [PATCH 1/2] perf record: remove unneeded gettimeofday() call
  2010-05-21  1:08 [GIT PULL v2 0/2] Allow disabling TUI per command in ~/.perfconfig Arnaldo Carvalho de Melo
@ 2010-05-21  1:08 ` Arnaldo Carvalho de Melo
  2010-05-21  1:08 ` [PATCH v2 2/2] perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig Arnaldo Carvalho de Melo
  2010-05-21  7:52 ` [GIT PULL v2 0/2] Allow disabling TUI per command " Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-21  1:08 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Russ Anderson, Ingo Molnar, Peter Zijlstra,
	Stephane Eranian, Arnaldo Carvalho de Melo

From: Russ Anderson <rja@sgi.com>

Perf record repeatedly calls gettimeofday() which adds noise to the performance
measurements.  Since gettimeofday() is only used for the error printf, delete
it.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <20100518225240.GC25589@sgi.com>
Signed-off-by: Russ Anderson <rja@sgi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 66b8ecd..e672269 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -65,9 +65,6 @@ static bool			multiplex			=  false;
 static int			multiplex_fd			=     -1;
 
 static long			samples				=      0;
-static struct timeval		last_read;
-static struct timeval		this_read;
-
 static u64			bytes_written			=      0;
 
 static struct pollfd		*event_array;
@@ -147,8 +144,6 @@ static void mmap_read(struct mmap_data *md)
 	void *buf;
 	int diff;
 
-	gettimeofday(&this_read, NULL);
-
 	/*
 	 * If we're further behind than half the buffer, there's a chance
 	 * the writer will bite our tail and mess up the samples under us.
@@ -159,23 +154,13 @@ static void mmap_read(struct mmap_data *md)
 	 */
 	diff = head - old;
 	if (diff < 0) {
-		struct timeval iv;
-		unsigned long msecs;
-
-		timersub(&this_read, &last_read, &iv);
-		msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
-
-		fprintf(stderr, "WARNING: failed to keep up with mmap data."
-				"  Last read %lu msecs ago.\n", msecs);
-
+		fprintf(stderr, "WARNING: failed to keep up with mmap data\n");
 		/*
 		 * head points to a known good entry, start there.
 		 */
 		old = head;
 	}
 
-	last_read = this_read;
-
 	if (old != head)
 		samples++;
 
-- 
1.6.2.5


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

* [PATCH v2 2/2] perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig
  2010-05-21  1:08 [GIT PULL v2 0/2] Allow disabling TUI per command in ~/.perfconfig Arnaldo Carvalho de Melo
  2010-05-21  1:08 ` [PATCH 1/2] perf record: remove unneeded gettimeofday() call Arnaldo Carvalho de Melo
@ 2010-05-21  1:08 ` Arnaldo Carvalho de Melo
  2010-05-21  7:52 ` [GIT PULL v2 0/2] Allow disabling TUI per command " Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-21  1:08 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo,
	Frédéric Weisbecker, Mike Galbraith, Paul Mackerras,
	Peter Zijlstra, Stephane Eranian, Tom Zanussi

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

Using the same scheme as for git's/perf's pager setup, i.e. if one
doesn't want to, on a newt enabled perf binary, to disable the TUI for
'perf report', its just a matter of doing:

  [root@doppio linux-2.6-tip]# printf "[tui]\n\nreport = off\n" >
  /root/.perfconfig
  [root@doppio linux-2.6-tip]# cat /root/.perfconfig
  [tui]

  report = off
  [root@doppio linux-2.6-tip]#

System wide settings are also possible, by editing /etc/perfconfig, etc,
i.e. the git machinery for config files applies to perf as well, so when
in doubt where to put your settings, consult the git documentation, if
it fails, please let us know.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Discussed-with: Stephane Eranian <eranian@google.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-report.c |    8 ++++----
 tools/perf/perf.c           |   25 +++++++++++++++++++++++--
 tools/perf/util/cache.h     |    2 +-
 tools/perf/util/newt.c      |    9 ++++++---
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1d3c100..a7b8760 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
 	 * so we don't allocated the extra space needed because the stdio
 	 * code will not use it.
 	 */
-	if (use_browser)
+	if (use_browser > 0)
 		err = hist_entry__inc_addr_samples(he, al->addr);
 out_free_syms:
 	free(syms);
@@ -330,7 +330,7 @@ static int __cmd_report(void)
 		hists = rb_entry(next, struct hists, rb_node);
 		hists__collapse_resort(hists);
 		hists__output_resort(hists);
-		if (use_browser)
+		if (use_browser > 0)
 			hists__browse(hists, help, input_name);
 		else {
 			const char *evname = NULL;
@@ -347,7 +347,7 @@ static int __cmd_report(void)
 		next = rb_next(&hists->rb_node);
 	}
 
-	if (!use_browser && sort_order == default_sort_order &&
+	if (use_browser <= 0 && sort_order == default_sort_order &&
 	    parent_pattern == default_parent_pattern) {
 		fprintf(stdout, "#\n# (%s)\n#\n", help);
 
@@ -491,7 +491,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
 	 * so don't allocate extra space that won't be used in the stdio
 	 * implementation.
 	 */
-	if (use_browser)
+	if (use_browser > 0)
 		symbol_conf.priv_size = sizeof(struct sym_priv);
 
 	if (symbol__init() < 0)
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 08e0e5d..6e48711 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -15,15 +15,15 @@
 #include "util/parse-events.h"
 #include "util/debugfs.h"
 
-bool use_browser;
-
 const char perf_usage_string[] =
 	"perf [--version] [--help] COMMAND [ARGS]";
 
 const char perf_more_info_string[] =
 	"See 'perf help COMMAND' for more information on a specific command.";
 
+int use_browser = -1;
 static int use_pager = -1;
+
 struct pager_config {
 	const char *cmd;
 	int val;
@@ -49,6 +49,24 @@ int check_pager_config(const char *cmd)
 	return c.val;
 }
 
+static int tui_command_config(const char *var, const char *value, void *data)
+{
+	struct pager_config *c = data;
+	if (!prefixcmp(var, "tui.") && !strcmp(var + 4, c->cmd))
+		c->val = perf_config_bool(var, value);
+	return 0;
+}
+
+/* returns 0 for "no tui", 1 for "use tui", and -1 for "not specified" */
+static int check_tui_config(const char *cmd)
+{
+	struct pager_config c;
+	c.cmd = cmd;
+	c.val = -1;
+	perf_config(tui_command_config, &c);
+	return c.val;
+}
+
 static void commit_pager_choice(void)
 {
 	switch (use_pager) {
@@ -255,6 +273,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 	if (p->option & RUN_SETUP)
 		prefix = NULL; /* setup_perf_directory(); */
 
+	if (use_browser == -1)
+		use_browser = check_tui_config(p->cmd);
+
 	if (use_pager == -1 && p->option & RUN_SETUP)
 		use_pager = check_pager_config(p->cmd);
 	if (use_pager == -1 && p->option & USE_PAGER)
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 5eca525..65fe664 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -30,7 +30,7 @@ extern const char *pager_program;
 extern int pager_in_use(void);
 extern int pager_use_color;
 
-extern bool use_browser;
+extern int use_browser;
 
 #ifdef NO_NEWT_SUPPORT
 static inline void setup_browser(void)
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 9338d06..9d203c9 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -1066,10 +1066,13 @@ static struct newtPercentTreeColors {
 void setup_browser(void)
 {
 	struct newtPercentTreeColors *c = &defaultPercentTreeColors;
-	if (!isatty(1))
+
+	if (!isatty(1) || !use_browser) {
+		setup_pager();
 		return;
+	}
 
-	use_browser = true;
+	use_browser = 1;
 	newtInit();
 	newtCls();
 	ui_helpline__puts(" ");
@@ -1082,7 +1085,7 @@ void setup_browser(void)
 
 void exit_browser(bool wait_for_ok)
 {
-	if (use_browser) {
+	if (use_browser > 0) {
 		if (wait_for_ok) {
 			char title[] = "Fatal Error", ok[] = "Ok";
 			newtWinMessage(title, ok, browser__last_msg);
-- 
1.6.2.5


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

* Re: [GIT PULL v2 0/2] Allow disabling TUI per command in ~/.perfconfig
  2010-05-21  1:08 [GIT PULL v2 0/2] Allow disabling TUI per command in ~/.perfconfig Arnaldo Carvalho de Melo
  2010-05-21  1:08 ` [PATCH 1/2] perf record: remove unneeded gettimeofday() call Arnaldo Carvalho de Melo
  2010-05-21  1:08 ` [PATCH v2 2/2] perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig Arnaldo Carvalho de Melo
@ 2010-05-21  7:52 ` Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2010-05-21  7:52 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Frédéric Weisbecker, Mike Galbraith,
	Paul Mackerras, Peter Zijlstra, Russ Anderson, Stephane Eranian,
	Tom Zanussi


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

> Hi Ingo,
> 
> 	I noticed some problems in the previous TUI 
> disabling patch, fixed in this v2 series, that also 
> includes a removal of some gettimeofday calls of little 
> utility submitted by Russ.
> 
>         Please pull from:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf
> 
> Regards,
> 
> - Arnaldo
> 
> 
> Arnaldo Carvalho de Melo (1):
>   perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig
> 
> Russ Anderson (1):
>   perf record: remove unneeded gettimeofday() call
> 
>  tools/perf/builtin-record.c |   17 +----------------
>  tools/perf/builtin-report.c |    8 ++++----
>  tools/perf/perf.c           |   25 +++++++++++++++++++++++--
>  tools/perf/util/cache.h     |    2 +-
>  tools/perf/util/newt.c      |    9 ++++++---
>  5 files changed, 35 insertions(+), 26 deletions(-)

Pulled, thanks Arnaldo!

	Ingo

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

end of thread, other threads:[~2010-05-21  7:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-21  1:08 [GIT PULL v2 0/2] Allow disabling TUI per command in ~/.perfconfig Arnaldo Carvalho de Melo
2010-05-21  1:08 ` [PATCH 1/2] perf record: remove unneeded gettimeofday() call Arnaldo Carvalho de Melo
2010-05-21  1:08 ` [PATCH v2 2/2] perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig Arnaldo Carvalho de Melo
2010-05-21  7:52 ` [GIT PULL v2 0/2] Allow disabling TUI per command " Ingo Molnar

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).