Received: by 10.192.165.156 with SMTP id m28csp1114360imm; Wed, 11 Apr 2018 12:41:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/xfYjng8DeEP6uIJwJ3hI9CviCclPC/w7NYz83UkOtjdKFGj8K1y+GeMVGxm0+LHzAeY1h X-Received: by 10.98.244.6 with SMTP id r6mr5083274pff.242.1523475718209; Wed, 11 Apr 2018 12:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523475718; cv=none; d=google.com; s=arc-20160816; b=lFYYw+vC1XW+ORU/Iy3KA3QQLpUc3CKUjmMpkBUR277m9pqHiRMAVveJtr+TwZRF0c LS8J1Xt9VPZlL0WEc8WriAtts8IuaZp0cRNQjwAscgiBL5TzlmBp/9aoQqzwtuoqojHk 89WhNmMH0R8fj2h+ndOXiF0zCE51syCUWcyXZGDb04nmxoE4ef7LjOj3JAM0ntFBeXOp hN274SZxiQP/sOaUjpkPyEiN3QZu5hdJA2E4dXxnpmg/flaEf5nGTqsaJDWUy0boojEF Rc9ZpTXKYzpaUFr0ki5K4F4HXyWvn8MrJ+R3CN/GZsxCaqmlXkp5BK4HWpg06Ucunwnv jT4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=klTRBfEA40dkUtRLpFcOHBaDlHuY/HVWeSY5FGIu6dc=; b=fftb/P/g11A/MyQPKHmV5m51rDpkiWewJOOUSsc4665LesoUH5Po2SIGVNbCGRXUqA ODURWSL1rbUOquCJeClAWEuRo/p6SpztXMLlRCk6mgjeECvduN/LRocFsgb0rQhaHr3f LMbVoym7byBh4gApiv7pc0wQsojvxtRiMrXyVC2ckTqAJ/SBWLdJ2Zx/JwxbPthYb4mQ RI9iFT0ofSxh8dusmIcK/5GDane9D/1LRO6qfr2Ka5Vow5vWT2f+3Ynbl4X+Hn7Ku1h2 AEiUrAdw0FX7kXCRfMLGuHL5Sd1vdyyxbXoqXo3lxTEf5Wbem8M8TEJfuOmteFdbtkq8 /ksA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si1669550plt.441.2018.04.11.12.41.21; Wed, 11 Apr 2018 12:41:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934283AbeDKTBk (ORCPT + 99 others); Wed, 11 Apr 2018 15:01:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38234 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756849AbeDKTBe (ORCPT ); Wed, 11 Apr 2018 15:01:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 73214DAC; Wed, 11 Apr 2018 19:01:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , Jiri Olsa , Andi Kleen , David Ahern , Peter Zijlstra , kernel-team@lge.com, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.9 195/310] perf header: Set proper module name when build-id event found Date: Wed, 11 Apr 2018 20:35:34 +0200 Message-Id: <20180411183630.979890454@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namhyung Kim [ Upstream commit 1deec1bd96ccd8beb04d2112a6d12fe20505c3a6 ] When perf processes build-id event, it creates DSOs with the build-id. But it didn't set the module short name (like '[module-name]') so when processing a kernel mmap event of the module, it cannot found the DSO as it only checks the short names. That leads for perf to create a same DSO without the build-id info and it'll lookup the system path even if the DSO is already in the build-id cache. After kernel was updated, perf cannot find the DSO and cannot show symbols in it anymore. You can see this if you have an old data file (w/ old kernel version): $ perf report -i perf.data.old -v |& grep scsi_mod build id event received for /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz : cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1 Failed to open /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz, continuing without symbols ... The second message didn't show the build-id. With this patch: $ perf report -i perf.data.old -v |& grep scsi_mod build id event received for /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz: cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1 /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz with build id cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1 not found, continuing without symbols ... Now it shows the build-id but still cannot load the symbol table. This is a different problem which will be fixed in the next patch. Signed-off-by: Namhyung Kim Acked-by: Jiri Olsa Cc: Andi Kleen Cc: David Ahern Cc: Peter Zijlstra Cc: kernel-team@lge.com Link: http://lkml.kernel.org/r/20170531120105.21731-1-namhyung@kernel.org [ Fix the build on older compilers (debian <= 8, fedora <= 21, etc) wrt kmod_path var init ] Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/header.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1454,8 +1454,16 @@ static int __event_process_build_id(stru dso__set_build_id(dso, &bev->build_id); - if (!is_kernel_module(filename, cpumode)) - dso->kernel = dso_type; + if (dso_type != DSO_TYPE_USER) { + struct kmod_path m = { .name = NULL, }; + + if (!kmod_path__parse_name(&m, filename) && m.kmod) + dso__set_short_name(dso, strdup(m.name), true); + else + dso->kernel = dso_type; + + free(m.name); + } build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);