Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1021763ybm; Wed, 27 May 2020 14:02:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDGlUtjvsIeDv1U44FprKSg/BoRBmSiazw3BlF+n6xm7FmCBaADQSnKRaiU+Blb+Wln5YI X-Received: by 2002:a17:906:b88c:: with SMTP id hb12mr143928ejb.483.1590613374598; Wed, 27 May 2020 14:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590613374; cv=none; d=google.com; s=arc-20160816; b=UnelbYGatl1RCi5jzVbyGXIMh1bfEppwLPUP4xcbUXHPKGpEII7TMg8p+7HJ5XqGnd g0gNBaYn+bQF9uAWdNpEougWJ4eROJo9XceWo49bDHhVZXrpStdgwKsTlxflQKO++fPN tkwN8QQZjbjfiWOphsryNMhMVrV00Khuqp8agcwfdYBIwfgWKXZbfDjxTmsYdPKcdkYV dwDgtKO9HIMchp+wosQTgyscZY9hJfYjbOVT1UTE05bCBhA+2oAOPoY3h6zd7CvwiPVJ rXSkU+4j505ba12hQEkFrvi+0Tv5Gsch1uPq8dS6Xz6HZchKBc18M0uoUMQ6WDlSvUNv MQlA== 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=VbTGqBEAJn7vOUI10dzvBC6GCHW95GnJA8YOb9SAJqI=; b=EobkiZOi7D1zwjEHtZmBclxKaY2C7Be+sQUFX6G79zRUD5OvSmzx87ukNqPdxXLpZJ 4p1kw3DMipEgMu/sAfAKxOyT206J1t1ZPtBV746pklCpEDqOnf+oTd0K/wfXtAWEz58b iNWJDDtkIzphH1VCNeVWrjC2d6jZyCnFr80qOPGTuuSKWuDYTR2IGF0lYRsq2I4CtSlM V5ogHFu2/4lrcrEBd/RAYZL/lLLNTdIPIRwhfjHyltNpW87NeDORYSUaXGKwGVDDITcY dZUPy0GDyLb66G2hQZvyzg+kyOmd0JdmRLG/YyEEJzd40QBqVthL2XTR6jzkfiFoq596 L2WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DuAEPU1c; 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 23si1948373ejy.621.2020.05.27.14.02.26; Wed, 27 May 2020 14:02:54 -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=DuAEPU1c; 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 S1727899AbgE0VAL (ORCPT + 99 others); Wed, 27 May 2020 17:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbgE0VAL (ORCPT ); Wed, 27 May 2020 17:00:11 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC070C05BD1E for ; Wed, 27 May 2020 14:00:09 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id p123so11692yba.6 for ; Wed, 27 May 2020 14:00:09 -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=VbTGqBEAJn7vOUI10dzvBC6GCHW95GnJA8YOb9SAJqI=; b=DuAEPU1cRI42BFnfXBzJAsWU1SICG9jB1tgTnRdUTLjbUdrAGZQIRRfIjyyb6rlaqd fQt3r6qWCtxqTEzLIA06d0rHSIeDAM59sIIy4xC7lqe48Fth1EFvVQZ1oZZCWZUc2wVo U1p06M58NHsCmXccWc7+OpTqVvMLfSx9E0zXXFIGw+rfyFyPxEaU4I4DZ9U1oYTWPQi6 FvzHAiezxHxgjWTBiTsaFW3+XgZpvkAiQSbkzBqK9/ofQjfus3EWvocbbU/dDRyLqRd4 mJDg+XWIUtWqbpIkaMNRgybB55pNMTydgGl3Pt30OLD42QultCXe86CGArrrE3ZUI38J JbVA== 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=VbTGqBEAJn7vOUI10dzvBC6GCHW95GnJA8YOb9SAJqI=; b=kn2Ln9ZHBq/kTiZI/EcIlF2EqF2iL6dExZjFJfhyXbxc3XEmFs2a5Z/9MZ9Nroxax2 KiCPuvnbBRDfoQc98uWKKHcOVyUK/uWdji6Vi2tfvmJwBBNZeqAtSvZWT/nVU25ar0P2 D287fPA8gD9d8BWG+sQpAgavtiBiOXcw+2frwNRkQ3qpYypzwhRw6jNxG25S2WdDWs4K JNzSBeJ+rS/2M9cTuAlKHa3CpIe0tVsaVsCRxxk3bV7PXjx1AXuY8/amjfz11Hk6CyRS IidhTHapzqLWBdrb5Kyw7c6rDXh24jAwjCUCc0mTf3vr2jkHGR3L0vEzZBz9tqIE3jly Ujhg== X-Gm-Message-State: AOAM530Kf+F2Y8OkGq1F+ak1uhW+aBna1vpsTPB1l1ypWlzsNpDSEusR I9tqPwRch3JXQaEHqW5DXGj31m6lLRu2f4m5cC5b6g== X-Received: by 2002:a25:5387:: with SMTP id h129mr145828ybb.47.1590613208522; Wed, 27 May 2020 14:00:08 -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: Wed, 27 May 2020 13:59:57 -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 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