All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH] perf top: Move toggling event logic into hists browser
Date: Mon, 22 Jun 2015 11:19:16 -0300	[thread overview]
Message-ID: <20150622141916.GE28405@kernel.org> (raw)
In-Reply-To: <1434858076-6533-1-git-send-email-namhyung@kernel.org>

Em Sun, Jun 21, 2015 at 12:41:16PM +0900, Namhyung Kim escreveu:
> 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
 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-top.c       | 24 +++---------------------
>  tools/perf/ui/browsers/hists.c | 19 +++++++++++++++++--
>  2 files changed, 20 insertions(+), 23 deletions(-)
> 
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 619a8696fda7..ecf319728f25 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -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;
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index c42adb600091..7629bef2fd79 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -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";
> -- 
> 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/

  reply	other threads:[~2015-06-22 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-21  3:41 [PATCH] perf top: Move toggling event logic into hists browser Namhyung Kim
2015-06-22 14:19 ` Arnaldo Carvalho de Melo [this message]
2015-06-25  7:55 ` [tip:perf/core] " tip-bot for Namhyung Kim

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=20150622141916.GE28405@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.