From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DCD7C433E2 for ; Tue, 15 Sep 2020 05:40:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 258C42078D for ; Tue, 15 Sep 2020 05:40:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726123AbgIOFkU (ORCPT ); Tue, 15 Sep 2020 01:40:20 -0400 Received: from mga18.intel.com ([134.134.136.126]:17894 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgIOFkS (ORCPT ); Tue, 15 Sep 2020 01:40:18 -0400 IronPort-SDR: TvqxKMP7pJhOBjTmObgDLUjgT2qmFYaaulOkts4wXdaWFShnRaGfyfD9Cw432mvYWu9law1u6x iDLlD6W21ogQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="146944481" X-IronPort-AV: E=Sophos;i="5.76,428,1592895600"; d="scan'208";a="146944481" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 22:40:14 -0700 IronPort-SDR: EwYZcO5vjGv6521gyVrlX1KlfOwrqg5CEO76PQ2v90FEMoeZsCak0Y8VVCd9C/tmUVyy4It8eu jLXaqQRpoRDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,428,1592895600"; d="scan'208";a="287860234" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.190]) ([10.237.72.190]) by fmsmga008.fm.intel.com with ESMTP; 14 Sep 2020 22:40:09 -0700 Subject: Re: [PATCH 02/26] perf: Introduce mmap3 version of mmap event To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Namhyung Kim , Jiri Olsa , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Song Liu , "Frank Ch. Eigler" , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Alexei Starovoitov , Daniel Borkmann , Yonghong Song References: <20200913210313.1985612-1-jolsa@kernel.org> <20200913210313.1985612-3-jolsa@kernel.org> <20200914152841.GC160517@kernel.org> <20200914193907.GO1714160@krava> <20200914220014.GH166601@kernel.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Tue, 15 Sep 2020 08:39:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200914220014.GH166601@kernel.org> Content-Type: text/plain; charset=utf-8 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 15/09/20 1:00 am, Arnaldo Carvalho de Melo wrote: > Em Mon, Sep 14, 2020 at 09:39:07PM +0200, Jiri Olsa escreveu: >> On Mon, Sep 14, 2020 at 12:28:41PM -0300, Arnaldo Carvalho de Melo wrote: >>> Em Mon, Sep 14, 2020 at 02:38:27PM +0900, Namhyung Kim escreveu: >>>> On Mon, Sep 14, 2020 at 6:03 AM Jiri Olsa wrote: >>>>> Add new version of mmap event. The MMAP3 record is an >>>>> augmented version of MMAP2, it adds build id value to >>>>> identify the exact binary object behind memory map: > >>>>> 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). > >>>>> 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. > >>> If we want to ditch useless stuff, then trow away pid, tid too, as we >>> can select those via sample_type. > >>> Having said that, at this point I don't even know if adding new >>> PERF_RECORD_ that are an update for a preexisting one is the right way >>> to proceed. > >>> Perhaps we should attach a BPF program to point where a mmap/munmap is >>> being done (perf_event_mmap()) and allow userspace to ask for whatever >>> it wants? With a kprobes there right now we can implement this MMAP3 >>> easily, no? > >> hmm, I'm always woried about solutions based on kprobes, >> because once the function is moved/removed you're screwed >> and need to keep up with function name changes and be >> backward compatible.. > > Well, I'm not advocating to have it as kprobes permanently, but we can > implement it now using a kprobes, i.e. systems wouldn't have to have its > kernel updated to have this feature, but once then need, for some other > reason, to have their kernel upgraded, then perf would notice that there > is a tracepoint for that and would happily use it. > > So we would be able to use that tracepoint with things like ftrace, > bpftrace, everything that knows about tracepoints, and perf would get > build-ids and whatever else is needed to have a mmap record, in the > future we could even ask for some more (or less) according to the what > is needed for some new feature. > > I.e. the point wasn't about kprobes was about using BPF to state what > we want to collect when a mmap is being put in place. Isn't the problem with krpobes / tracepoints etc that non-privileged users can't use them.