From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755262AbbDILk6 (ORCPT ); Thu, 9 Apr 2015 07:40:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40530 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751372AbbDILky (ORCPT ); Thu, 9 Apr 2015 07:40:54 -0400 Date: Thu, 9 Apr 2015 13:40:42 +0200 From: Jiri Olsa To: Wang Nan Cc: acme@kernel.org, jolsa@kernel.org, namhyung@kernel.org, mingo@redhat.com, lizefan@huawei.com, pi3orama@163.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] perf: report/annotate: fix segfault problem. Message-ID: <20150409114042.GB1321@krava.brq.redhat.com> References: <20150407151322.GK11983@kernel.org> <1428465138-124112-1-git-send-email-wangnan0@huawei.com> <20150408135954.GA1339@krava.redhat.com> <552624B7.30903@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <552624B7.30903@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 09, 2015 at 03:05:27PM +0800, Wang Nan wrote: SNIP > When mmap event at kernel address space occures, it distinguishes kernel and kernel module > according to the name in mmap event. Unfortunately, '[test_module]' won't be regarded as kernel > at this time, so according map__kmap(map)->kmaps won't get initialized. > > If we don't have buildid-cache for [test_module], machine__process_kernel_mmap_event --> > machine__new_module --> machine__module_dso --> dsos__find will return failuer, and a new > struct dso is created using dsos__addnew, its default dso->kernel is DSO_TYPE_USER. > > Step 3: process_sample_event -> map__load: a sample with kernel IP is arise, perf > tries to load DSO of such address. > > Step 4: map__load -> dso__load: in dso__load(): > > int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) > { > ... > if (dso->kernel == DSO_TYPE_KERNEL) > return dso__load_kernel_sym(dso, map, filter); > ... > } > > Because dso->kernel of "[test_module]" is incorrectly set to DSO_TYPE_KERNEL, it goes to > dso__load_kernel_sym. Where, since we use --kallsyms explicitly, dso__load_kallsyms() will > be called. > > Step 5: dso__load_kallsyms -> dso__load_kcore: > > dso__load_kallsyms tries to call dso__load_kcore. In my case it should fail because I don't have > /proc/kcore at all. However, > > static int dso__load_kcore(struct dso *dso, struct map *map, > const char *kallsyms_filename) > { > struct map_groups *kmaps = map__kmap(map)->kmaps; > struct machine *machine = kmaps->machine; > ... ok, here it is.. I've got 'lucky' and hit the '!kmap->kmaps' check in the map__kmaps function.. so I've got pr_err output instead which I succesfully ignored ;-) I'll comment in the patch v4 nice explanation! thanks jirka