perf top: Move toggling event logic into hists browser
Namhyung Kim
maintainerPATCH 1/1 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.
--- tools/perf/builtin-top.c | 24 +++--------------------- tools/perf/ui/browsers/hists.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 23 deletions(-)
tools/perf/builtin-top.c +3 -21
@@ -586,27 +586,9 @@ static void *display_thread_tui(void *arg) hists->uid_filter_str = top->record_opts.target.uid_str; } -while (true) { -int key =perf_evlist__tui_browse_hists (top->evlist, help, &hbt, - top->min_percent, - &top->session->header.env); - -if (key !='f' ) -break ; - -perf_evlist__toggle_enable (top->evlist); -/* -* No need to refresh, resort/decay histogram entries -* if we are not collecting samples: -*/ -if (top->evlist->enabled) { - hbt.refresh = top->delay_secs; - help ="Press 'f' to disable the events or 'h' to see other hotkeys" ; - }else { - help ="Press 'f' again to re-enable the events" ; - hbt.refresh =0 ; - } - } +perf_evlist__tui_browse_hists (top->evlist, help, &hbt, + top->min_percent, + &top->session->header.env); done =1 ;return NULL ;
tools/perf/ui/browsers/hists.c +17 -2
@@ -1902,8 +1902,23 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,case CTRL ('c' ): goto out_free_stack;case 'f' : -if (!is_report_browser (hbt)) - goto out_free_stack; +if (!is_report_browser (hbt)) { +struct perf_top *top = hbt->arg; + +perf_evlist__toggle_enable (top->evlist); +/* +* No need to refresh, resort/decay histogram +* entries if we are not collecting samples: +*/ +if (top->evlist->enabled) { + helpline ="Press 'f' to disable the events or 'h' to see other hotkeys" ; + hbt->refresh = delay_secs; + }else { + helpline ="Press 'f' again to re-enable the events" ; + hbt->refresh =0 ; + } +continue ; + }/* Fall thru */ default : helpline ="Press '?' for help on key bindings" ;
Signature · 5 lines
2.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/
Arnaldo Carvalho de Melo
maintainerEm Sun, Jun 21, 2015 at 12:41:16PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
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.
Yeah, at first I did it to try to remove references to whatever tool is using the hists browser, i.e. it should not know it is being called from something called 'top' or 'report' or something altogether different :-\
But yeah, your patch fixes the issue when we have multiple events, I am applying, but what sounds better is to make those is_foo_tool_browser() layering violations be something more abstract like hb->dynamic_mode, avoid accesses to evlist in perf_evsel__ prefixed functions and have the menu routine handle the 'f' hotkey.
Thanks!
- Arnaldo
Quoted 73 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-top.c | 24 +++--------------------- tools/perf/ui/browsers/hists.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 23 deletions(-)tools/perf/builtin-top.c +3
-21@@ -586,27 +586,9 @@ static void *display_thread_tui(void *arg) hists->uid_filter_str = top->record_opts.target.uid_str; } -while (true) { -int key =perf_evlist__tui_browse_hists (top->evlist, help, &hbt, - top->min_percent, - &top->session->header.env); - -if (key !='f' ) -break ; - -perf_evlist__toggle_enable (top->evlist); -/* -* No need to refresh, resort/decay histogram entries -* if we are not collecting samples: -*/ -if (top->evlist->enabled) { - hbt.refresh = top->delay_secs; - help ="Press 'f' to disable the events or 'h' to see other hotkeys" ; - }else { - help ="Press 'f' again to re-enable the events" ; - hbt.refresh =0 ; - } - } +perf_evlist__tui_browse_hists (top->evlist, help, &hbt, + top->min_percent, + &top->session->header.env); done =1 ;return NULL ;tools/perf/ui/browsers/hists.c +17
-2@@ -1902,8 +1902,23 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,case CTRL ('c' ): goto out_free_stack;case 'f' : -if (!is_report_browser (hbt)) - goto out_free_stack; +if (!is_report_browser (hbt)) { +struct perf_top *top = hbt->arg; + +perf_evlist__toggle_enable (top->evlist); +/* +* No need to refresh, resort/decay histogram +* entries if we are not collecting samples: +*/ +if (top->evlist->enabled) { + helpline ="Press 'f' to disable the events or 'h' to see other hotkeys" ; + hbt->refresh = delay_secs; + }else { + helpline ="Press 'f' again to re-enable the events" ; + hbt->refresh =0 ; + } +continue ; + }/* Fall thru */ default : helpline ="Press '?' for help on key bindings" ;Signature · 1 line
2.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/
tip-bot for Namhyung Kim
merge botperf top: Move toggling event logic into hists browser
Commit-ID: 13d1e536b14ec2d404319a25e681a3287ca084ad Gitweb: http://git.kernel.org/tip/13d1e536b14ec2d404319a25e681a3287ca084ad Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 21 Jun 2015 12:41:16 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 22 Jun 2015 11:21:11 -0300
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.
--- tools/perf/builtin-top.c | 24 +++--------------------- tools/perf/ui/browsers/hists.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 23 deletions(-)
tools/perf/builtin-top.c +3 -21
@@ -586,27 +586,9 @@ static void *display_thread_tui(void *arg) hists->uid_filter_str = top->record_opts.target.uid_str; } -while (true) { -int key =perf_evlist__tui_browse_hists (top->evlist, help, &hbt, - top->min_percent, - &top->session->header.env); - -if (key !='f' ) -break ; - -perf_evlist__toggle_enable (top->evlist); -/* -* No need to refresh, resort/decay histogram entries -* if we are not collecting samples: -*/ -if (top->evlist->enabled) { - hbt.refresh = top->delay_secs; - help ="Press 'f' to disable the events or 'h' to see other hotkeys" ; - }else { - help ="Press 'f' again to re-enable the events" ; - hbt.refresh =0 ; - } - } +perf_evlist__tui_browse_hists (top->evlist, help, &hbt, + top->min_percent, + &top->session->header.env); done =1 ;return NULL ;
tools/perf/ui/browsers/hists.c +17 -2
@@ -1902,8 +1902,23 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,case CTRL ('c' ): goto out_free_stack;case 'f' : -if (!is_report_browser (hbt)) - goto out_free_stack; +if (!is_report_browser (hbt)) { +struct perf_top *top = hbt->arg; + +perf_evlist__toggle_enable (top->evlist); +/* +* No need to refresh, resort/decay histogram +* entries if we are not collecting samples: +*/ +if (top->evlist->enabled) { + helpline ="Press 'f' to disable the events or 'h' to see other hotkeys" ; + hbt->refresh = delay_secs; + }else { + helpline ="Press 'f' again to re-enable the events" ; + hbt->refresh =0 ; + } +continue ; + }/* Fall thru */ default : helpline ="Press '?' for help on key bindings" ;