linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 4/6] perf annotate-data: Support event group display in TUI
Date: Wed, 10 Apr 2024 16:52:39 -0300	[thread overview]
Message-ID: <ZhbuB43qQXzfUT14@x1> (raw)
In-Reply-To: <20240409235000.1893969-5-namhyung@kernel.org>

On Tue, Apr 09, 2024 at 04:49:58PM -0700, Namhyung Kim wrote:
> Like in stdio, it should print all events in a group together.

Please provide the desired output, i.e. the "like in stdio", together
with the 'perf record' that creates a perf.data file that will then be
used with 'perf annotate' to produce the old output and then the new,
I'm trying to do that now to review the patch.

- Arnaldo
 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/ui/browsers/annotate-data.c | 50 ++++++++++++++++++++------
>  1 file changed, 40 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/annotate-data.c b/tools/perf/ui/browsers/annotate-data.c
> index fefacaaf16db..a4a0f042f201 100644
> --- a/tools/perf/ui/browsers/annotate-data.c
> +++ b/tools/perf/ui/browsers/annotate-data.c
> @@ -10,20 +10,27 @@
>  #include "util/annotate.h"
>  #include "util/annotate-data.h"
>  #include "util/evsel.h"
> +#include "util/evlist.h"
>  #include "util/sort.h"
>  
>  struct annotated_data_browser {
>  	struct ui_browser b;
>  	struct list_head entries;
> +	int nr_events;
>  };
>  
>  struct browser_entry {
>  	struct list_head node;
>  	struct annotated_member *data;
> -	struct type_hist_entry hists;
> +	struct type_hist_entry *hists;
>  	int indent;
>  };
>  
> +static struct annotated_data_browser *get_browser(struct ui_browser *uib)
> +{
> +	return container_of(uib, struct annotated_data_browser, b);
> +}
> +
>  static void update_hist_entry(struct type_hist_entry *dst,
>  			      struct type_hist_entry *src)
>  {
> @@ -33,17 +40,21 @@ static void update_hist_entry(struct type_hist_entry *dst,
>  
>  static int get_member_overhead(struct annotated_data_type *adt,
>  			       struct browser_entry *entry,
> -			       struct evsel *evsel)
> +			       struct evsel *leader)
>  {
>  	struct annotated_member *member = entry->data;
> -	int i;
> +	int i, k;
>  
>  	for (i = 0; i < member->size; i++) {
>  		struct type_hist *h;
> +		struct evsel *evsel;
>  		int offset = member->offset + i;
>  
> -		h = adt->histograms[evsel->core.idx];
> -		update_hist_entry(&entry->hists, &h->addr[offset]);
> +		for_each_group_evsel(evsel, leader) {
> +			h = adt->histograms[evsel->core.idx];
> +			k = evsel__group_idx(evsel);
> +			update_hist_entry(&entry->hists[k], &h->addr[offset]);
> +		}
>  	}
>  	return 0;
>  }
> @@ -61,6 +72,12 @@ static int add_child_entries(struct annotated_data_browser *browser,
>  	if (entry == NULL)
>  		return -1;
>  
> +	entry->hists = calloc(browser->nr_events, sizeof(*entry->hists));
> +	if (entry->hists == NULL) {
> +		free(entry);
> +		return -1;
> +	}
> +
>  	entry->data = member;
>  	entry->indent = indent;
>  	if (get_member_overhead(adt, entry, evsel) < 0) {
> @@ -113,6 +130,7 @@ static void annotated_data_browser__delete_entries(struct annotated_data_browser
>  
>  	list_for_each_entry_safe(pos, tmp, &browser->entries, node) {
>  		list_del_init(&pos->node);
> +		free(pos->hists);
>  		free(pos);
>  	}
>  }
> @@ -126,6 +144,7 @@ static int browser__show(struct ui_browser *uib)
>  {
>  	struct hist_entry *he = uib->priv;
>  	struct annotated_data_type *adt = he->mem_type;
> +	struct annotated_data_browser *browser = get_browser(uib);
>  	const char *help = "Press 'h' for help on key bindings";
>  	char title[256];
>  
> @@ -146,7 +165,8 @@ static int browser__show(struct ui_browser *uib)
>  	else
>  		strcpy(title, "Percent");
>  
> -	ui_browser__printf(uib, " %10s %10s %10s  %s",
> +	ui_browser__printf(uib, "%*s %10s %10s %10s  %s",
> +			   11 * (browser->nr_events - 1), "",
>  			   title, "Offset", "Size", "Field");
>  	ui_browser__write_nstring(uib, "", uib->width);
>  	return 0;
> @@ -175,18 +195,20 @@ static void browser__write_overhead(struct ui_browser *uib,
>  
>  static void browser__write(struct ui_browser *uib, void *entry, int row)
>  {
> +	struct annotated_data_browser *browser = get_browser(uib);
>  	struct browser_entry *be = entry;
>  	struct annotated_member *member = be->data;
>  	struct hist_entry *he = uib->priv;
>  	struct annotated_data_type *adt = he->mem_type;
> -	struct evsel *evsel = hists_to_evsel(he->hists);
> +	struct evsel *leader = hists_to_evsel(he->hists);
> +	struct evsel *evsel;
>  
>  	if (member == NULL) {
>  		bool current = ui_browser__is_current_entry(uib, row);
>  
>  		/* print the closing bracket */
>  		ui_browser__set_percent_color(uib, 0, current);
> -		ui_browser__write_nstring(uib, "", 11);
> +		ui_browser__write_nstring(uib, "", 11 * browser->nr_events);
>  		ui_browser__printf(uib, " %10s %10s  %*s};",
>  				   "", "", be->indent * 4, "");
>  		ui_browser__write_nstring(uib, "", uib->width);
> @@ -194,8 +216,12 @@ static void browser__write(struct ui_browser *uib, void *entry, int row)
>  	}
>  
>  	/* print the number */
> -	browser__write_overhead(uib, adt->histograms[evsel->core.idx],
> -				&be->hists, row);
> +	for_each_group_evsel(evsel, leader) {
> +		struct type_hist *h = adt->histograms[evsel->core.idx];
> +		int idx = evsel__group_idx(evsel);
> +
> +		browser__write_overhead(uib, h, &be->hists[idx], row);
> +	}
>  
>  	/* print type info */
>  	if (be->indent == 0 && !member->var_name) {
> @@ -267,11 +293,15 @@ int hist_entry__annotate_data_tui(struct hist_entry *he, struct evsel *evsel,
>  			.priv	 = he,
>  			.extra_title_lines = 1,
>  		},
> +		.nr_events = 1,
>  	};
>  	int ret;
>  
>  	ui_helpline__push("Press ESC to exit");
>  
> +	if (evsel__is_group_event(evsel))
> +		browser.nr_events = evsel->core.nr_members;
> +
>  	ret = annotated_data_browser__collect_entries(&browser);
>  	if (ret == 0)
>  		ret = annotated_data_browser__run(&browser, evsel, hbt);
> -- 
> 2.44.0.478.gd926399ef9-goog

  reply	other threads:[~2024-04-10 19:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 23:49 [PATCHSET 0/6] perf annotate: Add TUI support for data type profiling (v1) Namhyung Kim
2024-04-09 23:49 ` [PATCH 1/6] perf annotate: Show progress of sample processing Namhyung Kim
2024-04-09 23:49 ` [PATCH 2/6] perf annotate-data: Add hist_entry__annotate_data_tty() Namhyung Kim
2024-04-09 23:49 ` [PATCH 3/6] perf annotate-data: Add hist_entry__annotate_data_tui() Namhyung Kim
2024-04-10 20:21   ` Arnaldo Carvalho de Melo
2024-04-10 21:04     ` Arnaldo Carvalho de Melo
2024-04-10 21:05       ` Arnaldo Carvalho de Melo
2024-04-10 21:12         ` Arnaldo Carvalho de Melo
2024-04-10 21:17           ` Arnaldo Carvalho de Melo
2024-04-10 21:20             ` Arnaldo Carvalho de Melo
2024-04-10 21:32               ` Arnaldo Carvalho de Melo
2024-04-10 23:49                 ` Namhyung Kim
2024-04-09 23:49 ` [PATCH 4/6] perf annotate-data: Support event group display in TUI Namhyung Kim
2024-04-10 19:52   ` Arnaldo Carvalho de Melo [this message]
2024-04-10 20:24   ` Arnaldo Carvalho de Melo
2024-04-10 20:38     ` Arnaldo Carvalho de Melo
2024-04-09 23:49 ` [PATCH 5/6] perf report: Add a menu item to annotate data type " Namhyung Kim
2024-04-10 20:46   ` Arnaldo Carvalho de Melo
2024-04-10 20:50     ` Arnaldo Carvalho de Melo
2024-04-11  0:30       ` Namhyung Kim
2024-04-09 23:50 ` [PATCH 6/6] perf report: Do not collect sample histogram unnecessarily Namhyung Kim
2024-04-10 16:29 ` [PATCHSET 0/6] perf annotate: Add TUI support for data type profiling (v1) Ian Rogers

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=ZhbuB43qQXzfUT14@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).