Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp274626lqo; Wed, 15 May 2024 14:11:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWK+yXqC9pLatoXzMBGh91MK8povBqW5K3YJvczj7WfImADbzCHP/2LNTADMdmu4tFFg/rYQpnO1THC2hzxPf72GfPpW9M1ht4eG+YJTw== X-Google-Smtp-Source: AGHT+IFeZ+B/CEl1gmo3SYLxEf2AVrMiM5oIpTAjDFPV4+/+RkJ/LGT5H6zsfmQS44wzEeW+p2Vu X-Received: by 2002:a50:d745:0:b0:56e:3774:749b with SMTP id 4fb4d7f45d1cf-5734d6dfeedmr9785925a12.42.1715807503923; Wed, 15 May 2024 14:11:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715807503; cv=pass; d=google.com; s=arc-20160816; b=qosXJiSpQfQTzW1EDG1/Mm0HTNb3QaurxeRhxc5XROrwFhNxmSgzg82JedxpW1tg0r gpENMYv5r0+UqV0YFuquvR4QGwUs5fQw7ymQLedKQQbT5nX/+X/JzN1svqvDkqLvU9Z3 4mA4PlYuc62K9wrD1Tht/4COod1P8QAPDTuOox9X0uEEbikg7/LX3T25W5PuB9k601Y9 mFOLWEyIrLuHSrFvBfpQKAc47CjYAN7p1Uob0qp3pJmVhLuOmi9ZUC3k0zzqRRNIuTsw xXBu1Y0YCKBoxr+Modde5fsKKTiM/UPCjw5LMsRsRtf2zEx+6mt905ZqIvIr6nsM+Cgh oyMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=vbEfWwti9sP+i3xNOtH6sDmD+qj+e++mRuYRMdwI2pI=; fh=5BksDJxA/SfhQk3QQHTEZ4fXEO+DxcBDG1/AZim0b5U=; b=hJ1zvt/NSaSSv2hmeojYbRFZOrAomnuZoRcJcljGTnA3lB/w8xW7Roj3cUSiEYMq3/ +E5rciS+66LAU1zEflxP8a5ugvWV9h5QiO6IqkB8hdT0tPHIPeQtvfH5KkXdKnuhsDyl HnFSzoWnTmEfRjzqeKeUKMFjFk/447YKSQXeruZ4L7abTawlw0LFZPGIaISAQG3urB/3 xRkqGivkh8v6gC6tBi4lEKCq+N5Icr1zWl5+YHBsRjOkpkdkAKoXhwmejhJui3jLduXR PA9iyRRhr0IL7E7QW5a7d0bOvt8IBttOzbOAk8yXNV+nN9p0PG4h0qYjiDQvEfmHgAKg sEkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-180370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c378e4dsi8116980a12.671.2024.05.15.14.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 14:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-180370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A68CD1F22312 for ; Wed, 15 May 2024 21:11:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB1FC15B57D; Wed, 15 May 2024 21:11:13 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00B3E15B554; Wed, 15 May 2024 21:11:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715807472; cv=none; b=njDWhgrt5Vr82N0oMARQ15kh0lTRgxFcPgkrF3foIpVVAlU4N4kckkzsKkMOzuGsY3mbyyqF1kbJ0oKHsHWelMF9N7qffQMFmHR/tb/HqdAmXKY0gkUK8CC5YtKqmHqUDUn386m/FACpkfeRR51Ok7gjYBTO5EHsq3ySnTPR0P4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715807472; c=relaxed/simple; bh=6NiV8lMSfEqda6TLVZB7QbPpPh0hi2mYIQL4qTTbKvY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XY7j9ubRNK/wEPijJkv96Kt7pelczo2gUNzD8eQU0zvLPLfpq9WSb9/LajPOF/iy9bwPl9DvETFgvnuuyNE0EpCBFx456doOpGiWQHp1yYtVTHZJjojZpfOEcquvvh2fhsJQdcqyf2x6rMYJ+Wse0hrNk3PEO7BQJcSn8zJqVZc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 970071042; Wed, 15 May 2024 14:11:34 -0700 (PDT) Received: from PF4Q20KV.arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 970F83F7A6; Wed, 15 May 2024 14:11:07 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Adrian Hunter , James Clark , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Ian Rogers , Mark Rutland , Alexander Shishkin , Jiri Olsa , Athira Rajeev , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 2/2] perf maps: Remove the replacement of kernel map Date: Wed, 15 May 2024 22:10:45 +0100 Message-Id: <20240515211045.377080-3-leo.yan@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240515211045.377080-1-leo.yan@arm.com> References: <20240515211045.377080-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now the kcore maps are organized in ordering, the kernel text section will be respected when merging into the kernel maps. As a result, it is no need to replace the kernel text section specially. This commit removes the code for replacement of the kernel text section. With this change, the final maps has a minor difference - it separates the kernel map [_stext.._end] into two sections: [_stext.._edata] and [_edata.._end] As result, it still keeps the intact info for the kernel regions. Signed-off-by: Leo Yan --- tools/perf/util/symbol.c | 67 +++++----------------------------------- 1 file changed, 8 insertions(+), 59 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index c1513976ab6e..0712d3a6893f 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1338,12 +1338,10 @@ static int dso__load_kcore(struct dso *dso, struct map *map, { struct maps *kmaps = map__kmaps(map); struct kcore_mapfn_data md; - struct map *map_ref, *replacement_map = NULL; struct machine *machine; bool is_64_bit; int err, fd; char kcore_filename[PATH_MAX]; - u64 stext; if (!kmaps) return -EINVAL; @@ -1388,52 +1386,6 @@ static int dso__load_kcore(struct dso *dso, struct map *map, maps__remove_maps(kmaps, remove_old_maps, map); machine->trampolines_mapped = false; - /* Find the kernel map using the '_stext' symbol */ - if (!kallsyms__get_function_start(kallsyms_filename, "_stext", &stext)) { - u64 replacement_size = 0; - struct map_list_node *new_node; - - list_for_each_entry(new_node, &md.maps, node) { - struct map *new_map = new_node->map; - u64 new_size = map__size(new_map); - - if (!(stext >= map__start(new_map) && stext < map__end(new_map))) - continue; - - /* - * On some architectures, ARM64 for example, the kernel - * text can get allocated inside of the vmalloc segment. - * Select the smallest matching segment, in case stext - * falls within more than one in the list. - */ - if (!replacement_map || new_size < replacement_size) { - replacement_map = new_map; - replacement_size = new_size; - } - } - } - - if (!replacement_map) - replacement_map = list_entry(md.maps.next, struct map_list_node, node)->map; - - /* - * Update addresses of vmlinux map. Re-insert it to ensure maps are - * correctly ordered. Do this before using maps__merge_in() for the - * remaining maps so vmlinux gets split if necessary. - */ - map_ref = map__get(map); - maps__remove(kmaps, map_ref); - - map__set_start(map_ref, map__start(replacement_map)); - map__set_end(map_ref, map__end(replacement_map)); - map__set_pgoff(map_ref, map__pgoff(replacement_map)); - map__set_mapping_type(map_ref, map__mapping_type(replacement_map)); - - err = maps__insert(kmaps, map_ref); - map__put(map_ref); - if (err) - goto out_err; - /* Add new maps */ while (!list_empty(&md.maps)) { struct map_list_node *new_node = list_entry(md.maps.next, struct map_list_node, node); @@ -1441,17 +1393,14 @@ static int dso__load_kcore(struct dso *dso, struct map *map, list_del_init(&new_node->node); - /* skip if replacement_map, already inserted above */ - if (!RC_CHK_EQUAL(new_map, replacement_map)) { - /* - * Merge kcore map into existing maps, - * and ensure that current maps (eBPF) - * stay intact. - */ - if (maps__merge_in(kmaps, new_map)) { - err = -EINVAL; - goto out_err; - } + /* + * Merge kcore map into existing maps, + * and ensure that current maps (eBPF) + * stay intact. + */ + if (maps__merge_in(kmaps, new_map)) { + err = -EINVAL; + goto out_err; } free(new_node); } -- 2.34.1