From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@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 6/7] perf hists browser: Split popup menu actions
Date: Tue, 21 Apr 2015 00:22:06 +0900 [thread overview]
Message-ID: <20150420152206.GF8483@danjae.kornet> (raw)
In-Reply-To: <20150420140020.GE11111@kernel.org>
Hi Arnaldo,
On Mon, Apr 20, 2015 at 11:00:20AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Apr 19, 2015 at 01:04:14PM +0900, Namhyung Kim escreveu:
> > Currently perf_evsel__hists_browse() function spins on a huge loop and
> > handles many key actions. Since it's hard to read and modify, let's
> > split it out into small helper functions.
> >
> > The add_XXX_opt() functions are to register popup menu item on the
> > selected entry. When it adds an item, it also saves related data into
> > struct popup_option and returns 1 so that it can increase the number of
> > items (nr_opts). A callback function named do_XXX is called with saved
> > data when the item is selected by user.
> >
> > No functional change intended.
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/ui/browsers/hists.c | 565 ++++++++++++++++++++++++++---------------
> > 1 file changed, 363 insertions(+), 202 deletions(-)
> >
> > diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> > index cace2df7e561..315ebc493508 100644
> > --- a/tools/perf/ui/browsers/hists.c
> > +++ b/tools/perf/ui/browsers/hists.c
> > @@ -1216,11 +1216,6 @@ static void hist_browser__delete(struct hist_browser *browser)
> > free(browser);
> > }
> >
> > -static struct hist_entry *hist_browser__selected_entry(struct hist_browser *browser)
> > -{
> > - return browser->he_selection;
> > -}
> > -
>
> Why remove the above function? To reduce the patch size you could have
> left it and if the reason for removing it is that compelling, remove it
> in a later patch.
OK, will do.
>
> > static struct thread *hist_browser__selected_thread(struct hist_browser *browser)
> > {
> > return browser->he_selection->thread;
> > @@ -1395,6 +1390,281 @@ close_file_and_continue:
> > return ret;
> > }
> >
> > +struct popup_option {
> > + struct thread *thread;
> > + struct map *map;
> > + struct dso *dso;
> > + struct symbol *sym;
>
> You could use struct map_symbol, that has the three above, right? In
> some cases you would have less lines by doing:
>
>
> ms = po->ms;
OK.
>
> > + int (*fn)(struct popup_option *opt, struct hist_browser *browser,
> > + struct hist_browser_timer *hbt, struct pstack *pstack,
>
> I wonder if, as a prep patch, you couldn't have browser->hbt, so that we
> would reduce the function signature above. Ditto for pstack.
I don't get it. The hbt and pstack is needed to annotate and zoom.
Are you saying about step-by-step conversion for each action like
first patch for annotate, seconf for zoom, and so on..?
>
>
> Also, you're adding the mechanism (popup_option) at the same time that
> you make those new functions use it.
>
> I think that it would be better if you first created the functions, call
> them directly, then introduce popup_option (probably better named as
> "popup_action").
>
> Each patch would be smaller and more easily reviewable, as well bisect
> would work better when locating bugs.
OK, I'll split the patch into steps..
>
> > + struct perf_session_env *env);
> > +};
> > +
> > +static int
> > +do_annotate(struct popup_option *opt, struct hist_browser *browser,
> > + struct hist_browser_timer *hbt, struct pstack *pstack __maybe_unused,
> > + struct perf_session_env *env)
> > +{
> > + struct perf_evsel *evsel;
> > + struct annotation *notes;
> > + struct map_symbol ms;
> > + int err;
> > +
> > + if (!objdump_path && perf_session_env__lookup_objdump(env))
> > + return 0;
> > +
> > + ms.map = opt->map;
> > + ms.sym = opt->sym;
> > +
> > + notes = symbol__annotation(ms.sym);
> > + if (!notes->src)
> > + return 0;
> > +
> > + evsel = hists_to_evsel(browser->hists);
> > + err = map_symbol__tui_annotate(&ms, evsel, hbt);
> > + /*
> > + * offer option to annotate the other branch source or target
> > + * (if they exists) when returning from annotate
> > + */
> > + if ((err == 'q' || err == CTRL('c'))
> > + && browser->he_selection->branch_info)
>
> Please put the && operator at the end of the first line, even if
> originally it was like that (was it?).
Yes, it was. I'll change it anyway..
Thanks,
Namhyung
next prev parent reply other threads:[~2015-04-20 15:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-19 4:04 [PATCHSET 0/7] perf tools: Assorted cleanup for TUI (v1) Namhyung Kim
2015-04-19 4:04 ` [PATCH 1/7] perf tools: Get rid of position field from struct hist_entry Namhyung Kim
2015-05-06 2:55 ` [tip:perf/core] perf hists: " tip-bot for Namhyung Kim
2015-04-19 4:04 ` [PATCH 2/7] perf diff: Make hist_entry_diff fields union Namhyung Kim
2015-05-06 2:55 ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-04-19 4:04 ` [PATCH 3/7] perf tools: Move TUI-specific fields to struct hist_entry_tui Namhyung Kim
2015-04-20 8:20 ` Jiri Olsa
2015-04-20 12:10 ` Namhyung Kim
2015-04-19 4:04 ` [PATCH 4/7] perf tools: Move init_have_children field " Namhyung Kim
2015-04-19 4:04 ` [PATCH 5/7] perf hists browser: Fix possible memory leak Namhyung Kim
2015-04-20 8:24 ` Jiri Olsa
2015-04-20 12:13 ` Namhyung Kim
2015-04-19 4:04 ` [PATCH 6/7] perf hists browser: Split popup menu actions Namhyung Kim
2015-04-20 9:21 ` Jiri Olsa
2015-04-20 12:21 ` Namhyung Kim
2015-04-20 9:46 ` Jiri Olsa
2015-04-20 12:25 ` Namhyung Kim
2015-04-20 14:00 ` Arnaldo Carvalho de Melo
2015-04-20 15:22 ` Namhyung Kim [this message]
2015-04-20 21:28 ` Arnaldo Carvalho de Melo
2015-04-21 6:10 ` Namhyung Kim
2015-04-19 4:04 ` [PATCH 7/7] perf hists browser: Simplify zooming code a bit Namhyung Kim
2015-04-20 14:02 ` [PATCHSET 0/7] perf tools: Assorted cleanup for TUI (v1) Arnaldo Carvalho de Melo
-- strict thread matches above, loose matches on Subject: below --
2015-04-20 13:00 [PATCHSET 0/7] perf tools: Assorted cleanup for TUI (v2) Namhyung Kim
2015-04-20 13:00 ` [PATCH 6/7] perf hists browser: Split popup menu actions 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=20150420152206.GF8483@danjae.kornet \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox