Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf top: Move toggling event logic into hists browser

Current 'f' key action to enable/disable events won't work if there're
more than one event since perf_evsel_menu__run() doesn't return the key.
So move it to the hists browser loop so that it can be processed as like
other key action, and it's more natural to handle it there IMHO.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1434858076-6533-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
13d1e536 a9a3cd90

+20 -23
+3 -21
tools/perf/builtin-top.c
··· 586 586 hists->uid_filter_str = top->record_opts.target.uid_str; 587 587 } 588 588 589 - while (true) { 590 - int key = perf_evlist__tui_browse_hists(top->evlist, help, &hbt, 591 - top->min_percent, 592 - &top->session->header.env); 593 - 594 - if (key != 'f') 595 - break; 596 - 597 - perf_evlist__toggle_enable(top->evlist); 598 - /* 599 - * No need to refresh, resort/decay histogram entries 600 - * if we are not collecting samples: 601 - */ 602 - if (top->evlist->enabled) { 603 - hbt.refresh = top->delay_secs; 604 - help = "Press 'f' to disable the events or 'h' to see other hotkeys"; 605 - } else { 606 - help = "Press 'f' again to re-enable the events"; 607 - hbt.refresh = 0; 608 - } 609 - } 589 + perf_evlist__tui_browse_hists(top->evlist, help, &hbt, 590 + top->min_percent, 591 + &top->session->header.env); 610 592 611 593 done = 1; 612 594 return NULL;
+17 -2
tools/perf/ui/browsers/hists.c
··· 1902 1902 case CTRL('c'): 1903 1903 goto out_free_stack; 1904 1904 case 'f': 1905 - if (!is_report_browser(hbt)) 1906 - goto out_free_stack; 1905 + if (!is_report_browser(hbt)) { 1906 + struct perf_top *top = hbt->arg; 1907 + 1908 + perf_evlist__toggle_enable(top->evlist); 1909 + /* 1910 + * No need to refresh, resort/decay histogram 1911 + * entries if we are not collecting samples: 1912 + */ 1913 + if (top->evlist->enabled) { 1914 + helpline = "Press 'f' to disable the events or 'h' to see other hotkeys"; 1915 + hbt->refresh = delay_secs; 1916 + } else { 1917 + helpline = "Press 'f' again to re-enable the events"; 1918 + hbt->refresh = 0; 1919 + } 1920 + continue; 1921 + } 1907 1922 /* Fall thru */ 1908 1923 default: 1909 1924 helpline = "Press '?' for help on key bindings";