Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5522636ybi; Tue, 28 May 2019 14:39:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjUIasDgq4TrtDuZ3pZS3u8O5vLLTUtdOsLvikqgSJ7ZJ+oH53YT7ymsgLG4ygdWnzIULo X-Received: by 2002:a17:90a:c503:: with SMTP id k3mr8491907pjt.46.1559079547352; Tue, 28 May 2019 14:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559079547; cv=none; d=google.com; s=arc-20160816; b=M5Cfm86pt5BE5bLONOf9CPguf3BDBaUX4JwXcg2K+8sIb16lq47A/OmXNMFP3Vo+kx JW2dcKVkDyJxru6HqjY+gkBYrKXrBGKD1UifrOobDJm7XgaNpp1sSeZeIL5Lgg2v/uX/ rPO3qzNwbslGiJxQBVWQW4SKd27G9DCKX6XSwmG00qBnBKJoGmr0ZvxRfa0T9+vPs/zB EDCyWtJYLDIEf+y8sskVZGeYa9LhSx5ufOr57stGIs+XlCmXDtrWnG8rYhbWTHpHEJU+ Me7L8mcSFIfqbhgnOEKU8yXCs0nrJUFyHq6wLEO7yb2tmqapv5De4KHB7hqF79asoJFZ BYgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=zNtj7Mc4odQZV1gNb3k8TscpppokV5E18Uq/s9FRLwk=; b=DJ9nrnav2R4XYNHGlte68PpeSfORSMI1wGNXwjVfMZocbxYzcWBkHWofzglNaDZSm7 b51tJxT9T4lyR8j7+UVbtPKqmths+8aseBmzueNroYmrq4K3iJcavAypEpXrcYwhwYkd M/ziSRrktuEizhj8DPnjpPqVGfNHAxnCG5xmwpSztK2OilVrKY23eUNuw0cFa/Erw7Gz FYSZKMCKqCyc45btJ9sgmwKDNKCTsJcvXVhF9yfDYgLTgR1Et2B3B/OhS38utndiBLkX 3JpcyUPNwiraQnIbJ3sLf8gkUljz0ve2tEd4NpWmGqhgAeV1q19xV0wxXO3Y+DGJ9s7w 1yLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=tnck3Tex; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si4349468plf.347.2019.05.28.14.38.50; Tue, 28 May 2019 14:39:07 -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; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=tnck3Tex; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727964AbfE1VaA (ORCPT + 99 others); Tue, 28 May 2019 17:30:00 -0400 Received: from terminus.zytor.com ([198.137.202.136]:56785 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbfE1VaA (ORCPT ); Tue, 28 May 2019 17:30:00 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x4SLTgsE2240754 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 28 May 2019 14:29:42 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x4SLTgsE2240754 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1559078983; bh=zNtj7Mc4odQZV1gNb3k8TscpppokV5E18Uq/s9FRLwk=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=tnck3TexNg8bL1B6Kce8eulx9ajAxEhdzBOBhcqPbtXytQFwDi7uLdNjeT37Usgrg g5xLhtUmpWsEgcH/oTo9XmvAI2u9p8b4ef0mgUco5T3JjNBNoVl9VQ/50rfLnwW0xJ MvR8qSxv5mGRY2ei1gFoCSS5Nnnzp2zVhGnFvMtMYNWdQ7h9LftnN1DZVeV+QPhb59 ojMsSlkfZNT6rtb2N9TAVYiVCnUW8sC1Olz4uwAz2fVXM8ciqSZiv8j38rK6aQYPEI V3Qh95MQ7C0xbEU3BSxf5nOAey6ZIib167zgFs2i7DKv4Oz2sXGXMMZiXPgDBrDAJf cin5lmoS1Bz6A== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x4SLTgv32240751; Tue, 28 May 2019 14:29:42 -0700 Date: Tue, 28 May 2019 14:29:42 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jiri Olsa Message-ID: Cc: peterz@infradead.org, songliubraving@fb.com, sdf@google.com, ak@linux.intel.com, jolsa@kernel.org, tmricht@linux.ibm.com, mingo@kernel.org, acme@redhat.com, tglx@linutronix.de, namhyung@kernel.org, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, acme@redhat.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, namhyung@kernel.org, tmricht@linux.ibm.com, jolsa@kernel.org, mingo@kernel.org, songliubraving@fb.com, peterz@infradead.org, ak@linux.intel.com, sdf@google.com In-Reply-To: <20190508132010.14512-6-jolsa@kernel.org> References: <20190508132010.14512-6-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf machine: Read also the end of the kernel Git-Commit-ID: ed9adb2035b5be5896d465b19040262be5f4a824 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ed9adb2035b5be5896d465b19040262be5f4a824 Gitweb: https://git.kernel.org/tip/ed9adb2035b5be5896d465b19040262be5f4a824 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:03 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 09:52:23 -0300 perf machine: Read also the end of the kernel We mark the end of kernel based on the first module, but that could cover some bpf program maps. Reading _etext symbol if it's present to get precise kernel map end. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Cc: Thomas Richter Link: http://lkml.kernel.org/r/20190508132010.14512-6-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 28a9541c4835..dc7aafe45a2b 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -924,7 +924,8 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; * symbol_name if it's not that important. */ static int machine__get_running_kernel_start(struct machine *machine, - const char **symbol_name, u64 *start) + const char **symbol_name, + u64 *start, u64 *end) { char filename[PATH_MAX]; int i, err = -1; @@ -949,6 +950,11 @@ static int machine__get_running_kernel_start(struct machine *machine, *symbol_name = name; *start = addr; + + err = kallsyms__get_function_start(filename, "_etext", &addr); + if (!err) + *end = addr; + return 0; } @@ -1441,7 +1447,7 @@ int machine__create_kernel_maps(struct machine *machine) struct dso *kernel = machine__get_kernel(machine); const char *name = NULL; struct map *map; - u64 addr = 0; + u64 start = 0, end = ~0ULL; int ret; if (kernel == NULL) @@ -1460,9 +1466,9 @@ int machine__create_kernel_maps(struct machine *machine) "continuing anyway...\n", machine->pid); } - if (!machine__get_running_kernel_start(machine, &name, &addr)) { + if (!machine__get_running_kernel_start(machine, &name, &start, &end)) { if (name && - map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, addr)) { + map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, start)) { machine__destroy_kernel_maps(machine); ret = -1; goto out_put; @@ -1472,16 +1478,19 @@ int machine__create_kernel_maps(struct machine *machine) * we have a real start address now, so re-order the kmaps * assume it's the last in the kmaps */ - machine__update_kernel_mmap(machine, addr, ~0ULL); + machine__update_kernel_mmap(machine, start, end); } if (machine__create_extra_kernel_maps(machine, kernel)) pr_debug("Problems creating extra kernel maps, continuing anyway...\n"); - /* update end address of the kernel map using adjacent module address */ - map = map__next(machine__kernel_map(machine)); - if (map) - machine__set_kernel_mmap(machine, addr, map->start); + if (end == ~0ULL) { + /* update end address of the kernel map using adjacent module address */ + map = map__next(machine__kernel_map(machine)); + if (map) + machine__set_kernel_mmap(machine, start, map->start); + } + out_put: dso__put(kernel); return ret;