Skip to content

Commit

Permalink
perf top: Fix number of samples displayed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephane Eranian authored and Arnaldo Carvalho de Melo committed Jan 31, 2012
1 parent d8d9c28 commit 509605d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,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;
}
Expand All @@ -100,6 +98,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);
}

Expand Down Expand Up @@ -453,8 +458,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) {
Expand Down

0 comments on commit 509605d

Please sign in to comment.