Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp282305ybm; Thu, 28 May 2020 02:37:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpXHW8ibR/9cK/JHF04B3CvbcrqUgftJbPguVhJ1CBPXIEtck5DAlXH/bWlJjKd6qDjmzv X-Received: by 2002:a17:907:420e:: with SMTP id oh22mr2082284ejb.320.1590658642106; Thu, 28 May 2020 02:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590658642; cv=none; d=google.com; s=arc-20160816; b=W41kFPxggszhzdwmre9TLkomIr6jCpMVvqfAEU1JWV0yLw3+UdT+2XOdGP9d+T58IB L3T4m58uPpMrcInYJmtfhtaIJ6cbpd3emvvlKR3/Vm/GgEI46POp43FjXvcMR/b3k5p3 SXIQ4shoX8HiYGO7pFg6gT+sBV6rq3CSXj2/C8bq4mCO3L0/FIGR4SOS/b0ArNxycrzN khPHVUmWKYbvFWJE2yeKaMm2olwwrtUzIBL8HMpxrTot7dWm646cxrz9mxsXUxjrBES6 vAZfS7tMp8+kW+fBh82xkGlWsBenCrZVc9F39P3kboYttWxKL7FA9MpHG4EJnCJuyHVP Np6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RIEKd2/mNC5ZCQKsZfjS5e0RETs6SJqkGikMbM7WjKs=; b=E/Ddy4NBcGrT/dLmPzaIo2rdIY4iNBs6gRySe+bsw/78A1RMAFsxPX/QPZGN5uGSkN /lpnJuI4tIedEzCjDX3XouXts/CCkg8fau6pQhZLNXSl7X6CiyNlM6OP2N6O/L43/Ecs 6RiJFCDQKy+vZ0MADgZOUg1aLIEJ86bkt8veWaslFjAad2taFP/PL9lnkIR7jmZ8JsNm JADA55Bxtgq3cgae6Deie2/SSUryHoUapruTVgzAanbIPXZWf89XcDJt4KGIAN5UnSvg VN626CyscnSYEq0tIZ3P+4w2tiLBPconCZtqrC6DuLT8OsH7m8dRZ9jdxY62S14h251V E4RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ycvw3d71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si3110877edv.93.2020.05.28.02.36.59; Thu, 28 May 2020 02:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ycvw3d71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387395AbgE1JdJ (ORCPT + 99 others); Thu, 28 May 2020 05:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727981AbgE1JdI (ORCPT ); Thu, 28 May 2020 05:33:08 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FF83C05BD1E for ; Thu, 28 May 2020 02:33:08 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id s7so7082981ybo.9 for ; Thu, 28 May 2020 02:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RIEKd2/mNC5ZCQKsZfjS5e0RETs6SJqkGikMbM7WjKs=; b=Ycvw3d711px4YUgUi3RnPf4HNuJOmURAfUbCEeW1zaFjuwJ3bloc11fClVuOdjVBnc 7oGJnL7+kWEuh6Scm8jrRudKosKQtHz3wPjV2afqhnnnf/W4vEd2yaP9yd3zey2Rh9yb Ryh/6CMe1h0PqlXxynmkXnMIBKow7zGJXxaqtS//UdH8ueZB+C1wTT7OQRCanA0KrPqA GPW1/KNJ6dKJmtHdqix8iWscF5bwr4Lz06Hjx9eu+ScH0UI4htiFAMrxyNG0KfntKXQM lY7crDkx/+MXGZjUar9NKxrclPUZBJvFa+xBoRMc/mzvd8PAockPi71MIXDwyMThQenK vj4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RIEKd2/mNC5ZCQKsZfjS5e0RETs6SJqkGikMbM7WjKs=; b=Pg3d6mAQ5C4E9aaoTfQW6o1BJwrqRWXVwbB6O6puZGdoacnB6ayK5+LojrGjGSLFAj wqoB6w+x8AAPo641VUGr3mcZT7RdCtrqcV3jjph88o7ZYIywMMbz+UEH9mKLNTK2HM8L TNjHW27zF3TCjsWjLi1fE6x07bTpiiy/cCJQMTovAx23ea73d6u9/zaOvESJBiOE7vUX BBWUCPfUTSYMDg7mE8Us1dVCgD+RVS9wh5Wsaf6Gd3dBYEhTygQTRxsYZ2GH0bYawe6P nNJ4/s+dlH9P2CWbxiZlo9sB4VkmUGU1MlrhVCPJqOqYw1rCHwZMg0mj/QF2BOa1//dp f3lw== X-Gm-Message-State: AOAM532IZ9SeJ1deDIYqCYhZmkcVLP2oaqgBGppe5fKsuEx0Q3k2NWHr DISARD6i95I109ZMu5rS/cRkRNmdjx6ovmBi+R8jcg== X-Received: by 2002:a25:c08b:: with SMTP id c133mr3742107ybf.286.1590658387444; Thu, 28 May 2020 02:33:07 -0700 (PDT) MIME-Version: 1.0 References: <1590544271-125795-1-git-send-email-steve.maclean@linux.microsoft.com> In-Reply-To: From: Ian Rogers Date: Thu, 28 May 2020 02:32:55 -0700 Message-ID: Subject: Re: [EXTERNAL] Re: [PATCH v4] perf inject --jit: Remove //anon mmap events To: Steve MacLean Cc: Steve MacLean , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Stephane Eranian , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 27, 2020 at 1:59 PM Ian Rogers wrote: > > On Wed, May 27, 2020 at 12:27 PM Steve MacLean > wrote: > > > > >> ** Implemented solution > > >> > > >> This patch solves the issue by removing // anon mmap events for any > > >> process which has a valid jit-.dump file. > > >> > > >> It tracks on a per process basis to handle the case where some running > > >> apps support jit-.dump, but some only support perf-.map. > > >> > > >> It adds new assumptions: > > >> * // anon mmap events are only required for perf-.map support. > > >> * An app that uses jit-.dump, no longer needs perf-.map > > >> support. It assumes that any perf-.map info is inferior. > > >> > > >> *** Details > > >> > > >> Use thread->priv to store whether a jitdump file has been processed > > >> > > >> During "perf inject --jit", discard "//anon*" mmap events for any pid > > >> which has sucessfully processed a jitdump file. > > > > > > > > > Thanks Steve this is an important fix! As //anon could be for malloc or other uses, should the stripping behavior be behind a flag? > > > > > > Ian > > > > I hadn't anticipated a need to preserve the //anon mmap events when profiling JIT generated code. > > > > As far as I know mmap events are captured by perf only for mapping code to symbols. File mappings are kept > > by the change. Only // anon mappings are stripped. (Only for processes which emitted jitdump files.) > > And these are stripped only during the `perf inject --jit` step. I believe the // Anon mapping are only > > generally useful for mapping JIT code. > > > > I suppose if someone was trying to count mmap events it might be confusing, but `perf inject --jit` creates > > synthetic mmap file events which would also make this scenario confusing. > > > > I personally don't see a good reason to add a flag. I also don't see a simple way either. Not running `perf inject --jit` > > would preserve existing behavior w/o jitdump support. Without stripping the anon events jitdump support is painfully > > broken.... > > Agreed that things are broken. In general only executable mappings are > held onto by perf, so it could be I'm over worrying about //anon > stripping breaking around memory allocations. We have some other use > cases for //anon at Google but they aren't impacted by jitdump. We > have also been trying to migrate jit caches to using memfd_create, > which has the same problem that this patch fixes for //anon. Fixing > memfd_create is a separate issue to //anon. I'll try to get a repro > for Java that demonstrates the problem and then add a Tested-by. > > Thanks, > Ian So on tip/perf/core with: 1c0cd2dbb993 perf jvmti: Fix jitdump for methods without debug info 3ce17c1e52f4 perf jvmti: remove redundant jitdump line table entries I've been trying variants of: Before: /tmp/perf/perf record -k 1 -e cycles:u -o /tmp/perf.data java -agentpath:/tmp/perf/libperf-jvmti.so -XX:+PreserveFramePointer -XX:InitialCodeCacheSize=20M -XX:ReservedCodeCacheSize=1G -jar dacapo-9.12-bach.jar jython /tmp/perf/perf inject -i /tmp/perf.data -o /tmp/perf-jit.data -j /tmp/perf/perf report -i /tmp/perf-jit.data |grep class\ |wc -l 578 /tmp/perf/perf report -i /tmp/perf-jit.data |grep unknown |wc -l 6 After: /tmp/perf/perf record -k 1 -e cycles:u -o /tmp/perf.data java -agentpath:/tmp/perf/libperf-jvmti.so -XX:+PreserveFramePointer -XX:InitialCodeCacheSize=20M -XX:ReservedCodeCacheSize=1G -jar dacapo-9.12-bach.jar jython /tmp/perf/perf inject -i /tmp/perf.data -o /tmp/perf-jit.data -j /tmp/perf/perf report -i /tmp/perf-jit.data |grep class\ |wc -l 589 /tmp/perf/perf report -i /tmp/perf-jit.data |grep unknown |wc -l 60 So maybe the jit cache isn't behaving the way that the patch cures, the uptick in unknowns appears consistent in my testing though. I expect user error, is there an obvious explanation I'm missing? Thanks, Ian