Re: [PATCH 1/2] perf symbols: Ignore mapping symbols on aarch64

From: Victor Kamensky
Date: Wed Jan 14 2015 - 21:51:14 EST


On 14 January 2015 at 16:03, Russell King - ARM Linux
<linux@xxxxxxxxxxxxxxxx> wrote:
> On Wed, Jan 14, 2015 at 10:38:38AM -0800, Victor Kamensky wrote:
>> >From fed6caab410ddcaf487ff23a3908eca129e50b89 Mon Sep 17 00:00:00 2001
>> From: Victor Kamensky <victor.kamensky@xxxxxxxxxx>
>> Date: Wed, 14 Jan 2015 07:42:41 -0800
>> Subject: [PATCH 3/3] perf symbols: improve abi compliance in arm mapping
>> symbols handling
>>
>> Both Arm and Aarch64 ELF ABI allow mapping symbols be in from
>> either "$d" or "$d.<any>". But current code that handles mapping
>> symbols only deals with the first, dollar character and a single
>> letter, case.
>>
>> The patch adds handling of the second case with period
>> followed by any characters.
>>
>> Suggested-by: Will Deacon <will.deacon@xxxxxxx>
>> Signed-off-by: Victor Kamensky <victor.kamensky@xxxxxxxxxx>
>
> I wonder if it would make more sense to re-use the "is_arm_mapping_symbol"
> thing which we have in kernel/module.c and scripts/kallsyms.c - it
> seems silly to re-invent code which we already have to detect these
> symbols.

Thanks for pointing this out. I did not know about
"is_arm_mapping_symbol" function.

Do you suggest we copy one of those functions into tools/perf?
Since tools/perf is separate user-land utility I don't see easy way
how can we reuse those directly.

Also those functions check for mapping symbols
seems to be more efficient that one I come with, for example
one from scripts/kallsyms.c

static inline int is_arm_mapping_symbol(const char *str)
{
return str[0] == '$' && strchr("axtd", str[1])
&& (str[2] == '\0' || str[2] == '.');
}

But it seems that they are somewhat accurate: because they bundle
EM_ARM and EM_AARCH64 into one case. According to ABIs
for EM_ARM we have $a, $t, $d, $a.<any>, $t.<any>, $d.<any>;
and for EM_AARCH64 we have $x, $d, $x.<any>, $d.<any>.

How about the following two variants of the patch. It follows the same
mapping handling logic as in other 3 copies of is_arm_mapping_symbol
function in kernel, but it still separate copy in tools/perf code. Personally I
prefer variant 1, but I am fine with variant 2 too, because practically it
will be OK.

Variant 1 (as addition to this patch, as above):