[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150306180226.GB5187@kernel.org>
Date: Fri, 6 Mar 2015 15:02:26 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Naohiro Aota <naota@...sp.net>,
Peter Zijlstra <peterz@...radead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>, namhyung@...nel.org,
Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH perf/core v2 1/5] perf-probe: Fix to handle aliased
symbols in glibc
Em Fri, Mar 06, 2015 at 02:59:19PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Mar 06, 2015 at 04:31:20PM +0900, Masami Hiramatsu escreveu:
> > Fix perf probe to handle aliased symbols correctly in glibc.
> > In the glibc, several symbols are defined as an alias of
> > __libc_XXX, e.g. malloc is an alias of __libc_malloc.
> > In such cases, dwarf has no subroutine instances of the
> > alias functions (e.g. no "malloc" instance), but the map
> > has that symbol and its address.
> > Thus, if we search the alieased symbol in debuginfo, we
> > always fail to find it, but it is in the map.
> >
> > To solve this problem, this fails back to address-based
> > alternative search, which searches the symbol in the map,
> > translates its address to alternative (correct) function
> > name by using debuginfo, and retry to find the alternative
> > function point from debuginfo.
> >
> > This adds fail-back process to --vars, --lines and --add
> > options. So, now you can use those on malloc@...c :)
>
> --vars and --add works, but not --lines:
Ok, it works after applying 2/5, so it was just me confused by the above
statement, that a fallback was added that would make --lines work, it
works, but not with this patch, the next one is needed.
Anyway, works now, I'm happy, thanks!
- Arnaldo
> [root@...andy ~]# perf probe -x /usr/lib64/libc-2.17.so -V malloc
> Available variables at malloc
> @<__libc_malloc+96>
> size_t bytes
>
> [root@...andy ~]# perf probe -x /usr/lib64/libc-2.17.so -L malloc
> Specified source line is not found.
> Error: Failed to show lines.
> [root@...andy ~]#
>
> [root@...andy ~]# perf probe -x /usr/lib64/libc-2.17.so -a "malloc
> bytes"
> Added new event:
> probe_libc:malloc (on malloc in /usr/lib64/libc-2.17.so with bytes)
>
> You can now use it in all perf tools, such as:
>
> perf record -e probe_libc:malloc -aR sleep 1
>
> [root@...andy ~]#
>
> [root@...andy ~]# cat /t/events/probe_libc/malloc/format
> name: malloc
> ID: 1921
> format:
> field:unsigned short common_type; offset:0; size:2; signed:0;
> field:unsigned char common_flags; offset:2; size:1; signed:0;
> field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
> field:int common_pid; offset:4; size:4; signed:1;
>
> field:unsigned long __probe_ip; offset:8; size:8; signed:0;
> field:u64 bytes; offset:16; size:8; signed:0;
>
> print fmt: "(%lx) bytes=0x%Lx", REC->__probe_ip, REC->bytes
> [root@...andy ~]#
>
> Works for the aliased symbol, anyway, applying as it makes progress.
>
> [root@...andy ~]# perf probe -x /usr/lib64/libc-2.17.so -L __libc_malloc
> <__libc_malloc@...r/src/debug/glibc-2.17-c758a686/malloc/malloc.c:0>
> 0 __libc_malloc(size_t bytes)
> 1 {
> mstate ar_ptr;
> void *victim;
>
> __malloc_ptr_t (*hook) (size_t, const __malloc_ptr_t)
> 6 = force_reg (__malloc_hook);
> 7 if (__builtin_expect (hook != NULL, 0))
> 8 return (*hook)(bytes, RETURN_ADDRESS (0));
>
> 10 arena_lookup(ar_ptr);
>
> 12 arena_lock(ar_ptr, bytes);
> 13 if(!ar_ptr)
> 14 return 0;
> 15 victim = _int_malloc(ar_ptr, bytes);
> 16 if(!victim) {
> 17 LIBC_PROBE (memory_malloc_retry, 1, bytes);
> 18 ar_ptr = arena_get_retry(ar_ptr, bytes);
> 19 if (__builtin_expect(ar_ptr != NULL, 1)) {
> 20 victim = _int_malloc(ar_ptr, bytes);
> 21 (void)mutex_unlock(&ar_ptr->mutex);
> }
> } else
> 24 (void)mutex_unlock(&ar_ptr->mutex);
> assert(!victim || chunk_is_mmapped(mem2chunk(victim)) ||
> ar_ptr == arena_for_chunk(mem2chunk(victim)));
> return victim;
> 28 }
> libc_hidden_def(__libc_malloc)
>
> void
>
> [root@...andy ~]#
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists