Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2325994ybj; Mon, 23 Sep 2019 01:42:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH9PcL3lPKXLug2ywRWAKFMx7HBqVHBKP3ltyS07xUH9n82wvaLWrM/xev4Dq3xuwE06sj X-Received: by 2002:a50:8b61:: with SMTP id l88mr12930785edl.244.1569228155629; Mon, 23 Sep 2019 01:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569228155; cv=none; d=google.com; s=arc-20160816; b=kuN7wkllR1TM/R55vq8jYG0tz8DemtMukip0Ne45oFh7sxB7ED+OkSlkFF+vEKAzYr VZM1JSwFXNpz1Kr/dh1cn2A5wc+L8BtJ39pFp7dHYw71fiF6kMMqPY+RjrRFHCdiXHO8 3xpWU0DyVkQ6D8l5mU51acH6k6JogQ4TyJYVWChjcIAeJtzIL3WvSl2t6yVw5XSFvHn2 VmHLPDnRP0OyLwq5XsB5ZuAhCUJeukmkxI4ZIMyCBcSUiJIVS+rE4rsEmBgm2vcuK1Xy 4V9qFhVS8idqg8ROzRXObQfh8Ka95oo70YHJ5U1IywVYuQkklK6Xeq5L8/fDhw7T65/3 bVRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=HPiPEiJFgD/jwy0RVx5HWzug8lnmj5MBi1VsVPdTBVQ=; b=NiXjwlKTvDyJ77CwtJNi1ZQkst0m5kw3Deje+0P8phAM6xmz5qtLPsKm0Vh6U0Z3JY 3HD1HN+k6rIGXWRPPnQipCacYM/gKdUVx8is6QCL1lT3Il1OZZ03420Uq6tvPeqYyyeO 4ElMLAUupx1c3FtiONpraiS4AKSdZcaIZUvj+8opb6aaLrzVkKgp83d35WJosDV40hGW ftKtMEBuCrNQFcWoXPf1nQtsYiS21rcDO0wHugaFRO4Sp2t9KsXuPobg+ozMQJaz3Rcq Q1N9SBSgvw0Rk2qOoChjzt0jxg+T6itJ++ZF+2CnRl/CbihPSUD/z5QYlCZ5HsBeaCl0 JTMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HC9NApN1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si5949186eda.129.2019.09.23.01.42.12; Mon, 23 Sep 2019 01:42:35 -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=@gmail.com header.s=20161025 header.b=HC9NApN1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406132AbfITTi5 (ORCPT + 99 others); Fri, 20 Sep 2019 15:38:57 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:44931 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbfITTi4 (ORCPT ); Fri, 20 Sep 2019 15:38:56 -0400 Received: by mail-qk1-f193.google.com with SMTP id u22so4968694qkk.11 for ; Fri, 20 Sep 2019 12:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HPiPEiJFgD/jwy0RVx5HWzug8lnmj5MBi1VsVPdTBVQ=; b=HC9NApN1TrPGFCVB87OggyWNs1AVcY6h764RCGQjlS+Vr3ySwHbmDDSctFOQ9GbhHX Bx3GAfac3ec5ZF9H1QoJEZLrtvn/V22hfGhSOiDz3ASpAleqh5D7tIshBUEWvolqOen6 qH1TJYtmaZEGQMpuak29tt8haQ00eOWEsX0c+ulO/dNvi4atHxDVyRu/pW62VOF8qNzf OF7U275FwFdFsRN4DwW8GudtwNuyWn4D2XuICsHIgInEuxNktwknk1L0aWGuq5TE+vP4 nSYI55z/1CH474O+TDnv3R2M6HJqRFg7yvfNBcABENALc4qTEXeIpQNDoh9eTDPKunnO LyQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HPiPEiJFgD/jwy0RVx5HWzug8lnmj5MBi1VsVPdTBVQ=; b=jw7Cmmx6GD2fdJlbENZhuDrOxums9lymIY6pawRD9Xu5CFRUvLiBcDGeCiykQG0G83 td57cVLRWwxireOyYPj3b93pzB4vNLK9D0sVKHTn5wG9u+Qyb6c37HK51T9FEir9qBNS zZp2vJB2BdkuVT8wlU6nRsD4gtwBLIoqrkrhpkdziFV9ePSfCc8I6Y5ySwfTBPgftW7w VDr7WRuP03T4OaCUuEQNuxVQzFbZE1NXuUTYF9aSlGp5YyaVxrsKojfckM0TspGst0pO rSpLY2kJkOkrtKaHK/EsfDzseiyrzM22IR104EM+BY/sU9zkOGGPfV1Nokomh058KvOT 4LLQ== X-Gm-Message-State: APjAAAUDl596jmYtm2udZ8VXecCN++XgEKbmpG9S+Vl66hKHla0yLsVH XaAzv6Tk60CHOEL/xMBHq+g= X-Received: by 2002:ae9:e20f:: with SMTP id c15mr5486890qkc.122.1569008335673; Fri, 20 Sep 2019 12:38:55 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.95.178.75]) by smtp.gmail.com with ESMTPSA id a14sm1541500qkg.59.2019.09.20.12.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2019 12:38:54 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 6F5BB40340; Fri, 20 Sep 2019 16:38:52 -0300 (-03) Date: Fri, 20 Sep 2019 16:38:52 -0300 To: Steve MacLean Cc: Peter Zijlstra , Ingo Molnar , 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" , Brian Robbins , Tom McDonald , John Salem Subject: Re: [PATCH] perf map: fix overlapped map handling Message-ID: <20190920193852.GI4865@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Sep 20, 2019 at 07:20:18PM +0000, Steve MacLean escreveu: > 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. > > 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 > } > > after->start = map->end; > + after->pgoff = pos->map_ip(pos, map->end); So is this equivalent to what __split_vma() does in the kernel, i.e.: if (new_below) new->vm_end = addr; else { new->vm_start = addr; new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT); } where new->vm_pgoff starts equal to the vm_pgoff of the mmap being split? - Arnaldo > + 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.7.4 -- - Arnaldo