linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 05/46] perf annotate: Pass perf_evsel instead of just evsel->idx
Date: Tue,  5 Jun 2018 14:49:49 -0300	[thread overview]
Message-ID: <20180605175030.32549-6-acme@kernel.org> (raw)
In-Reply-To: <20180605175030.32549-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The code gets shorter and we'll be able to use evsel->evlist in a
followup patch.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-t0s7vy19wq5kak74kavm8swf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-annotate.c |  6 +++---
 tools/perf/builtin-report.c   | 17 ++++++++---------
 tools/perf/builtin-top.c      |  6 +++---
 tools/perf/util/annotate.c    | 12 ++++++------
 tools/perf/util/annotate.h    |  4 ++--
 5 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index da5704240239..2b21bbcd70ea 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -162,12 +162,12 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
 	hist__account_cycles(sample->branch_stack, al, sample, false);
 
 	bi = he->branch_info;
-	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel);
 
 	if (err)
 		goto out;
 
-	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel);
 
 out:
 	return err;
@@ -249,7 +249,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
 	if (he == NULL)
 		return -ENOMEM;
 
-	ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
+	ret = hist_entry__inc_addr_samples(he, sample, evsel, al->addr);
 	hists__inc_nr_samples(hists, true);
 	return ret;
 }
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index ad978e3ee2b8..7a689c933f04 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -136,26 +136,25 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
 
 	if (sort__mode == SORT_MODE__BRANCH) {
 		bi = he->branch_info;
-		err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+		err = addr_map_symbol__inc_samples(&bi->from, sample, evsel);
 		if (err)
 			goto out;
 
-		err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+		err = addr_map_symbol__inc_samples(&bi->to, sample, evsel);
 
 	} else if (rep->mem_mode) {
 		mi = he->mem_info;
-		err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel->idx);
+		err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel);
 		if (err)
 			goto out;
 
-		err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
+		err = hist_entry__inc_addr_samples(he, sample, evsel, al->addr);
 
 	} else if (symbol_conf.cumulate_callchain) {
 		if (single)
-			err = hist_entry__inc_addr_samples(he, sample, evsel->idx,
-							   al->addr);
+			err = hist_entry__inc_addr_samples(he, sample, evsel, al->addr);
 	} else {
-		err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
+		err = hist_entry__inc_addr_samples(he, sample, evsel, al->addr);
 	}
 
 out:
@@ -181,11 +180,11 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
 			     rep->nonany_branch_mode);
 
 	bi = he->branch_info;
-	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel);
 	if (err)
 		goto out;
 
-	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel);
 
 	branch_type_count(&rep->brtype_stat, &bi->flags,
 			  bi->from.addr, bi->to.addr);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 7a349fcd3864..bc71e899096d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -188,7 +188,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)
 static void perf_top__record_precise_ip(struct perf_top *top,
 					struct hist_entry *he,
 					struct perf_sample *sample,
-					int counter, u64 ip)
+					struct perf_evsel *evsel, u64 ip)
 {
 	struct annotation *notes;
 	struct symbol *sym = he->ms.sym;
@@ -204,7 +204,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
 	if (pthread_mutex_trylock(&notes->lock))
 		return;
 
-	err = hist_entry__inc_addr_samples(he, sample, counter, ip);
+	err = hist_entry__inc_addr_samples(he, sample, evsel, ip);
 
 	pthread_mutex_unlock(&notes->lock);
 
@@ -691,7 +691,7 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,
 	struct perf_evsel *evsel = iter->evsel;
 
 	if (perf_hpp_list.sym && single)
-		perf_top__record_precise_ip(top, he, iter->sample, evsel->idx, al->addr);
+		perf_top__record_precise_ip(top, he, iter->sample, evsel, al->addr);
 
 	hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
 		     !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 71897689dacf..0f5ed6091e00 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -836,7 +836,7 @@ static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles
 }
 
 static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
-				    int evidx, u64 addr,
+				    struct perf_evsel *evsel, u64 addr,
 				    struct perf_sample *sample)
 {
 	struct annotation *notes;
@@ -846,7 +846,7 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
 	notes = symbol__get_annotation(sym, false);
 	if (notes == NULL)
 		return -ENOMEM;
-	return __symbol__inc_addr_samples(sym, map, notes, evidx, addr, sample);
+	return __symbol__inc_addr_samples(sym, map, notes, evsel->idx, addr, sample);
 }
 
 static int symbol__account_cycles(u64 addr, u64 start,
@@ -974,15 +974,15 @@ void annotation__compute_ipc(struct annotation *notes, size_t size)
 }
 
 int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
-				 int evidx)
+				 struct perf_evsel *evsel)
 {
-	return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr, sample);
+	return symbol__inc_addr_samples(ams->sym, ams->map, evsel, ams->al_addr, sample);
 }
 
 int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
-				 int evidx, u64 ip)
+				 struct perf_evsel *evsel, u64 ip)
 {
-	return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip, sample);
+	return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evsel, ip, sample);
 }
 
 static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map_symbol *ms)
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 5080b6dd98b8..aef9eae4f125 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -279,14 +279,14 @@ static inline struct annotation *symbol__annotation(struct symbol *sym)
 }
 
 int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
-				 int evidx);
+				 struct perf_evsel *evsel);
 
 int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
 				    struct addr_map_symbol *start,
 				    unsigned cycles);
 
 int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
-				 int evidx, u64 addr);
+				 struct perf_evsel *evsel, u64 addr);
 
 int symbol__alloc_hist(struct symbol *sym);
 void symbol__annotate_zero_histograms(struct symbol *sym);
-- 
2.14.3

  parent reply	other threads:[~2018-06-05 17:49 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 17:49 [GIT PULL 00/46] perf/core fixes and improvements Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 01/46] perf tools: Remove dead quote.[ch] code Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 02/46] perf probe: Use return of map__get() to make code more compact Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 03/46] perf cgroup: Make evlist__find_cgroup() " Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 04/46] perf tools: No need to check if the argument to __get() function is NULL Arnaldo Carvalho de Melo
2018-06-05 17:49 ` Arnaldo Carvalho de Melo [this message]
2018-06-05 17:49 ` [PATCH 06/46] perf annotate: __symbol__acount_cycles doesn't need notes Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 07/46] perf annotate: Split allocation of annotated_source struct Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 08/46] perf annotate: Introduce constructor/destructor for annotated_source Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 09/46] perf annotate: Introduce annotated_source__alloc_histograms Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 10/46] perf annotate: __symbol__inc_addr_samples() needs just annotated_source Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 11/46] perf annotate: Introduce symbol__hists() Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 12/46] perf annotate: Introduce symbol__cycle_hists() Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 13/46] perf annotate: Stop using symbol_conf.nr_events global in symbol__hists() Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 14/46] perf annotate: Replace symbol__alloc_hists() with symbol__hists() Arnaldo Carvalho de Melo
2018-06-05 17:49 ` [PATCH 15/46] perf tools: Ditch the symbol_conf.nr_events global Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 16/46] perf annotate: Add comment about annotated_src->nr_histograms Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 17/46] perf annotate stdio: Use annotation_options consistently Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 18/46] perf srcline: Introduce map__srcline() to make code more compact Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 19/46] perf sort: Introduce addr_map_symbol__srcline() " Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 20/46] perf srcline: Make hist_entry srcline helper consistent with map's Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 21/46] perf annotate: Pass annotation_options to symbol__annotate() Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 22/46] perf annotate: Adopt anotation options from symbol_conf Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 23/46] perf annotate: Move disassembler_style global to annotation_options Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 24/46] perf hists browser: Pass annotation_options from tool to browser Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 25/46] perf annotate: Move objdump_path to struct annotation_options Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 26/46] perf test: Use header file util/debug.h Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 27/46] perf report: No need to have report_callchain_help as a global Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 28/46] perf evsel: Add has_callchain() helper to make code more compact/clear Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 29/46] perf script: Check if evsel has callchains before trying to use it Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 30/46] perf sched: Use sched->show_callchain where appropriate Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 31/46] perf hists: Do not allocate space for callchains for evsels without them Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 32/46] perf hists: Introduce hist_entry__has_callchain() method Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 33/46] perf hists: Check if a hist_entry has callchains before using them Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 34/46] perf tests kmod-path: Add tests for vdso32 and vdsox32 Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 35/46] perf tools: Fix symbol and object code resolution " Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 36/46] perf record: Enable arbitrary event names thru name= modifier Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 37/46] perf stat: Display user and system time Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 38/46] perf tools: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 39/46] perf test code-reading: Fix perf_env setup for PTI entry trampolines Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 40/46] perf map: Consider PTI entry trampolines in rip_2objdump() Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 41/46] perf test record+probe_libc_inet_pton: Ask 'nm' for dynamic symbols Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 42/46] perf script powerpc: Python script for hypervisor call statistics Arnaldo Carvalho de Melo
2018-06-06 14:53   ` Paul Clarke
2018-06-07  5:34     ` Ravi Bangoria
2018-06-07 13:41       ` Paul Clarke
2018-06-07 13:45         ` Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 43/46] perf intel-pt: Fix sync_switch INTEL_PT_SS_NOT_TRACING Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 44/46] perf intel-pt: Fix decoding to accept CBR between FUP and corresponding TIP Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 45/46] perf intel-pt: Fix MTC timing after overflow Arnaldo Carvalho de Melo
2018-06-05 17:50 ` [PATCH 46/46] perf intel-pt: Fix "Unexpected indirect branch" error Arnaldo Carvalho de Melo
2018-06-07  5:22 ` [GIT PULL 00/46] perf/core fixes and improvements Ingo Molnar

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=20180605175030.32549-6-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.com \
    --cc=williams@redhat.com \
    /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).