All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	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>,
	Hendrick Brueckner <brueckner@linux.vnet.ibm.com>,
	Thomas Richter <tmricht@linux.vnet.ibm.com>,
	Wang Nan <wangnan0@huawei.com>,
	kernel-team@lge.com
Subject: Re: [PATCH 2/5] perf unwind: Do not look at globals
Date: Wed, 17 Jan 2018 14:34:28 +0900	[thread overview]
Message-ID: <20180117053428.GA7530@danjae.aot.lge.com> (raw)
In-Reply-To: <20180116200520.GG16107@kernel.org>

Hi Arnaldo,

On Tue, Jan 16, 2018 at 05:05:20PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 16, 2018 at 08:49:09PM +0100, Jiri Olsa escreveu:
> > On Tue, Jan 16, 2018 at 03:26:50PM -0300, Arnaldo Carvalho de Melo wrote:
> > 
> > SNIP
> > 
> > > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > > index c0debc3f79b6..c0815a37fdb5 100644
> > > --- a/tools/perf/builtin-c2c.c
> > > +++ b/tools/perf/builtin-c2c.c
> > > @@ -2390,9 +2390,10 @@ static int setup_callchain(struct perf_evlist *evlist)
> > >  	enum perf_call_graph_mode mode = CALLCHAIN_NONE;
> > >  
> > >  	if ((sample_type & PERF_SAMPLE_REGS_USER) &&
> > > -	    (sample_type & PERF_SAMPLE_STACK_USER))
> > > +	    (sample_type & PERF_SAMPLE_STACK_USER)) {
> > >  		mode = CALLCHAIN_DWARF;
> > > -	else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
> > > +		dwarf_callchain_users = true;
> > > +	} else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
> > >  		mode = CALLCHAIN_LBR;
> > >  	else if (sample_type & PERF_SAMPLE_CALLCHAIN)
> > >  		mode = CALLCHAIN_FP;
> > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> > > index dd4df9a5cd06..6593779224d5 100644
> > > --- a/tools/perf/builtin-report.c
> > > +++ b/tools/perf/builtin-report.c
> > > @@ -338,9 +338,10 @@ static int report__setup_sample_type(struct report *rep)
> > >  
> > >  	if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {
> > >  		if ((sample_type & PERF_SAMPLE_REGS_USER) &&
> > > -		    (sample_type & PERF_SAMPLE_STACK_USER))
> > > +		    (sample_type & PERF_SAMPLE_STACK_USER)) {
> > >  			callchain_param.record_mode = CALLCHAIN_DWARF;
> > > -		else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
> > > +			dwarf_callchain_users = true;
> > > +		} else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
> > >  			callchain_param.record_mode = CALLCHAIN_LBR;
> > >  		else
> > >  			callchain_param.record_mode = CALLCHAIN_FP;
> > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > > index c1cce474c0f1..08bc818f371b 100644
> > > --- a/tools/perf/builtin-script.c
> > > +++ b/tools/perf/builtin-script.c
> > > @@ -2919,9 +2919,10 @@ static void script__setup_sample_type(struct perf_script *script)
> > >  
> > >  	if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {
> > >  		if ((sample_type & PERF_SAMPLE_REGS_USER) &&
> > > -		    (sample_type & PERF_SAMPLE_STACK_USER))
> > > +		    (sample_type & PERF_SAMPLE_STACK_USER)) {
> > >  			callchain_param.record_mode = CALLCHAIN_DWARF;
> > > -		else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
> > > +			dwarf_callchain_users = true;
> > > +		} else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
> > >  			callchain_param.record_mode = CALLCHAIN_LBR;
> > >  		else
> > >  			callchain_param.record_mode = CALLCHAIN_FP;
> > > diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
> > > index ac40e05bcab4..260418969120 100644
> > > --- a/tools/perf/tests/dwarf-unwind.c
> > > +++ b/tools/perf/tests/dwarf-unwind.c
> > > @@ -173,6 +173,7 @@ int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unu
> > >  	}
> > >  
> > >  	callchain_param.record_mode = CALLCHAIN_DWARF;
> > > +	dwarf_callchain_users = true;
> > >  
> > >  	if (init_live_machine(machine)) {
> > >  		pr_err("Could not init machine\n");
> > > diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> > > index 082505d08d72..32ef7bdca1cf 100644
> > > --- a/tools/perf/util/callchain.c
> > > +++ b/tools/perf/util/callchain.c
> > > @@ -37,6 +37,15 @@ struct callchain_param callchain_param = {
> > >  	CALLCHAIN_PARAM_DEFAULT
> > >  };
> > >  
> > > +/*
> > > + * Are there any events usind DWARF callchains?
> > > + *
> > > + * I.e.
> > > + *
> > > + * -e cycles/call-graph=dwarf/
> > > + */
> > > +bool dwarf_callchain_users;
> > 
> > hum, I don't follow.. this bool seems to mirror the usage of
> > 'param->record_mode = CALLCHAIN_DWARF', whats the difference?
> > 
> > also, the patch title says 'Do not look at globals', while inside you
> 
> The first version didn't look at globals, the second one doesn't look at
> an _specific_ global variable, the global config for --call-graph, which
> is a global variable, callchain_param, which _we_ can't touch at
> apply_config_terms(), since that is about _just_ that event, not all of
> them.

Right, we need to call the prepare routine when any of event requires
DWARF unwind even though the global callchain_param is FP, for example.


> 
> > add new global dwarf_callchain_users and work with it.. what do I miss?
> > 
> > I'll check tomorrow with clean head ;-)
> 
> Look closely at apply_config_terms() it passes a _local_ variable to
> 
>                         perf_evsel__config_callchain(evsel, opts, &param);
> 
> It will not affect any globals that tools/perf/util/unwind-libunwind-local.c
> could possibly use... and that is the problem. :-)
> 
> The right fix, as I said, is more involved and may allow us to remove
> these two global variables, both callchain_param and
> dwarf_callchain_users.
> 
> We need to have per-evsel unwind ops, per thread addr_space continues to
> be used by the dwarf unwinder _for the events sampled in that thread_,
> etc.
> 
> The prepare_unwind is to be made to evsel and thread (for thread we need
> to look at one of its executable maps, to determine if it is 32-bit or
> 64-bit, etc, but not necessarily at that insert_map part, etc).

Yep, but I'm ok with the proposed solution right now.

Thanks,
Namhyung

  reply	other threads:[~2018-01-17  5:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 14:24 [RFC 0/5] per-event settings fixes Arnaldo Carvalho de Melo
2018-01-16 14:24 ` [PATCH 1/5] perf callchain: Fix attr.sample_max_stack setting Arnaldo Carvalho de Melo
2018-01-16 14:24 ` [PATCH 2/5] perf unwind: Do not look at globals Arnaldo Carvalho de Melo
2018-01-16 15:19   ` Jiri Olsa
2018-01-16 15:36     ` Arnaldo Carvalho de Melo
2018-01-16 18:26       ` Arnaldo Carvalho de Melo
2018-01-16 19:49         ` Jiri Olsa
2018-01-16 20:05           ` Arnaldo Carvalho de Melo
2018-01-17  5:34             ` Namhyung Kim [this message]
2018-01-17  8:23             ` Jiri Olsa
2018-01-17 16:33         ` [tip:perf/core] perf unwind: Do not look just at the global callchain_param.record_mode tip-bot for Arnaldo Carvalho de Melo
2018-01-16 19:30       ` [PATCH 2/5] perf unwind: Do not look at globals Jiri Olsa
2018-01-16 19:45         ` Arnaldo Carvalho de Melo
2018-01-16 19:55           ` Jiri Olsa
2018-01-16 20:07             ` Arnaldo Carvalho de Melo
2018-01-16 14:24 ` [PATCH 3/5] perf trace: Setup DWARF callchains for non-syscall events when --max-stack is used Arnaldo Carvalho de Melo
2018-01-16 14:24 ` [PATCH 4/5] perf trace: Allow overriding global --max-stack per event Arnaldo Carvalho de Melo
2018-01-16 14:24 ` [PATCH 5/5] perf callchains: Ask for PERF_RECORD_MMAP for data mmaps for DWARF unwinding Arnaldo Carvalho de Melo
2018-01-16 15:27 ` [RFC 0/5] per-event settings fixes Thomas-Mich Richter
2018-01-16 15:38   ` Arnaldo Carvalho de Melo

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=20180117053428.GA7530@danjae.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tmricht@linux.vnet.ibm.com \
    --cc=wangnan0@huawei.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 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.