From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266AbeAURlo (ORCPT ); Sun, 21 Jan 2018 12:41:44 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:44613 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750923AbeAURln (ORCPT ); Sun, 21 Jan 2018 12:41:43 -0500 X-Google-Smtp-Source: AH8x227DpusACt3JYliyljENkThDC7z3XKSyMhevbkjFGFVffrOIymymr4VjNO23VoqIA8oMc+88fQ== Date: Mon, 22 Jan 2018 01:25:03 +0800 From: Wang YanQing To: Jiri Olsa Cc: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf report: Provide libtraceevent with a kernel symbol resolver Message-ID: <20180121172503.GA22289@udknight> Mail-Followup-To: Wang YanQing , Jiri Olsa , acme@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org References: <20180115044732.GB20373@udknight> <20180115100611.GB14646@krava> <20180116164812.GA4118@udknight> <20180118094318.GB5947@krava> <20180118142230.GA5078@udknight> <20180119185759.GA24243@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180119185759.GA24243@krava> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 19, 2018 at 07:57:59PM +0100, Jiri Olsa wrote: > On Thu, Jan 18, 2018 at 10:22:30PM +0800, Wang YanQing wrote: > > On Thu, Jan 18, 2018 at 10:43:18AM +0100, Jiri Olsa wrote: > > > On Wed, Jan 17, 2018 at 12:48:12AM +0800, Wang YanQing wrote: > > > > On Mon, Jan 15, 2018 at 11:06:11AM +0100, Jiri Olsa wrote: > > > > > On Mon, Jan 15, 2018 at 12:47:32PM +0800, Wang YanQing wrote: > > > > > > So that beautifiers wanting to resolve kernel function addresses to > > > > > > names can do its work, and when we use "perf report" for output of > > > > > > "perf kmem record", we will get kernel symbol output. > > > > > > > > > > > > Signed-off-by: Wang YanQing > > > > > > --- > > > > > > tools/perf/builtin-report.c | 9 +++++++++ > > > > > > 1 file changed, 9 insertions(+) > > > > > > > > > > > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > > > > > > index dd4df9a..7b65100 100644 > > > > > > --- a/tools/perf/builtin-report.c > > > > > > +++ b/tools/perf/builtin-report.c > > > > > > @@ -1317,6 +1317,15 @@ int cmd_report(int argc, const char **argv) > > > > > > report.range_num = 1; > > > > > > } > > > > > > > > > > > > + if (session->tevent.pevent && > > > > > > + pevent_set_function_resolver(session->tevent.pevent, > > > > > > + machine__resolve_kernel_addr, > > > > > > + &session->machines.host) < 0) { > > > > > > + pr_err("%s: failed to set libtraceevent function resolver\n", > > > > > > + __func__); > > > > > > + return -1; > > > > > > + } > > > > > > > > > > why not calling the wrapper trace_event__register_resolver? > > > > The reason is the same as builtin-script doesn't use trace_event__register_resolver, > > > > because we only use report and script to analyze offline perf.data, and there could > > > > be no tracepoints in perf.data. > > > > > > hum, I missed this functionality.. so we need this even if there > > > are no tracepoints in the perf.data? > > > > In "perf report", when there are tracepoints in perf.data, session->tevent.pevent > > will be initialized in trace-event-read.c:trace_report, then "if (session->tevent.pevent" > > will become true, and we should calling pevent_set_function_resolver. > > > > But if we calling trace_event__register_resolver, then it will initialize tevent.pevent > > no matter whether there are tracepoints in perf.data. > > ok, should we call it from perf_session__read_header then? > below perf_evlist__prepare_tracepoint_events perhaps No, I think we can't do it in perf_session__read_header, because perf_session__new calls perf_session__create_kernel_maps to initialize machines.host after calling perf_session__open, and pevent_set_function_resolver needs it. Although it is possible to place pevent_set_function_resolver at the tail of perf_session__new, but I don't think it is a better choice for us, because tools like "perf kmem stat" doesn't need it, "perf kmem stat" has itself way to prepare and display the symbols of callsites. I think the current calling place of pevent_set_function_resolver for "perf report" is the right place. Thanks. > jirka