Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp906163imd; Thu, 1 Nov 2018 07:24:06 -0700 (PDT) X-Google-Smtp-Source: AJdET5eYs+NDd7DaHkprHJmq5hK9BTmo9wobzUDZ1kWaiCmkfUVXeAbHne3D3JKCA07bZurGgZX8 X-Received: by 2002:a17:902:9a8b:: with SMTP id w11-v6mr7644590plp.94.1541082246430; Thu, 01 Nov 2018 07:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541082246; cv=none; d=google.com; s=arc-20160816; b=asrn9h2Pl2HgQ1g4kuQij8vHxK7w05yuJ19Udom2nIpmgImN8DIPIbRAG8gRpbXk4y tLCsAJgPhTimu43IVU6pJrkP9PFX51PGupBsWQffQQ7A/7FuPhjiN/26g5LgpD8siuk4 dTztaFHG2p+eM3x5w53/30HLF4TkGWcOm1JDMvSGFP2HQEC2Jy6I3rK2Qx02PJdaVPKy gQTqSnlD/7c1/ny2168T1nPeJtqwQ+lzG+dFDhfDIFuspEQFocZbU+7qspMUW+OOOCKo tbxg8CnSushn3FpaGDZfzICYdDR9PVqt1seFuBTGAqEKNe0QnC3XAnwDgMJeQ+dZG3DZ 8bGA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=EgQZp0Z+JbqTvSJJGeJicerASWDmBibXfnt/1UPxS20=; b=ZTRFjnSlsXzdFGOlCrRjlUFtqVTY/8iSw8IBbVNM7IaFH8q87S4xBS/eqUhYz81pT0 ntOs7pUbHzmirD932U3/Y1DKlskc7VVN/p8TAqMub9BMpNyfTpFkRAUVlkJ8kcjnYZe5 w2NxHNj0nIICFb/JI/dNiWyfnSUbKqFyG972zg0yU66miUDoR39Uw+E9dCOyUQPV4d9m sL2uQX1C/08+KzCuJc5ZTuRyrmh1dXTfJgG8ibuzZmFgs1FqJEtGRjg1UJreAU8KMbXe M1U7uioDyZg3xCdicU8xU9+rTZGyhr3fmC143FMwIlTHtt90QZ5ByT4Te5g1WgsyE0fO LghA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r75-v6si28091731pgr.429.2018.11.01.07.23.51; Thu, 01 Nov 2018 07:24:06 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728313AbeKAXMy (ORCPT + 99 others); Thu, 1 Nov 2018 19:12:54 -0400 Received: from mga02.intel.com ([134.134.136.20]:4260 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728238AbeKAXMx (ORCPT ); Thu, 1 Nov 2018 19:12:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2018 07:09:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,452,1534834800"; d="scan'208";a="92949471" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 01 Nov 2018 07:09:39 -0700 Received: from [10.251.5.195] (kliang2-mobl1.ccr.corp.intel.com [10.251.5.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 200565802E4; Thu, 1 Nov 2018 07:09:38 -0700 (PDT) Subject: Re: [PATCH 1/2] perf: Add munmap callback To: Stephane Eranian , Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Arnaldo Carvalho de Melo , LKML , Borislav Petkov , Andi Kleen References: <20181024151116.30935-1-kan.liang@linux.intel.com> From: "Liang, Kan" Message-ID: Date: Thu, 1 Nov 2018 10:09:35 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/24/2018 3:30 PM, Stephane Eranian wrote: > The need for this new record type extends beyond physical address conversions > and PEBS. A long while ago, someone reported issues with symbolization related > to perf lacking munmap tracking. It had to do with vma merging. I think the > sequence of mmaps was as follows in the problematic case: > 1. addr1 = mmap(8192); > 2. munmap(addr1 + 4096, 4096) > 3. addr2 = mmap(addr1+4096, 4096) > > If successful, that yields addr2 = addr1 + 4096 (could also get the > same without forcing the address). > > In that case, if I recall correctly, the vma for 1st mapping (now at > 4k) and that of the 2nd mapping (4k) > get merged into a single 8k vma and this is what perf_events will > record for PERF_RECORD_MMAP. > On the perf tool side, it is assumed that if two timestamped mappings > overlap then, the latter overrides > the former. In this case, perf would loose the mapping of the first > 4kb and assume all symbols comes from > 2nd mapping. Hopefully I got the scenario right. If so, then you'd > need PERF_RECORD_UNMAP to > disambiguate assuming the perf tool is modified accordingly. > Hi Stephane and Peter, I went through the link(https://lkml.org/lkml/2017/1/27/452). I'm trying to understand the problematic case. It looks like the issue can only be triggered by perf inject --jit. Because it can inject extra MMAP events. As my understanding, Linux kernel only try to merge VMAs if they are both from anon or they are both from the same file. --jit breaks the rule, and makes the merged VMA partly from anon, partly from file. Now, there is a new MMAP event which range covers the modified VMA. Without the help of MUNMAP event, perf tool have no idea if the new one is a newly merged VMA (modified VMA + a new VMA) or a brand new VMA. Current code just simply overwrite the modified VMAs. The VMA information which --jit injected may be lost. The symbolization may be lost as well. Except --jit, the VMAs information should be consistent between kernel and perf tools. We shouldn't observe the problem. MUNMAP event is not needed. Is my understanding correct? Do you have a test case for the problem? Thanks, Kan