Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3766933pxb; Tue, 17 Nov 2020 03:04:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxP23KvqdWCA0Syf7AC9SMl3ic0jt0VBcsMBakmyDRLCUhilddcSPn6/+XnsxZZUl6pP+nb X-Received: by 2002:a17:906:3ac4:: with SMTP id z4mr18580124ejd.92.1605611049951; Tue, 17 Nov 2020 03:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605611049; cv=none; d=google.com; s=arc-20160816; b=eDl5OO06qAb2vZJe+0rmtso7iGNUb+WuxuKaqzdJkYmhrZIm3jCtIS3E9f3goA+lI7 A1ktn247El6SUGaPU3B6QHCyceliOK7DalH+jghnlmwzjyv8pP0G7UzrVg32+9kj22+b m42B2RVeT8dF2EeNWkdawu6OJdGRRIrB3t1k4wjZoNDhRWk4VxUYFyQ7eiP44j39fl1T qWrUucf/PYGBD3xg8+KHY3MRo4lGlGFq0zNIGsSiVUrt6po0S/vSEnT9Ec9VxSNr9quh 3jmHhQrNXZJE79KQxdmhaYae7myZnMoBEu9DoFW7ARHVEfMvCxhjhjFc7Wyyh4AcAGAl Shgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hbLMJOqYbalQi96QJvxPMz4tye2gx/zl39UkAicx1wA=; b=iCavgiMtW2t/WgvoWe/QtM4/3+p4/bluYWEJwbebUOb460NluGUU3V0PkwGdv4eYEo qImmO0RbUPCGUBago8X49q99cqrNg9BdD3Wydjyo9pSgEEdsg9+lX0jTy7k2X8bJiqjW 4TF53tKmMk7XBWCEszOvSO/qm+BcI9LhxcSjhpKaDLSGuw0faz5FJhAzgedX0V5ogXa9 hiKwnny48+cwksJZJB1ULCKbAkkQDnrvToXx7qW9rB01tc4UF3FWgoWo16YBeXi5bKbo H74lqSsG+T6IPtUliMVaO+Yzuc/y7s+kzHgIJH4+LjDQRW4sUKodudba+/SU3g5U9jdv F8Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si178552ejc.387.2020.11.17.03.03.46; Tue, 17 Nov 2020 03:04:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728346AbgKQLBv convert rfc822-to-8bit (ORCPT + 99 others); Tue, 17 Nov 2020 06:01:51 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:58847 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727526AbgKQLBu (ORCPT ); Tue, 17 Nov 2020 06:01:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-7O7OghAJMq2Q-lLoLjG-cw-1; Tue, 17 Nov 2020 06:01:43 -0500 X-MC-Unique: 7O7OghAJMq2Q-lLoLjG-cw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10E52803F50; Tue, 17 Nov 2020 11:01:41 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA7EF5C1CF; Tue, 17 Nov 2020 11:01:37 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 11/24] perf tools: Try to load vmlinux from buildid database Date: Tue, 17 Nov 2020 12:00:40 +0100 Message-Id: <20201117110053.1303113-12-jolsa@kernel.org> In-Reply-To: <20201117110053.1303113-1-jolsa@kernel.org> References: <20201117110053.1303113-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we don't check on kernel's vmlinux the same way as we do for normal binaries, but we either look for kallsyms file in build id database or check on known vmlinux locations (plus some other optional paths). This patch adds the check for standard build id binary location, so we are ready once we start to store it there from debuginfod in following changes. Signed-off-by: Jiri Olsa --- tools/perf/util/build-id.c | 13 ++++++++++--- tools/perf/util/build-id.h | 2 ++ tools/perf/util/symbol.c | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index ef9a31b54ba2..2755d7b37a44 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -260,10 +260,9 @@ static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso, "debug" : "elf")); } -char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size, - bool is_debug) +char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t size, + bool is_debug, bool is_kallsyms) { - bool is_kallsyms = dso__is_kallsyms((struct dso *)dso); bool is_vdso = dso__is_vdso((struct dso *)dso); char sbuild_id[SBUILD_ID_SIZE]; char *linkname; @@ -292,6 +291,14 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size, return bf; } +char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size, + bool is_debug) +{ + bool is_kallsyms = dso__is_kallsyms((struct dso *)dso); + + return __dso__build_id_filename(dso, bf, size, is_debug, is_kallsyms); +} + #define dsos__for_each_with_build_id(pos, head) \ list_for_each_entry(pos, head, node) \ if (!pos->has_build_id) \ diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index d53415feaf69..f1a2f67df6e4 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -29,6 +29,8 @@ char *build_id_cache__kallsyms_path(const char *sbuild_id, char *bf, char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size, bool is_debug); +char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t size, + bool is_debug, bool is_kallsyms); int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 0d14abdf3d72..64a039cbba1b 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -2189,6 +2189,8 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map) int err; const char *kallsyms_filename = NULL; char *kallsyms_allocated_filename = NULL; + char *filename = NULL; + /* * Step 1: if the user specified a kallsyms or vmlinux filename, use * it and only it, reporting errors to the user if it cannot be used. @@ -2213,6 +2215,20 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map) return dso__load_vmlinux(dso, map, symbol_conf.vmlinux_name, false); } + /* + * Before checking on common vmlinux locations, check if it's + * stored as standard build id binary (not kallsyms) under + * .debug cache. + */ + if (!symbol_conf.ignore_vmlinux_buildid) + filename = __dso__build_id_filename(dso, NULL, 0, false, false); + if (filename != NULL) { + err = dso__load_vmlinux(dso, map, filename, true); + if (err > 0) + return err; + free(filename); + } + if (!symbol_conf.ignore_vmlinux && vmlinux_path != NULL) { err = dso__load_vmlinux_path(dso, map); if (err > 0) -- 2.26.2