From: Adrian Hunter <adrian.hunter@intel.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
Chris Phlipot <cphlipot0@gmail.com>,
acme@kernel.org, mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH 1/5] perf tools: fix incorrect ordering of callchain entries
Date: Fri, 22 Apr 2016 10:59:29 +0300 [thread overview]
Message-ID: <5719D9E1.9020507@intel.com> (raw)
In-Reply-To: <5719D909.9020303@intel.com>
+Jiri since he wrote the original code
On 22/04/16 10:55, Adrian Hunter wrote:
> On 19/04/16 11:56, Chris Phlipot wrote:
>> The existing implentation implementation of thread__resolve_callchain,
>
> Remove 'implentation'
>
>> under certain circumstanes, can assemble callchain entries in the
>
> 'circumstanes' -> 'circumstances'
>
>> incorrect order.
>>
>> A the callchain entries are resolved incorrectly for a sample when all
>> of the following conditions are met:
>>
>> 1. callchain_param.order is set to ORDER_CALLER
>>
>> 2. thread__resolve_callchain_sample is able to resolve callchain entries
>> for the sample.
>>
>> 3. unwind__get_entries is also able to resolve callchain entries for the
>> sample.
>>
>> The fix is accomplished by reversing the order in which
>> thread__resolve_callchain_sample and unwind__get_entries are called
>> when callchain_param.order is set to ORDER_CALLER.
>
> Can you give an example of the commands you used and what the call chain
> looked like before and after.
>
> Also please run ./scripts/checkpatch.pl
>
>>
>> Unwind specific code from thread__resolve_callchain is also moved into a
>> new static function to improve readability of the fix.
>>
>> Signed-off-by: Chris Phlipot <cphlipot0@gmail.com>
>> ---
>> tools/perf/util/machine.c | 57 ++++++++++++++++++++++++++++++++++-------------
>> 1 file changed, 41 insertions(+), 16 deletions(-)
>>
>> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
>> index 0c4dabc..dd086c8 100644
>> --- a/tools/perf/util/machine.c
>> +++ b/tools/perf/util/machine.c
>> @@ -1806,8 +1806,6 @@ static int thread__resolve_callchain_sample(struct thread *thread,
>> int skip_idx = -1;
>> int first_call = 0;
>>
>> - callchain_cursor_reset(cursor);
>> -
>> if (has_branch_callstack(evsel)) {
>> err = resolve_lbr_callchain_sample(thread, cursor, sample, parent,
>> root_al, max_stack);
>> @@ -1918,20 +1916,12 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
>> entry->map, entry->sym);
>> }
>>
>> -int thread__resolve_callchain(struct thread *thread,
>> - struct callchain_cursor *cursor,
>> - struct perf_evsel *evsel,
>> - struct perf_sample *sample,
>> - struct symbol **parent,
>> - struct addr_location *root_al,
>> - int max_stack)
>> -{
>> - int ret = thread__resolve_callchain_sample(thread, cursor, evsel,
>> - sample, parent,
>> - root_al, max_stack);
>> - if (ret)
>> - return ret;
>> -
>> +static int thread__resolve_callchain_unwind(struct thread *thread,
>> + struct callchain_cursor *cursor,
>> + struct perf_evsel *evsel,
>> + struct perf_sample *sample,
>> + int max_stack)
>> +{
>> /* Can we do dwarf post unwind? */
>> if (!((evsel->attr.sample_type & PERF_SAMPLE_REGS_USER) &&
>> (evsel->attr.sample_type & PERF_SAMPLE_STACK_USER)))
>> @@ -1944,7 +1934,42 @@ int thread__resolve_callchain(struct thread *thread,
>>
>> return unwind__get_entries(unwind_entry, cursor,
>> thread, sample, max_stack);
>> +}
>> +
>> +int thread__resolve_callchain(struct thread *thread,
>> + struct callchain_cursor *cursor,
>> + struct perf_evsel *evsel,
>> + struct perf_sample *sample,
>> + struct symbol **parent,
>> + struct addr_location *root_al,
>> + int max_stack)
>> +{
>> + int ret = 0;
>> + callchain_cursor_reset(&callchain_cursor);
>> +
>> + if (callchain_param.order == ORDER_CALLEE) {
>> + ret = thread__resolve_callchain_sample(thread, cursor,
>> + evsel, sample,
>> + parent, root_al,
>> + max_stack);
>> + if (ret)
>> + return ret;
>> + ret = thread__resolve_callchain_unwind(thread, cursor,
>> + evsel, sample,
>> + max_stack);
>> + } else {
>> + ret = thread__resolve_callchain_unwind(thread, cursor,
>> + evsel, sample,
>> + max_stack);
>> + if (ret)
>> + return ret;
>> + ret = thread__resolve_callchain_sample(thread, cursor,
>> + evsel, sample,
>> + parent, root_al,
>> + max_stack);
>> + }
>>
>> + return ret;
>> }
>>
>> int machine__for_each_thread(struct machine *machine,
>>
>
>
next prev parent reply other threads:[~2016-04-22 8:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 8:56 [PATCH 1/5] perf tools: fix incorrect ordering of callchain entries Chris Phlipot
2016-04-19 8:56 ` [PATCH 2/5] perf script: extend db-export api to include callchains for samples Chris Phlipot
2016-04-22 7:56 ` Adrian Hunter
2016-04-23 4:41 ` Chris Phlipot
2016-04-28 8:36 ` Chris Phlipot
2016-04-19 8:56 ` [PATCH 3/5] perf script: fix postgresql ubuntu install instructions Chris Phlipot
2016-04-19 13:41 ` Arnaldo Carvalho de Melo
2016-04-23 13:03 ` [tip:perf/core] perf script: Fix " tip-bot for Chris Phlipot
2016-04-19 8:56 ` [PATCH 4/5] perf script: add option to control callchain export from python Chris Phlipot
2016-04-19 8:56 ` [PATCH 5/5] perf script: Update export-to-postgresql to support callchains Chris Phlipot
2016-04-22 7:55 ` [PATCH 1/5] perf tools: fix incorrect ordering of callchain entries Adrian Hunter
2016-04-22 7:59 ` Adrian Hunter [this message]
2016-04-23 3:35 ` Chris Phlipot
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=5719D9E1.9020507@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=cphlipot0@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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