linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>,
	Hendrik Brueckner <brueckner@linux.vnet.ibm.com>,
	zvonko.kosic@de.ibm.com, Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: perf report does not resolve symbols on s390x
Date: Wed, 12 Jul 2017 11:05:28 +0200	[thread overview]
Message-ID: <371172f0-ecb9-c1c9-a478-e618c0f63c51@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170711190304.GH27350@kernel.org>

On 07/11/2017 09:03 PM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jul 07, 2017 at 02:17:25PM +0200, Thomas-Mich Richter escreveu:
>> On 07/06/2017 02:35 PM, Thomas-Mich Richter wrote:
>>> On 07/05/2017 05:50 PM, Arnaldo Carvalho de Melo wrote:

[...]

>> The fog has lifted and I found the root cause. Digging into machine__resolve was the
>> right hint...
> 
>> What happens is this (short version)
>> machine__resolve has map and sym pointers ( al->map:0x32629190 al->sym:0x32776f40 )
>> --> sample__resolve_callchain al->map:0x32629190 al->sym:0x32776f40
>>     --> thread__resolve_callchain al->map:0x32629190 al->sym:0x32776f40
>>         --> thread__resolve_callchain_sample
>>             creates a new struct addr_location to find the ip addr and its details.
>>             --> add_callchain_ip (cpumode:2 --> user space address indicator)
>>                 --> thread__find_addr_map 
>>                     this function can not resolve the address and as a last action
>>                     tries to resolve the address within kernel address space 
>>                     --> machine__get_kernel_start
> 
>> Now this function is interesting:
> 
>> int machine__get_kernel_start(struct machine *machine)
>> {
>>         struct map *map = machine__kernel_map(machine);
>>         int err = 0;
> 
>>         /*
>>          * The only addresses above 2^63 are kernel addresses of a 64-bit
>>          * kernel.  Note that addresses are unsigned so that on a 32-bit system
>>          * all addresses including kernel addresses are less than 2^32.  In
>>          * that case (32-bit system), if the kernel mapping is unknown, all
>>          * addresses will be assumed to be in user space - see
>>          * machine__kernel_ip().
>>          */
>>         machine->kernel_start = 1ULL << 63;
>>         if (map) {
>>                 err = map__load(map);
>>                 if (map->start)
>>                         machine->kernel_start = map->start;
>>         }
>>         return err;
>> }
> 
>> It determines the kernel starts at address 1<<63 and loads the kernel address mapping.
>> On s390x
>> - The kernel starts at 0x0 (value of map->start) and thus all checks in function 
>>   thread__find_addr_map() fail and no symbol is found for the specified addresses
>>   because the kernel starts at 0x8000000000000000. Which is wrong the kernel start at 0x0.
> 
> Hi Thomas, really nice debugging session!

Thanks for the credit.... :-)
> 
> I'm trying the one-liner below, Adrian, can you please check this and
> provide an ack? I think that that comment about the address that it will
> default when map__load() fails needs rewriting in light of Thomas
> comments about other arches (see further below)?
> 
> I did a quick check of machine->kernel_start usage in Intel PT and since
> on x86 that assumption about partitioning the address space holds, no
> problem should be introduced by the one-liner fix, right?
> 
> - Arnaldo
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 5de2b86b9880..2e9eb6aa3ce2 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -2209,7 +2209,7 @@ int machine__get_kernel_start(struct machine *machine)
>  	machine->kernel_start = 1ULL << 63;
>  	if (map) {
>  		err = map__load(map);
> -		if (map->start)
> +		if (!err)
>  			machine->kernel_start = map->start;
>  	}
>  	return err;
> 
> 

I like this patch. I have done a new build and removed all my debug output to start
from scratch. Without your patch I get this:

 To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 4  of event 'cpu-clock'
# Event count (approx.): 1000000
#
# Children      Self  Command  Shared Object     Symbol                  
# ........  ........  .......  ................  ........................
#
    75.00%     0.00%  true     [unknown]         [k] 0x00000000004bedda
            |
            ---0x4bedda
               |          
               |--50.00%--0x42693a
               |          |          
               |           --25.00%--0x2a72e0
               |                     0x2af0ca
               |                     0x3d1003fe4c0
               |          
                --25.00%--0x4272bc
                          0x26fa84


and with your patch (I just rebuilt the perf tool, nothing else and used the same
perf.data file as input):

# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 4  of event 'cpu-clock'
# Event count (approx.): 1000000
#
# Children      Self  Command  Shared Object               Symbol                            
# ........  ........  .......  ..........................  ..................................
#
    75.00%     0.00%  true     [kernel.vmlinux]            [k] pgm_check_handler
            |
            ---pgm_check_handler
               do_dat_exception
               handle_mm_fault
               __handle_mm_fault
               filemap_map_pages
               |          
               |--25.00%--rcu_read_lock_held
               |          rcu_lockdep_current_cpu_online
               |          0x3d1003ff4c0
               |          
                --25.00%--lock_release


Looks good to me....

>> -- 
>> Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany
>> --
>> Vorsitzende des Aufsichtsrats: Martina Koederitz 
>> Geschäftsführung: Dirk Wittkopp
>> Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
> 


-- 
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

      parent reply	other threads:[~2017-07-12  9:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 14:45 perf report does not resolve symbols on s390x Thomas-Mich Richter
2017-07-05 15:50 ` Arnaldo Carvalho de Melo
2017-07-06  7:23   ` Thomas-Mich Richter
2017-07-06 12:35   ` Thomas-Mich Richter
2017-07-07 12:17     ` Thomas-Mich Richter
2017-07-07 12:22       ` Arnaldo Carvalho de Melo
2017-07-11 19:03       ` Arnaldo Carvalho de Melo
2017-07-11 19:38         ` Arnaldo Carvalho de Melo
2017-07-11 19:48           ` Arnaldo Carvalho de Melo
2017-07-12  8:21             ` Thomas-Mich Richter
2017-07-12 10:40             ` Michael Ellerman
2017-07-12 14:04               ` Arnaldo Carvalho de Melo
2017-07-13 12:02                 ` Michael Ellerman
2017-07-12  9:05         ` Thomas-Mich Richter [this message]

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=371172f0-ecb9-c1c9-a478-e618c0f63c51@linux.vnet.ibm.com \
    --to=tmricht@linux.vnet.ibm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=zvonko.kosic@de.ibm.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).