Re: [PATCH v4] perf tools: Fix build-id matching on vmlinux

From: Namhyung Kim
Date: Mon Sep 29 2014 - 00:45:33 EST


Hi Ingo and Arnaldo,

On Wed, 24 Sep 2014 09:33:56 +0200, Ingo Molnar wrote:
> * Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>> @@ -1062,8 +1063,26 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
>> * Should be there already, from the build-id table in
>> * the header.
>> */
>> - struct dso *kernel = __dsos__findnew(&machine->kernel_dsos,
>> - kmmap_prefix);
>> + struct dso *kernel = NULL;
>> + struct dso *dso;
>> +
>> + list_for_each_entry(dso, &machine->kernel_dsos, node) {
>> + const char *suffix;
>> + size_t len = strlen(dso->long_name);
>> +
>> + if (WARN_ONCE(len <= 3, "Too short dso name"))
>> + continue;
>> +
>> + suffix = dso->long_name + len - 3;
>> + if (strcmp(suffix, ".ko")) {
>> + kernel = dso;
>> + break;
>> + }

I just noticed that the modules can be gzip'ed on some system
(e.g. Arch) so that it no longer has the ".ko" suffix.

$ ls /lib/modules/`uname -r`/kernel/fs/btrfs/
btrfs.ko.gz


Actually in this case, the dso->long_name cannot be set since when perf
record synthesizes module map events, it checks the ".ko" suffix
also. :/

And I also guess that if one loads a custom module not in a canonical
path, it again cannot find the long name (absolute path) of the module
and it results in no ".ko" suffix in the long name - so the check will
be broken too.


>> + }
>> +
>> + if (kernel == NULL)
>> + kernel = __dsos__findnew(&machine->kernel_dsos,
>> + kmmap_prefix);
>
> Please don't break the line just to pacify checkpatch.pl. Other
> than that:

For non string literals too? Anyway in this case, it's already broken. :)


>
> Acked-by: Ingo Molnar <mingo@xxxxxxxxxx>

Thanks anyway! :)

Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/