Received: by 10.192.165.148 with SMTP id m20csp883135imm; Wed, 25 Apr 2018 09:05:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5FCe0dyJLJPnoN1zkp2Yv+yHEwIKBeN3bDpvbi0XFhd+s1mKuPi0f3u/zs2oLdEZ6+94+ X-Received: by 10.98.138.68 with SMTP id y65mr28249916pfd.110.1524672322153; Wed, 25 Apr 2018 09:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672322; cv=none; d=google.com; s=arc-20160816; b=SPfU4v12vAWMiIy2rhiYeHqbDWITRyEa9Ll2tXstAFW+BKgKa4szUwVRy7D55H4z7V qkrfDLYJYSLrfyZiyt4ZMe9ax/ZvJEcvKDg2wyY5KWiqz4WXLBGeRafJl84/7YDYWBAO m9TB04VtMlw0dAj/xkHPbsw6OqF9btLkFPMQnj/K1mPAyHQK0eraCgmr+kEVGYOnOL1I JFOXsu7Nr0LMYSOO1XTwdN2xjch/nY5h/bWzwchbJ06teP/4WQ5U5XFm/dpvs9CaDR9L nIXcW18VbTTr4CtDQwnJuBLkkalRtC2Qi3TIBN/dwCI1GSG8If/jttWBtRzI5hkQSiVO tPhg== 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:dmarc-filter:arc-authentication-results; bh=q7Wclx5x6phxjCSpFAMtE6q/6irUGRfL44MXyn4QxX0=; b=dfA53iowrD7IpbzTPapxmO31gAmzhdy+wi1koFphBQ1eoam000vPTdWprtIZAgu/zX D8teUyx7FCKSUHcavolkJcP0N8varwwOYits9VbO34vzoV3bgD8HtC0NRHKGAuQzwFhK zDfNdxVgXh0jKSkzQKO/lwmn2BQLrf4Q4zrErVxwCTUwv58jQZNgqH1orarxMmxIWj6h feFvtCGJa3JFS3se2IaHNqtEDyjFusBCqHEAu1+L+daPdoGZ+bHmOJmUoTQYM8y3zsQL qZX/YjVlmzKRNrLLO3X6dUzBjXl7HLkQN7irEnqsBWV0r7CdOb9SFDaEQ4UHIm4AZH8c cuVQ== 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 z24si10687797pge.161.2018.04.25.09.05.06; Wed, 25 Apr 2018 09:05:22 -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 S932109AbeDYQEB (ORCPT + 99 others); Wed, 25 Apr 2018 12:04:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:46870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755307AbeDYQAW (ORCPT ); Wed, 25 Apr 2018 12:00:22 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C390E21759; Wed, 25 Apr 2018 16:00:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C390E21759 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Namhyung Kim , Jiri Olsa , Peter Zijlstra , kernel-team@lge.com, Arnaldo Carvalho de Melo Subject: [PATCH 01/12] perf machine: Set main kernel end address properly Date: Wed, 25 Apr 2018 12:59:57 -0300 Message-Id: <20180425160008.3407-2-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180425160008.3407-1-acme@kernel.org> References: <20180425160008.3407-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim map_groups__fixup_end() was called to set the end addresses of kernel and module maps. But now since machine__create_modules() sets the end address of modules properly, the only remaining piece is the kernel map. We can set it with adjacent module's address directly instead of calling map_groups__fixup_end(). If there's no module after the kernel map, the end address will be ~0ULL. Since it also changes the start address of the kernel map, it needs to re-insert the map to the kmaps in order to keep a correct ordering. Kim reported that it caused problems on ARM64. Reported-by: Kim Phillips Tested-by: Kim Phillips Signed-off-by: Namhyung Kim Cc: Jiri Olsa Cc: Peter Zijlstra Cc: kernel-team@lge.com Link: http://lkml.kernel.org/r/20180419235915.GA19067@sejong Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 2eca8478e24f..32d50492505d 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1019,13 +1019,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type) return ret; } -static void map_groups__fixup_end(struct map_groups *mg) -{ - int i; - for (i = 0; i < MAP__NR_TYPES; ++i) - __map_groups__fixup_end(mg, i); -} - static char *get_kernel_version(const char *root_dir) { char version[PATH_MAX]; @@ -1233,6 +1226,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; int ret; @@ -1259,13 +1253,25 @@ int machine__create_kernel_maps(struct machine *machine) machine__destroy_kernel_maps(machine); return -1; } - machine__set_kernel_mmap(machine, addr, 0); + + /* we have a real start address now, so re-order the kmaps */ + map = machine__kernel_map(machine); + + map__get(map); + map_groups__remove(&machine->kmaps, map); + + /* assume it's the last in the kmaps */ + machine__set_kernel_mmap(machine, addr, ~0ULL); + + map_groups__insert(&machine->kmaps, map); + map__put(map); } - /* - * Now that we have all the maps created, just set the ->end of them: - */ - map_groups__fixup_end(&machine->kmaps); + /* 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); + return 0; } -- 2.14.3