aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-05-13 22:08:59 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-05-28 09:23:59 -0400
commit933cbb1c6c617a6ae167538c2fa503efc9c4a832 (patch)
treefb558d90be1397cc4792bfeab8477a3305a1c2f9 /tools/perf/builtin-top.c
parent804f7ac78803ed095bb0402d540f859ecb1be9f1 (diff)
perf top: Fix -E option behavior
The -E/--entries option controls how many lines to be printed on stdio output but it doesn't work as it should be: If -E option is specified, print that many lines regardless of current window size, if not automatically adjust number of lines printed to fit into the window size. Reported-by: Minchan Kim <minchan@kernel.org> Tested-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1368497347-9628-2-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index df9e06af89bf..81adcafbac8f 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -70,10 +70,11 @@
70 70
71static volatile int done; 71static volatile int done;
72 72
73#define HEADER_LINE_NR 5
74
73static void perf_top__update_print_entries(struct perf_top *top) 75static void perf_top__update_print_entries(struct perf_top *top)
74{ 76{
75 if (top->print_entries > 9) 77 top->print_entries = top->winsize.ws_row - HEADER_LINE_NR;
76 top->print_entries -= 9;
77} 78}
78 79
79static void perf_top__sig_winch(int sig __maybe_unused, 80static void perf_top__sig_winch(int sig __maybe_unused,
@@ -82,13 +83,6 @@ static void perf_top__sig_winch(int sig __maybe_unused,
82 struct perf_top *top = arg; 83 struct perf_top *top = arg;
83 84
84 get_term_dimensions(&top->winsize); 85 get_term_dimensions(&top->winsize);
85 if (!top->print_entries
86 || (top->print_entries+4) > top->winsize.ws_row) {
87 top->print_entries = top->winsize.ws_row;
88 } else {
89 top->print_entries += 4;
90 top->winsize.ws_row = top->print_entries;
91 }
92 perf_top__update_print_entries(top); 86 perf_top__update_print_entries(top);
93} 87}
94 88
@@ -296,10 +290,10 @@ static void perf_top__print_sym_table(struct perf_top *top)
296 top->hide_user_symbols, 290 top->hide_user_symbols,
297 top->hide_kernel_symbols); 291 top->hide_kernel_symbols);
298 hists__output_recalc_col_len(&top->sym_evsel->hists, 292 hists__output_recalc_col_len(&top->sym_evsel->hists,
299 top->winsize.ws_row - 3); 293 top->print_entries - printed);
300 putchar('\n'); 294 putchar('\n');
301 hists__fprintf(&top->sym_evsel->hists, false, 295 hists__fprintf(&top->sym_evsel->hists, false,
302 top->winsize.ws_row - 4 - printed, win_width, stdout); 296 top->print_entries - printed, win_width, stdout);
303} 297}
304 298
305static void prompt_integer(int *target, const char *msg) 299static void prompt_integer(int *target, const char *msg)
@@ -477,7 +471,6 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
477 perf_top__sig_winch(SIGWINCH, NULL, top); 471 perf_top__sig_winch(SIGWINCH, NULL, top);
478 sigaction(SIGWINCH, &act, NULL); 472 sigaction(SIGWINCH, &act, NULL);
479 } else { 473 } else {
480 perf_top__sig_winch(SIGWINCH, NULL, top);
481 signal(SIGWINCH, SIG_DFL); 474 signal(SIGWINCH, SIG_DFL);
482 } 475 }
483 break; 476 break;