linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
	Stephane Eranian <eranian@google.com>,
	David Ahern <dsahern@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 6/9] perf top: Fix number of samples displayed
Date: Mon, 30 Jan 2012 23:24:36 -0200	[thread overview]
Message-ID: <1327973079-29426-7-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1327973079-29426-1-git-send-email-acme@infradead.org>

From: Stephane Eranian <eranian@google.com>

In recent versions of perf top, pressing the 'e' key to change the
number of displayed samples had no effect.

The number of samples was still dictated by the size of the terminal
(stdio mode). That was quite annoying because typically only the first
dozen samples really matter.

This patch fixes this.

Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120130105037.GA5160@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-top.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index e8b033c..d869b21 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -88,8 +88,6 @@ void get_term_dimensions(struct winsize *ws)
 
 static void perf_top__update_print_entries(struct perf_top *top)
 {
-	top->print_entries = top->winsize.ws_row;
-
 	if (top->print_entries > 9)
 		top->print_entries -= 9;
 }
@@ -99,6 +97,13 @@ static void perf_top__sig_winch(int sig __used, siginfo_t *info __used, void *ar
 	struct perf_top *top = arg;
 
 	get_term_dimensions(&top->winsize);
+	if (!top->print_entries
+	    || (top->print_entries+4) > top->winsize.ws_row) {
+		top->print_entries = top->winsize.ws_row;
+	} else {
+		top->print_entries += 4;
+		top->winsize.ws_row = top->print_entries;
+	}
 	perf_top__update_print_entries(top);
 }
 
@@ -452,8 +457,10 @@ static void perf_top__handle_keypress(struct perf_top *top, int c)
 				};
 				perf_top__sig_winch(SIGWINCH, NULL, top);
 				sigaction(SIGWINCH, &act, NULL);
-			} else
+			} else {
+				perf_top__sig_winch(SIGWINCH, NULL, top);
 				signal(SIGWINCH, SIG_DFL);
+			}
 			break;
 		case 'E':
 			if (top->evlist->nr_entries > 1) {
-- 
1.7.9.rc2.1.g69204


  parent reply	other threads:[~2012-01-31  1:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31  1:24 [GIT PULL 0/9] perf/core fixes and improvements Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 1/9] perf evsel: Fix spelling typo Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 2/9] perf script: Unify the expressions indicating "unknown" Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 3/9] perf script: Print branch_from and branch_to of BTS events Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 4/9] perf script: Add the offset field specifier Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 5/9] perf script: Add option resolving vmlinux path Arnaldo Carvalho de Melo
2012-01-31  1:24 ` Arnaldo Carvalho de Melo [this message]
2012-01-31  1:24 ` [PATCH 7/9] perf lock: Document lock info subcommand Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 8/9] perf tools: Remove unnecessary ctype.h inclusion Arnaldo Carvalho de Melo
2012-01-31  1:24 ` [PATCH 9/9] perf python: Use attr.watermark in twatch.py Arnaldo Carvalho de Melo
2012-01-31 12:06 ` [GIT PULL 0/9] perf/core fixes and improvements Ingo Molnar

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=1327973079-29426-7-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    /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).