Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8160337ybn; Tue, 1 Oct 2019 04:14:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzP5z7waqwTk/dEu8aT7w583Oophi7VFezGnGDC07aD7ebwHvj7THSC5T7/UNgglI+/ivw X-Received: by 2002:a17:906:f259:: with SMTP id gy25mr23872683ejb.2.1569928465634; Tue, 01 Oct 2019 04:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569928465; cv=none; d=google.com; s=arc-20160816; b=oGTqqombovEJxrMN6cpAievq8hBA+xoHV8+TmTGhzNo7H8CiSArN3ibZYekEUWPPlp ND5oiAkQUgejGbSmHbmpDEYDweqCTm1n61ba6oS7qRc8r2mgLJpDaumvRWugxHXoxiaS vItsfoMR6LBOIqw3IqKjmkQ+Og0qXes+p7FI9Rmv+gf4DVNnKQ0RgUJXMZ5MZbm5y6L/ PHkDeOH/J4gg9Y/Wv/1Ry/ea+F+RTrJxVMAfjlyf1lvXSxn/wWE6yOa3W6FW6krgNpv9 vTSqMdCbSoghkWWhfYQorTMVc9gGXvqlUY35j3IX+hAeg1ErpMAiMH3Q0ga4VPdWwmGD P6Jw== 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 :dkim-signature; bh=lhOhmuElhmrNL+S4idb1YEqA9EsHaJYLnxRaGNPa5CE=; b=sWYf3otltex6VjO/n98jMO3rcM1TW9H02px4jFbHTQTn29+3P0A2WN+HLKnK1HOgRd GkUixlOVFbdWtBL0ExBoVVKSeWrVprtPlrLFo2GwxbnM/4KrrILULi/zsnPKBDECxbmh fKjGSOFLdN57i4Iu2LU/Zi9dV6wYjfxEUBkJLygz8gfMLyVNOEzYm6PRP5+mo+pbvpLT PTt11rkaYCzzNYkHlgQJhoeJIlO16dvhXmw5h7YNACPEJgCzGfSIJ7jJHr1O6AAAByxW RMXBLYIf7UAxMIXAPJgx/BEVUze7Snii5OLr78bFkubkCs5UxxBcTqs9xp6ZW9DZyFPq S8TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wi9K6IiI; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a25si8530642eju.71.2019.10.01.04.14.01; Tue, 01 Oct 2019 04:14:25 -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=@kernel.org header.s=default header.b=wi9K6IiI; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731756AbfJALNU (ORCPT + 99 others); Tue, 1 Oct 2019 07:13:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731480AbfJALNU (ORCPT ); Tue, 1 Oct 2019 07:13:20 -0400 Received: from quaco.ghostprotocols.net (177.206.223.101.dynamic.adsl.gvt.net.br [177.206.223.101]) (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 3343421920; Tue, 1 Oct 2019 11:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569928398; bh=Llp2SQjqkC/mu2n3hj4e4dsjUlKCyvIJARC4iZguoTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wi9K6IiIedE5sJ7QzoDwy0boguV+BtqOAyLCDoAoOe2vpPRp7Xq4YrKbAuzfN2gCA gZxqZxSFsA3SiFe0pLfaZWgH+JaI8Tsx0OgO6wb1R+r8zY+FPmomkzZO/Jsiz7WC63 imZmMyhos6X88LZ0+X5kOPGso6DI+crcLxSdugGo= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Steve MacLean , Steve MacLean , Brian Robbins , Alexander Shishkin , Andi Kleen , Davidlohr Bueso , Eric Saint-Etienne , John Keeping , John Salem , Leo Yan , Mark Rutland , Peter Zijlstra , Song Liu , Stephane Eranian , Tom McDonald , Arnaldo Carvalho de Melo Subject: [PATCH 12/24] perf map: Fix overlapped map handling Date: Tue, 1 Oct 2019 08:12:04 -0300 Message-Id: <20191001111216.7208-13-acme@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191001111216.7208-1-acme@kernel.org> References: <20191001111216.7208-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve MacLean Whenever an mmap/mmap2 event occurs, the map tree must be updated to add a new entry. If a new map overlaps a previous map, the overlapped section of the previous map is effectively unmapped, but the non-overlapping sections are still valid. maps__fixup_overlappings() is responsible for creating any new map entries from the previously overlapped map. It optionally creates a before and an after map. When creating the after map the existing code failed to adjust the map.pgoff. This meant the new after map would incorrectly calculate the file offset for the ip. This results in incorrect symbol name resolution for any ip in the after region. Make maps__fixup_overlappings() correctly populate map.pgoff. Add an assert that new mapping matches old mapping at the beginning of the after map. Committer-testing: Validated correct parsing of libcoreclr.so symbols from .NET Core 3.0 preview9 (which didn't strip symbols). Preparation: ~/dotnet3.0-preview9/dotnet new webapi -o perfSymbol cd perfSymbol ~/dotnet3.0-preview9/dotnet publish perf record ~/dotnet3.0-preview9/dotnet \ bin/Debug/netcoreapp3.0/publish/perfSymbol.dll ^C Before: perf script --show-mmap-events 2>&1 | grep -e MMAP -e unknown |\ grep libcoreclr.so | head -n 4 dotnet 1907 373352.698780: PERF_RECORD_MMAP2 1907/1907: \ [0x7fe615726000(0x768000) @ 0 08:02 5510620 765057155]: \ r-xp .../3.0.0-preview9-19423-09/libcoreclr.so dotnet 1907 373352.701091: PERF_RECORD_MMAP2 1907/1907: \ [0x7fe615974000(0x1000) @ 0x24e000 08:02 5510620 765057155]: \ rwxp .../3.0.0-preview9-19423-09/libcoreclr.so dotnet 1907 373352.701241: PERF_RECORD_MMAP2 1907/1907: \ [0x7fe615c42000(0x1000) @ 0x51c000 08:02 5510620 765057155]: \ rwxp .../3.0.0-preview9-19423-09/libcoreclr.so dotnet 1907 373352.705249: 250000 cpu-clock: \ 7fe6159a1f99 [unknown] \ (.../3.0.0-preview9-19423-09/libcoreclr.so) After: perf script --show-mmap-events 2>&1 | grep -e MMAP -e unknown |\ grep libcoreclr.so | head -n 4 dotnet 1907 373352.698780: PERF_RECORD_MMAP2 1907/1907: \ [0x7fe615726000(0x768000) @ 0 08:02 5510620 765057155]: \ r-xp .../3.0.0-preview9-19423-09/libcoreclr.so dotnet 1907 373352.701091: PERF_RECORD_MMAP2 1907/1907: \ [0x7fe615974000(0x1000) @ 0x24e000 08:02 5510620 765057155]: \ rwxp .../3.0.0-preview9-19423-09/libcoreclr.so dotnet 1907 373352.701241: PERF_RECORD_MMAP2 1907/1907: \ [0x7fe615c42000(0x1000) @ 0x51c000 08:02 5510620 765057155]: \ rwxp .../3.0.0-preview9-19423-09/libcoreclr.so All the [unknown] symbols were resolved. Signed-off-by: Steve MacLean Tested-by: Brian Robbins Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Davidlohr Bueso Cc: Eric Saint-Etienne Cc: John Keeping Cc: John Salem Cc: Leo Yan Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stephane Eranian Cc: Tom McDonald Link: http://lore.kernel.org/lkml/BN8PR21MB136270949F22A6A02335C238F7800@BN8PR21MB1362.namprd21.prod.outlook.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/map.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 5b83ed1ebbd6..eec9b282c047 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "symbol.h" +#include #include #include #include @@ -850,6 +851,8 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp } after->start = map->end; + after->pgoff += map->end - pos->start; + assert(pos->map_ip(pos, map->end) == after->map_ip(after, map->end)); __map_groups__insert(pos->groups, after); if (verbose >= 2 && !use_browser) map__fprintf(after, fp); -- 2.21.0