Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3795380ybv; Mon, 10 Feb 2020 06:33:46 -0800 (PST) X-Google-Smtp-Source: APXvYqx1rZgx5xIIFUkx6N35xkxtWNXGDQVn826Yzy7/JoiiVf8e0ORdR350Bfs7nOHyt2WdDJa1 X-Received: by 2002:a05:6830:c7:: with SMTP id x7mr1238701oto.272.1581345226696; Mon, 10 Feb 2020 06:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581345226; cv=none; d=google.com; s=arc-20160816; b=g+Okdgw5tqNFU/ypNhbE98xSMpRCzwv/3BTxd0Yt+3EdT5Du5dhV9vlrJ5TDJGDyi9 fMbzh4iaS7vcJnN34JbRx4uQZc1OkR6kniTjgkbxF5/WkbLVQlSBp7Exq9S0g4ULdW9j YY1MQCcdYrwrdwe+pzeoo4A9e8QvdIGBPgMoSwm90DAQpiUUqR/nusByAJwSASWH38R/ wi3K0niK+VhC2R9mAwru8LgQjbZGzKuRXvchJ1SrXElZMVdP6Od4GfxelUmpNtmDWFD4 Vv7ljpmGfo3k/4trZUrADl3Em4J78rV/hAwpkMv5/8MpcoX/kdCv/UKe9hW2uyiatsqf upAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GeIIssqxiCqVxb7uos+ku0XUxcDDx5UfD/iw/YMHqIc=; b=o5Krxt1uBrnWmT4wiF0e8EQ0bVRTJJ23qh1utxaB3zKaVKCvL1m2wTRNAAj54Ay3tq SKs43+9V4wIMv2FB3NYdVu+uL6bBDJBLGJPsZzReX2gGkkm+hXfSTEmRSDaqPPTgo97R Xu4kVPHLXQIkSswzGxWgcA/JajrxgGMKkz6bHTqGFVn1ST982DgF6QOmTlZkE3sQXxob cFX4l29kqIWpNV3jth4MMglrTNYUJNzAdlJ3UbWrXGm7KP8ifTa8P3rE7p0u7CjI6G2B 9tzWiivqjKgrLuhw9Cnh3sl96zneS1AP5dQU93oZ3rEu2NqtiopP/dYESjBIRfdmp4nV fnCw== 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 k15si250713oij.134.2020.02.10.06.33.34; Mon, 10 Feb 2020 06:33:46 -0800 (PST) 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 S1728947AbgBJOcn convert rfc822-to-8bit (ORCPT + 99 others); Mon, 10 Feb 2020 09:32:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39843 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728193AbgBJOcm (ORCPT ); Mon, 10 Feb 2020 09:32:42 -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-170-2mkHyP3OM4iZsy39PIdPKg-1; Mon, 10 Feb 2020 09:32:31 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13F7018A8C82; Mon, 10 Feb 2020 14:32:30 +0000 (UTC) Received: from krava.redhat.com (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AC6860BF1; Mon, 10 Feb 2020 14:32:28 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ravi Bangoria , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 4/4] perf tools: Move kmap::kmaps setup to maps__insert Date: Mon, 10 Feb 2020 15:32:18 +0100 Message-Id: <20200210143218.24948-5-jolsa@kernel.org> In-Reply-To: <20200210143218.24948-1-jolsa@kernel.org> References: <20200210143218.24948-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 2mkHyP3OM4iZsy39PIdPKg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So the kmaps pointer setup is centralized and we do not need to update it in all those places (2 current places and few more missing) after calling maps__insert. Reported-by: Ravi Bangoria Tested-by: Ravi Bangoria Signed-off-by: Jiri Olsa --- tools/perf/util/machine.c | 13 +------------ tools/perf/util/map.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 0a43dc83d7b2..460315476314 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -979,7 +979,6 @@ int machine__create_extra_kernel_map(struct machine *machine, kmap = map__kmap(map); - kmap->kmaps = &machine->kmaps; strlcpy(kmap->name, xm->name, KMAP_NAME_LEN); maps__insert(&machine->kmaps, map); @@ -1089,9 +1088,6 @@ int __weak machine__create_extra_kernel_maps(struct machine *machine __maybe_unu static int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) { - struct kmap *kmap; - struct map *map; - /* In case of renewal the kernel map, destroy previous one */ machine__destroy_kernel_maps(machine); @@ -1100,14 +1096,7 @@ __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) return -1; machine->vmlinux_map->map_ip = machine->vmlinux_map->unmap_ip = identity__map_ip; - map = machine__kernel_map(machine); - kmap = map__kmap(map); - if (!kmap) - return -1; - - kmap->kmaps = &machine->kmaps; - maps__insert(&machine->kmaps, map); - + maps__insert(&machine->kmaps, machine->vmlinux_map); return 0; } diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index cea05fc9595c..a08ca276098e 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -543,6 +543,16 @@ void maps__insert(struct maps *maps, struct map *map) __maps__insert(maps, map); ++maps->nr_maps; + if (map->dso && map->dso->kernel) { + struct kmap *kmap = map__kmap(map); + + if (kmap) + kmap->kmaps = maps; + else + pr_err("Internal error: kernel dso with non kernel map\n"); + } + + /* * If we already performed some search by name, then we need to add the just * inserted map and resort. -- 2.24.1