Received: by 10.192.165.156 with SMTP id m28csp1165776imm; Wed, 11 Apr 2018 13:43:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx48gXsAgLePDI3+99KY6jyYH461CD+yW1okNgQiAcjKthRVlOjpoMMxZbEsCYRA3IEWt+5x1 X-Received: by 10.98.80.145 with SMTP id g17mr5258500pfj.71.1523479381448; Wed, 11 Apr 2018 13:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523479381; cv=none; d=google.com; s=arc-20160816; b=fi3KdPFFtsmcPGE5ZMmtBEQgwtcIZ5Awz1tWuH3oQtc43jxJTz+a1G2bDyXrZGRGVv F8QP4sDtzXZl9BSXlINR5ED6aRk7luRl6XDIF+GIfv1Xpp64K9L3hxjyNvzxCtOtoPc9 TFEFFO8/5EevTT9KK0SxeKdqRM0bT+oTrseo8E8I7sUkiE2MZqmjg1nOaPRHNrXlLyo/ OibzYah8YTUF3xI5BlnKgl6Ofg4tul7CCzYGT83Cf/mu7jQ+oBTDkK/hqEFZ86HKBUJD TETQOmrIIiaaNd3khadknx/cSkPW64yqHv2FQBEt40+5XjB9bcYQiX5XdrCVrJDbi+Mi GKPQ== 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=lv1XkHzO12D1lQdNj4JwvAf8E59oodXRypNaTEYQnyk=; b=O8iuIBqo08DxXyr+GIV2c1BkivyXFlvP03KqW5+Xubl2KMXNsGruBsfpvrL5E6SXdb z08+3e7Zq7u0haeOe0ZSaLO86PLI5h3u00Pav0ZdFahK7G9ER8j4N6H+qCTn1Gsv9YAe oZPHdRR13GjzEQzRJfdEv8QkC35cyAhsfw7B07eWMjbC9V9XeRyhejj3oqxRKXnVg1+T ddlWTTt16l2B9IttIxF4WMQ/k9oU5g4t11hOBiO3CjCdNwQt5jn+1x2mq5xGRmj+dM4R UYbVK4ljsIeFsl5/kgmpMr+3vFxdIK+jsFw0Xs0U6Tpa/WFyn1psOCbB62qOqJa3i7sO QbHA== 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 o5si1166118pgp.796.2018.04.11.13.42.24; Wed, 11 Apr 2018 13:43:01 -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 S1756172AbeDKSs6 (ORCPT + 99 others); Wed, 11 Apr 2018 14:48:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754583AbeDKSsz (ORCPT ); Wed, 11 Apr 2018 14:48:55 -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 04B56E3C; Wed, 11 Apr 2018 18:48:55 +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.4 121/190] perf header: Set proper module name when build-id event found Date: Wed, 11 Apr 2018 20:36:07 +0200 Message-Id: <20180411183558.608495202@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183550.114495991@linuxfoundation.org> References: <20180411183550.114495991@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.4-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 @@ -1258,8 +1258,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);