Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3323539yba; Tue, 16 Apr 2019 09:04:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxa7bQnTZDLAvjFN6F/T13majKA4wc60MPvHqoRiBKDigKRk1MoSShULwsjmbWAnbLUaRqL X-Received: by 2002:a62:6f02:: with SMTP id k2mr67967451pfc.136.1555430642076; Tue, 16 Apr 2019 09:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555430642; cv=none; d=google.com; s=arc-20160816; b=hDC0tQ0xXmQMh559if6kjU3KV8H7yYewXlhd+8wsncyANzBu7VZxkrKPSXfLpJd0dB kzG/C6x1xaKFhgV/HdJm+L7UX66OdVZmQyW3NCIDn6AkJqXD9zioTZ1qgt0Lqv7YOSve /BbVIPhpOVeRUsIT6epgaJ0dMz92gAsUHmeJkoBfvUk1Mg614h4hrs+XnunFUYyGFoec iHH+SX8xgnthLWdFy0p1Auf1/e9snw/rX0JEdTpbtM64n6qWxA9UvtvRBYsS1jpvZQaK ojUA73mqsyuz8VyV1S+SPpZGXvacR0xt501vaoh8+lkLSniVV6g8iyuA+/FaVROFB2Kh z8Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=RXXZUD7B6o5jsrNrJagRaEdezKfSBtdcYzOgH5BhpNc=; b=dZRsxxxHFQspjk8yofQgO0AGNwhOL0bLh0JlCQpAaqSoxCjOi+UfxqPGqO4HdqJrzm rT1CchKUuyxmSyWGwH3/oDx5RrbJLHgXTytEpmV/Xd+2Ld6dpS98VyJrBY1ctwsoxKsI UW48ioLlOh1g39de7evrntnFjWM2PJSrJs1OE/hcSx2j5Uj+YnLGURI+nqP+fjDK1fMz xDakI+pQNNk9BNHnNpYOkoG7G+/id0QrLkgysqOrZ6G7xbCjjxjYG6nSHkpwnsWV/wwb WMrYdpzmoCQPVTOCiUk6+O8vt4XHkctqSyu32Nxemug6mZWBOkaJAIAIjItFn8ZCUgd8 7xyQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si51426857pfa.154.2019.04.16.09.03.45; Tue, 16 Apr 2019 09:04:02 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbfDPQBw (ORCPT + 99 others); Tue, 16 Apr 2019 12:01:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38078 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729934AbfDPQBu (ORCPT ); Tue, 16 Apr 2019 12:01:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EBB14C05242C; Tue, 16 Apr 2019 16:01:49 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A495C5D71A; Tue, 16 Apr 2019 16:01:47 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Adrian Hunter , Song Liu , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 05/12] perf tools: Read also the end of the kernel Date: Tue, 16 Apr 2019 18:01:20 +0200 Message-Id: <20190416160127.30203-6-jolsa@kernel.org> In-Reply-To: <20190416160127.30203-1-jolsa@kernel.org> References: <20190416160127.30203-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 16 Apr 2019 16:01:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Link: http://lkml.kernel.org/n/tip-ynut991ttyyhvo1sbhlm4c42@git.kernel.org Signed-off-by: Jiri Olsa --- 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 3c520baa198c..ad0205fbb506 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; } @@ -1440,7 +1446,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) @@ -1459,9 +1465,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; @@ -1471,16 +1477,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; -- 2.17.2