Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1792014ybj; Sun, 22 Sep 2019 12:02:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt6wWf56d1HpeDkyfAv6Jk/rwN+xTG0u0Ah2BySfrdbNount6YlHQNRL4FjZDaaDEdvdSu X-Received: by 2002:a17:906:3281:: with SMTP id 1mr9133369ejw.181.1569178966675; Sun, 22 Sep 2019 12:02:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1569178966; cv=pass; d=google.com; s=arc-20160816; b=RNnE5c/ZxuJNMH4wf5Xh7msPwefVTsEw5pBFLZg1OITBW06q5WN1WZz9+HYjrAKa77 hF66wLYatdTgKjHmRS7a64aoAb3N6dRAhFXa3FYM3wBBea0c69prr95Mh6q3ZdQ7eDOd zPcL5oWwXSCzPD1LpAQF2YL79T9b5XsZsYM6YopTeomMtGeryYo6MoiIoRKHbWzqHylX /TiJTfRibD6CRmjJUL6NIDoAOfxb9yecrnON40kXp4y1CKtUJ8Q/5huXb/erJCA6zg6j ijA1wiqREQpF15i9tlJ6dH+zCZC8UeobLGxs6zI/bgVY8AO3vtNWRA+jW7QtLkUtid1y i07Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :msip_labels:content-language:accept-language:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=AL0Qfy7YaUhhdLtqJrDq+kFso747FyI74iE57dXvZDg=; b=FCINNpy8f0bxewUwqGC0QNPjUEkYgH01r7jOoT+D/jVk35ir3medYCMlSdIUrgUNuW 17eIA72yYySXu+4AQdMeKBiRPkboZep9PIx68SwzPAK4EHrEvdfCNOCY7ogXmriSkdsy 8jzRVcMiWglr9GDbMy9Q+KQTdTkZ6bDf6B6mRPqTsEaxFCHDMlplT5yliUUP/C0fDl7q ruja4qgzWSl5tAV28kZN4ffnoWBTXFsqAy4G6D7sEuxd1VCxLFMW3xwsXZl80wQxrX+o QIY+RDDRcWXq8Swt0Fj6kvMabVgxYWAHX6AoTqA5VThCddYdlmJMiujs7zKSBMh6V7pU ePQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=Cm+40xSZ; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g32si5585238eda.330.2019.09.22.12.02.23; Sun, 22 Sep 2019 12:02:46 -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=@microsoft.com header.s=selector2 header.b=Cm+40xSZ; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729487AbfITTUW (ORCPT + 99 others); Fri, 20 Sep 2019 15:20:22 -0400 Received: from mail-eopbgr750115.outbound.protection.outlook.com ([40.107.75.115]:43800 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725869AbfITTUV (ORCPT ); Fri, 20 Sep 2019 15:20:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PntwezEus3IQhcol8M5Edb79tTG73VjaKSArPHBIlwV5Pz3iXcV+9KypR93QzV+OtStLVXy5hit6YJPxqEnzuLMfkNt/GbFXM/gKmV5bOgAAa/nE1gOa7ebPzbyiVCx8QJrBHdrtYrr3aeYB9qXDi+2qZJvobeM0TZIOcfgYEEu9FsQ+lfh3tWyZCVfbVSsUxbs8q21PpYc0QrqmbPvja3vlcaOn02U6YWEb3pfppZedGHct9yPotWRpPMjJM5ZHuhrqo88bpAY7nf5qR7s5iJc4SNxegVR5BoDq21qhYqZDhGoulvweSHrJ6mCFm0dzEJ1a/9n2AVR7RULYh1FJNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AL0Qfy7YaUhhdLtqJrDq+kFso747FyI74iE57dXvZDg=; b=UGhwrR0x7zkrQvMbrBAkMKnHgvCQkpBZsSBCcdErYse7+5gQcrTdBOxnrUDirK8uUl9aeJ4UiWVQVEeZeBMObeDSuiZN5TYgzm/g1mCFNzN3b7am0iTJTrASpBtgXHCVDdK6PoWocEicqIuJMBh9hSfJE9LuCecLP6KK1HcTh2WV2ad69KLLWEiY+fY1aQ1vrpzbh+NK6eCRwRF2tt82rC3CBas6Z28VfLHdPtyT1whvVYSchF1tICSAPXDYizutrYC/JXuidDYxMO8tIAprI5NEitB11J3E/I7AYk85913py3w1Je7T/BDpwcU8SoMaM52nygMBpPemb6Sur9rMlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AL0Qfy7YaUhhdLtqJrDq+kFso747FyI74iE57dXvZDg=; b=Cm+40xSZ0F+aIhs6WdqWV7AwbJSLOCsPKP2QLYsmQhH4oyi77gorUpiFDZi0ZGGFNyIeM5eFNxOqxtB09bgRGEZb33v8Q2pcFKsiGnqr4QTeXE+veYG7V4IkYfofPMZAWf1dzoWvgYUpKcudHt/brgbMfgWqMrHZJ8m/x5sW+cI= Received: from BN8PR21MB1362.namprd21.prod.outlook.com (20.179.76.155) by BN8PR21MB1250.namprd21.prod.outlook.com (20.179.74.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.11; Fri, 20 Sep 2019 19:20:19 +0000 Received: from BN8PR21MB1362.namprd21.prod.outlook.com ([fe80::4506:fd59:ba74:46d]) by BN8PR21MB1362.namprd21.prod.outlook.com ([fe80::4506:fd59:ba74:46d%7]) with mapi id 15.20.2284.009; Fri, 20 Sep 2019 19:20:19 +0000 From: Steve MacLean To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Changbin Du , Eric Saint-Etienne , John Keeping , Andi Kleen , Song Liu , Davidlohr Bueso , Leo Yan , "linux-kernel@vger.kernel.org" CC: Brian Robbins , Tom McDonald , John Salem Subject: [PATCH] perf map: fix overlapped map handling Thread-Topic: [PATCH] perf map: fix overlapped map handling Thread-Index: AdVv5y6SzPv23L21QnSQJe3E6wWQgA== Date: Fri, 20 Sep 2019 19:20:18 +0000 Message-ID: Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=stmaclea@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-09-20T19:20:17.8175398Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=4481e280-18db-41f0-b60b-edd25023ba1e; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic authentication-results: spf=none (sender IP is ) smtp.mailfrom=Steve.MacLean@microsoft.com; x-originating-ip: [24.163.126.65] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 48baf6d2-034b-4cd7-144f-08d73dff9321 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:BN8PR21MB1250; x-ms-traffictypediagnostic: BN8PR21MB1250:|BN8PR21MB1250: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0166B75B74 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(4636009)(396003)(39860400002)(136003)(346002)(376002)(366004)(199004)(189003)(6506007)(186003)(7696005)(52536014)(5660300002)(74316002)(25786009)(8990500004)(66446008)(10090500001)(305945005)(3846002)(7736002)(486006)(8676002)(4326008)(64756008)(66946007)(66556008)(102836004)(476003)(76116006)(14454004)(6436002)(86362001)(256004)(6116002)(33656002)(8936002)(66066001)(55016002)(81156014)(107886003)(99286004)(26005)(66476007)(66574012)(71200400001)(81166006)(478600001)(71190400001)(110136005)(22452003)(2906002)(2501003)(10290500003)(7416002)(54906003)(9686003)(316002)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:BN8PR21MB1250;H:BN8PR21MB1362.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 6JbZPMSQL/DdTJiYAjF32XKhCUaFr12oxmUT/DbJhN7hvaYBevN2LrQGI6w6KCafavNbg360Ybtf6prluUAktjWGJ5KCEjtnEXfqm1+8sRYhNxVacp8t78jU56C1kk9ixCq2uWlL+2Xr/2Znwv6x4pG7c1SIRio+Y1Mbg1zyGshmPH6FfrAL3xzKCFB0y4v+d8pYL3yEen3y771o2YKP4l4R8H9CWjVkANuU3LahXYkdlN1cZ3oc9HliKVjZEi6cDeQqo5tAIrp9wsBERqQZrOX0TiH/DOPfHwus7SLcjkVUOVSj3Ju3+h4ydsFezzrsvumzHLCI7X8YP4RKNfjffr5LYtCQvN7hKi6CJADcPTxaJurIL/Jtg/f/7ZDlViGX8y9KN6fm10NW9ow+kTZ4ug2bmDXDXxjyhaM6dPFz2rs= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48baf6d2-034b-4cd7-144f-08d73dff9321 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2019 19:20:18.8359 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GzGcI/W0Nj8VYdCTrGfuP1PDMo6eSdjGyzYvBW4/qQFJVMJKM7aIC6ttEISiQXWrxEtqLsj6eNMyGV4jtc0oQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR21MB1250 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.pgof= f. 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. Signed-off-by: Steve MacLean --- 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 5b83ed1..73870d7 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 } =20 after->start =3D map->end; + after->pgoff =3D pos->map_ip(pos, map->end); + assert(pos->map_ip(pos, map->end) =3D=3D after->map_ip(after, map->end)= ); __map_groups__insert(pos->groups, after); if (verbose >=3D 2 && !use_browser) map__fprintf(after, fp); --=20 2.7.4