Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2322934pxk; Mon, 14 Sep 2020 10:11:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4GWICJm1GjWZ1ODQIPpAh2JZqXV+HJMp+OsFNlAHFXvswe6Ne2ifV97XujAmFxwDsf/K7 X-Received: by 2002:a17:906:c0c4:: with SMTP id bn4mr7805587ejb.27.1600103473112; Mon, 14 Sep 2020 10:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600103473; cv=none; d=google.com; s=arc-20160816; b=jJ83q3u87JcabX1UjeQt18wJ1XEo46qMhrcXN0u2IB4rcmVuMl1AFF74xpJbkcpFxy U8Yr7voD+KmyBBQKsvPPgigg6SQ02FvitGTF3Oppx345+me1cAqC8w1XKsBBoJ7bn0Hr 66CIDZs7DWD95DjpAGG9VUB1CJmV/mtjr/yMpuLsdi9KNih/vg9R+P5buZurURtR/7Cs IHF3CGOJqit8cmu2IeKxk9UwTz53GWyWCiA7jWmJ8kTCJhMrEmDs/aId7KzVGhFprtzF uyV2UP4hRSTzsBxQ8iT6OwqPDMpXTwt7Cvsj6BoQCnU/eN7dNn3NyFR9IDeJVgUXSquA 3hsQ== 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=+EOCx9ftlXj9r5hUVYs4UrtJe1lnrNygcuxr0i6YY/o=; b=dv8P2VFi18+xHqC/EWQp8q3s51IgOeY/Axr2BaxVLYYH1w1PrLo0FhE+wL1dT57U6v qoAE3nP35cqTlaWtnf4fmiiWJathy0Jwzkk+n/dDlYnF7YHi9K4Kz7+CwrIQ+UgLGhqV UJX+9zD0IYJvDnmlzDWJXlooxx28JGDzPZ2ISp/Ep47+CRQEqFKNcXglxfMrlA6WcoEQ pptdtO0ajWTcJKY7FzCqynkh4qMFskiiDuKcPMIx77+RlkgJZy5Ju7ebaz+WkGuQbtsd gTmCiUmI9xqjaN5sgoLcFyUdKx/WZqgn+WpmahEJVJqrB2LmgI3dQDGHfs+keL+eWT7l xUPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="W/PkP+J+"; 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 y14si7565055edo.347.2020.09.14.10.10.49; Mon, 14 Sep 2020 10:11:13 -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="W/PkP+J+"; 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 S1726171AbgINRKQ (ORCPT + 99 others); Mon, 14 Sep 2020 13:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbgINRI0 (ORCPT ); Mon, 14 Sep 2020 13:08:26 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64AF7C06174A for ; Mon, 14 Sep 2020 10:08:23 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id z9so812127wmk.1 for ; Mon, 14 Sep 2020 10:08:23 -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=+EOCx9ftlXj9r5hUVYs4UrtJe1lnrNygcuxr0i6YY/o=; b=W/PkP+J+A5uVeI0t9NwdGy9u6SXPvioNMmJApM0IhvCdhGeeVQ/0sSLzpbtV6fHxOO TQA7URqIQXMcFyhPnkZL00bGwjQYlVfd8ZGP7Tr9U0URP6LIWwhW5cI3DpcdnZziCe3A rkMi/fX2tRSMb8AXgS6ZJqc/Z7MkbC669iHpSYUfE/yNyKjXLon5Y84ptPDd3LxckRTM /89hO7enXbpddOyQjfLUgGQOtu5ucvyfMwXRa5f7+BSLzE5I/s5e+SmOwb/9FPwXEWic SMSmbELfgqNO3BovNsBFDowXf74LKxlzY7G6f6FTP1uTuMEFOSE2TgL0P+gRZ6rLfQBM 1Skw== 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=+EOCx9ftlXj9r5hUVYs4UrtJe1lnrNygcuxr0i6YY/o=; b=P9k62QWx9qG7MD3nRt02Og6wPaIRFPlMYHAmiVPU+bubvQvQ7H5azombvc2vD3REUZ chSmZ/dfB1Pe40NW+DrFEeuVG7CCP5znuT3KRnDE4EUpEmF2P/D4kp+6xkS2XivcYJhJ wIj/5X8G4ieTRoirXybUhfb31Rmu7oBGAIgMQneKCeDlxK3aBa9gsPSkSa6rUpGkZ9yp EJYdE42pg3rKoAHGmh35ixfVV6g/Xw9gfrrnbq/qwgh4DLHJ8/p68gEKPX4XAl/YC/0u eYZFBhd7xvcfEoqrugBu+tURJVo/c1H6QTQL5j+l/D4sH2lQrvL+ovmfNIhXE3qgDKan 8tKw== X-Gm-Message-State: AOAM530y5KbcTRGB2ByvaVsTgeWFk4nbUS2dkS1B2F1x/SDq/GG3b1+0 lh/2uDw82zrs0hs194L3/yqqhFlsjfYbBLJvxqUu1Q== X-Received: by 2002:a1c:f402:: with SMTP id z2mr335531wma.87.1600103301802; Mon, 14 Sep 2020 10:08:21 -0700 (PDT) MIME-Version: 1.0 References: <20200913210313.1985612-1-jolsa@kernel.org> <20200913210313.1985612-3-jolsa@kernel.org> <20200914152841.GC160517@kernel.org> <20200914163534.GT1362448@hirez.programming.kicks-ass.net> In-Reply-To: <20200914163534.GT1362448@hirez.programming.kicks-ass.net> From: Ian Rogers Date: Mon, 14 Sep 2020 10:08:01 -0700 Message-ID: Subject: Re: [PATCH 02/26] perf: Introduce mmap3 version of mmap event To: Peter Zijlstra Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , lkml , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Song Liu , "Frank Ch. Eigler" , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter , Alexei Starovoitov , Daniel Borkmann , Yonghong Song 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 Mon, Sep 14, 2020 at 9:35 AM wrote: > > On Mon, Sep 14, 2020 at 12:28:41PM -0300, Arnaldo Carvalho de Melo wrote: > > > > > struct { > > > > struct perf_event_header header; > > > > > > u32 pid, tid; > > > > u64 addr; > > > > u64 len; > > > > u64 pgoff; > > > > u32 maj; > > > > u32 min; > > > > u64 ino; > > > > u64 ino_generation; > > > > u32 prot, flags; > > > > u32 reserved; > > > > What for this reserved? its all nicely aligned already, u64 followed by > > two u32 (prot, flags). > > I suspect it is so that sizeof(reserve+buildid) is a multiple of 8. But > yes, that's a wee bit daft, since the next field is a variable length > character array. > > > > > u8 buildid[20]; > > > > > Do we need maj, min, ino, ino_generation for mmap3 event? > > > I think they are to compare binaries, then we can do it with > > > build-id (and I think it'd be better).. > > > > Humm, I thought MMAP2 would be a superset of MMAP and MMAP3 would be a > > superset of MMAP2. > > Well, the 'funny' thing is that if you do use buildid, then > {maj,min,ino,ino_generation} are indeed superfluous, but are combined > also large enough to contain buildid. > > > If we want to ditch useless stuff, then trow away pid, tid too, as we > > can select those via sample_type. > > Correct. > > So something like: > > struct { > struct perf_event_header header; > > u64 addr; > u64 len; > u64 pgoff; > union { > struct { > u32 maj; > u32 min; > u64 ino; > u64 ino_generation; > }; > u8 buildid[20]; > }; > u32 prot, flags; > char filename[]; > struct sample_id sample_id; > }; > > Using one of the MISC bits to resolve the union. Might actually bring > benefit to everyone. Us normal people get to have a smaller MMAP record, > while the buildid folks can have it too. > > Even more extreme would be using 2 MISC bits and allowing the union to > be 0 sized for anon. > > That said; I have the nagging feeling there were unresolved issues with > mmap2, but I can't seem to find any relevant emails on it :/ My > google-fu is weak today. Firstly, thanks Jiri for this really useful patch set for our use-cases! Some thoughts: One issue with mmap2 events at the moment is that they happen "after" the mmap is performed. This allows the mapped address to be known but has the unfortunate problem of causing mmap events to get "extended" due to adjacent vmas being merged. There are some workarounds like commit c8f6ae1fb28d (perf inject jit: Remove //anon mmap events). Perhaps these events can switch to reporting the length the mmap requested rather than the length of the vma? I could imagine that changes here could be interesting to folks doing CHERI or hypervisors, for example, they may want more address bits. BPF has stack traces with elements of buildid + offset. Using these in perf samples would avoid the need for mmap events, synthesis, etc. but at the cost of larger and possibly slower stack traces. Perhaps we should just remove the idea of mmap events altogether? Thanks, Ian