From mboxrd@z Thu Jan 1 00:00:00 1970 From: Masami Hiramatsu Subject: Re: [PATCH v4 2/9] perf/core: open access for CAP_SYS_PERFMON privileged process Date: Sun, 12 Jan 2020 10:44:46 +0900 Message-ID: <20200112104446.f667df82b061dfb9c7a6bdce@kernel.org> References: <20200108160713.GI2844@hirez.programming.kicks-ass.net> <20200110140234.GO2844@hirez.programming.kicks-ass.net> <20200111005213.6dfd98fb36ace098004bde0e@kernel.org> <20200110164531.GA2598@kernel.org> <20200111084735.0ff01c758bfbfd0ae2e1f24e@kernel.org> <2B79131A-3F76-47F5-AAB4-08BCA820473F@fb.com> <5e191833.1c69fb81.8bc25.a88c@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5e191833.1c69fb81.8bc25.a88c@mx.google.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: arnaldo.melo@gmail.com Cc: Mark Rutland , Song Liu , Peter Zijlstra , Benjamin Herrenschmidt , Will Deacon , Alexei Starovoitov , Stephane Eranian , james.bottomley@hansenpartnership.com, Paul Mackerras , Jiri Olsa , Andi Kleen , Michael Ellerman , Igor Lubashev , James Morris , Alexander Shishkin , Ingo Molnar , "oprofile-list@lists.sf.net" , Serge Hallyn , Robert Richter , Kees Cook , Jann Horn , "selinux@vger.kernel.org" , intel-gfx@lists.freedesktop List-Id: linux-perf-users.vger.kernel.org On Fri, 10 Jan 2020 21:35:12 -0300 arnaldo.melo@gmail.com wrote: > ,Jann Horn ,Thomas Gleixner ,Tvrtko Ursulin ,Lionel Landwerlin ,linux-kernel ,"linux-security-module@vger.kernel.org" ,"selinux@vger.kernel.org" ,"intel-gfx@lists.freedesktop.org" ,"bpf@vger.kernel.org" ,"linux-parisc@vger.kernel.org" ,"linuxppc-dev@lists.ozlabs.org" ,"linux-perf-users@vger.kernel.org" ,"linux-arm-kernel@lists.infradead.org" ,"oprofile-list@lists.sf.net" > From: Arnaldo Carvalho de Melo > Message-ID: > > On January 10, 2020 9:23:27 PM GMT-03:00, Song Liu wrote: > > > > > >> On Jan 10, 2020, at 3:47 PM, Masami Hiramatsu > >wrote: > >> > >> On Fri, 10 Jan 2020 13:45:31 -0300 > >> Arnaldo Carvalho de Melo wrote: > >> > >>> Em Sat, Jan 11, 2020 at 12:52:13AM +0900, Masami Hiramatsu escreveu: > >>>> On Fri, 10 Jan 2020 15:02:34 +0100 Peter Zijlstra > > wrote: > >>>>> Again, this only allows attaching to previously created kprobes, > >it does > >>>>> not allow creating kprobes, right? > >>> > >>>>> That is; I don't think CAP_SYS_PERFMON should be allowed to create > >>>>> kprobes. > >>> > >>>>> As might be clear; I don't actually know what the user-ABI is for > >>>>> creating kprobes. > >>> > >>>> There are 2 ABIs nowadays, ftrace and ebpf. perf-probe uses ftrace > >interface to > >>>> define new kprobe events, and those events are treated as > >completely same as > >>>> tracepoint events. On the other hand, ebpf tries to define new > >probe event > >>>> via perf_event interface. Above one is that interface. IOW, it > >creates new kprobe. > >>> > >>> Masami, any plans to make 'perf probe' use the perf_event_open() > >>> interface for creating kprobes/uprobes? > >> > >> Would you mean perf probe to switch to perf_event_open()? > >> No, perf probe is for setting up the ftrace probe events. I think we > >can add an > >> option to use perf_event_open(). But current kprobe creation from > >perf_event_open() > >> is separated from ftrace by design. > > > >I guess we can extend event parser to understand kprobe directly. > >Instead of > > > > perf probe kernel_func > > perf stat/record -e probe:kernel_func ... > > > >We can just do > > > > perf stat/record -e kprobe:kernel_func ... > > > You took the words from my mouth, exactly, that is a perfect use case, an alternative to the 'perf probe' one of making a disabled event that then gets activated via record/stat/trace, in many cases it's better, removes the explicit probe setup case. Ah, I got it. If the perf event parser just kicks perf's kprobe creation interface, it will be easy. In that case, there should be following differences. - perf * -e "kprobe":kernel_func will put a local (hidden) kprobe events. So ftrace user can not access it. - perf * -e "kprobe":kernel_func may not support inline/function-body nor trace local variables etc. Hm, if we support inline function via -e "kprobe" interface, we have to expand perf_event_open() to support multi-probe event. Thanks, > > Regards, > > - Arnaldo > > > > >Thanks, > >Song > -- Masami Hiramatsu 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=-0.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 9D434C33CA7 for ; Sun, 12 Jan 2020 01:46:50 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EDE320848 for ; Sun, 12 Jan 2020 01:46:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="f0hoRGlu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EDE320848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47wKMW3bgdzDqcH for ; Sun, 12 Jan 2020 12:46:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=mhiramat@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=f0hoRGlu; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47wKKQ6HmWzDqW3 for ; Sun, 12 Jan 2020 12:44:58 +1100 (AEDT) Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B06520848; Sun, 12 Jan 2020 01:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578793495; bh=be5/qvDI0xWmWfszMbPxV2+iE40FAvtbAVatuYqBdFU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=f0hoRGlul2fyhkOOcYf1vS5xKaAldIjyYI8U8Uba9sbzBzlr3WwBUMp4wsLy5lJdJ XmmdHCMtMDQduupcXI0Mw4zH29CkC4uugIayLSeHFJMxGogQNV1b79k9XvjtJOogU9 4tM2vpzf/obL6Rvpm4tCnfNHWY7gk7jjptMstCSE= Date: Sun, 12 Jan 2020 10:44:46 +0900 From: Masami Hiramatsu To: arnaldo.melo@gmail.com Subject: Re: [PATCH v4 2/9] perf/core: open access for CAP_SYS_PERFMON privileged process Message-Id: <20200112104446.f667df82b061dfb9c7a6bdce@kernel.org> In-Reply-To: <5e191833.1c69fb81.8bc25.a88c@mx.google.com> References: <20200108160713.GI2844@hirez.programming.kicks-ass.net> <20200110140234.GO2844@hirez.programming.kicks-ass.net> <20200111005213.6dfd98fb36ace098004bde0e@kernel.org> <20200110164531.GA2598@kernel.org> <20200111084735.0ff01c758bfbfd0ae2e1f24e@kernel.org> <2B79131A-3F76-47F5-AAB4-08BCA820473F@fb.com> <5e191833.1c69fb81.8bc25.a88c@mx.google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: , Mark Rutland , Song Liu , Peter Zijlstra , joonas.lahtinen@linux.intel.com, Will Deacon , Alexei Starovoitov , Stephane Eranian , james.bottomley@hansenpartnership.com, Paul Mackerras , Jiri Olsa , Andi Kleen , Alexey Budankov , Igor Lubashev , James Morris , Alexander Shishkin , Ingo Molnar , "oprofile-list@lists.sf.net" , Serge Hallyn , Robert Richter , Kees Cook , Jann Horn , "selinux@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , jani.nikula@linux.intel.com, Lionel Landwerlin , rodrigo.vivi@intel.com, Namhyung Kim , Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" , Tvrtko Ursulin , "linux-parisc@vger.kernel.org" , linux-kernel , "linux-perf-users@vger.kernel.org" , "linux-security-module@vger.kernel.org" , Casey Schaufler , "bpf@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, 10 Jan 2020 21:35:12 -0300 arnaldo.melo@gmail.com wrote: > ,Jann Horn ,Thomas Gleixner ,Tvrtko Ursulin ,Lionel Landwerlin ,linux-kernel ,"linux-security-module@vger.kernel.org" ,"selinux@vger.kernel.org" ,"intel-gfx@lists.freedesktop.org" ,"bpf@vger.kernel.org" ,"linux-parisc@vger.kernel.org" ,"linuxppc-dev@lists.ozlabs.org" ,"linux-perf-users@vger.kernel.org" ,"linux-arm-kernel@lists.infradead.org" ,"oprofile-list@lists.sf.net" > From: Arnaldo Carvalho de Melo > Message-ID: > > On January 10, 2020 9:23:27 PM GMT-03:00, Song Liu wrote: > > > > > >> On Jan 10, 2020, at 3:47 PM, Masami Hiramatsu > >wrote: > >> > >> On Fri, 10 Jan 2020 13:45:31 -0300 > >> Arnaldo Carvalho de Melo wrote: > >> > >>> Em Sat, Jan 11, 2020 at 12:52:13AM +0900, Masami Hiramatsu escreveu: > >>>> On Fri, 10 Jan 2020 15:02:34 +0100 Peter Zijlstra > > wrote: > >>>>> Again, this only allows attaching to previously created kprobes, > >it does > >>>>> not allow creating kprobes, right? > >>> > >>>>> That is; I don't think CAP_SYS_PERFMON should be allowed to create > >>>>> kprobes. > >>> > >>>>> As might be clear; I don't actually know what the user-ABI is for > >>>>> creating kprobes. > >>> > >>>> There are 2 ABIs nowadays, ftrace and ebpf. perf-probe uses ftrace > >interface to > >>>> define new kprobe events, and those events are treated as > >completely same as > >>>> tracepoint events. On the other hand, ebpf tries to define new > >probe event > >>>> via perf_event interface. Above one is that interface. IOW, it > >creates new kprobe. > >>> > >>> Masami, any plans to make 'perf probe' use the perf_event_open() > >>> interface for creating kprobes/uprobes? > >> > >> Would you mean perf probe to switch to perf_event_open()? > >> No, perf probe is for setting up the ftrace probe events. I think we > >can add an > >> option to use perf_event_open(). But current kprobe creation from > >perf_event_open() > >> is separated from ftrace by design. > > > >I guess we can extend event parser to understand kprobe directly. > >Instead of > > > > perf probe kernel_func > > perf stat/record -e probe:kernel_func ... > > > >We can just do > > > > perf stat/record -e kprobe:kernel_func ... > > > You took the words from my mouth, exactly, that is a perfect use case, an alternative to the 'perf probe' one of making a disabled event that then gets activated via record/stat/trace, in many cases it's better, removes the explicit probe setup case. Ah, I got it. If the perf event parser just kicks perf's kprobe creation interface, it will be easy. In that case, there should be following differences. - perf * -e "kprobe":kernel_func will put a local (hidden) kprobe events. So ftrace user can not access it. - perf * -e "kprobe":kernel_func may not support inline/function-body nor trace local variables etc. Hm, if we support inline function via -e "kprobe" interface, we have to expand perf_event_open() to support multi-probe event. Thanks, > > Regards, > > - Arnaldo > > > > >Thanks, > >Song > -- Masami Hiramatsu 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=-0.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 F1FACC33CA7 for ; Sun, 12 Jan 2020 01:44:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4F2B2087F for ; Sun, 12 Jan 2020 01:44:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="f0hoRGlu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4F2B2087F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D7BF6E2B4; Sun, 12 Jan 2020 01:44:58 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 702CD6E2B4 for ; Sun, 12 Jan 2020 01:44:56 +0000 (UTC) Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B06520848; Sun, 12 Jan 2020 01:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578793495; bh=be5/qvDI0xWmWfszMbPxV2+iE40FAvtbAVatuYqBdFU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=f0hoRGlul2fyhkOOcYf1vS5xKaAldIjyYI8U8Uba9sbzBzlr3WwBUMp4wsLy5lJdJ XmmdHCMtMDQduupcXI0Mw4zH29CkC4uugIayLSeHFJMxGogQNV1b79k9XvjtJOogU9 4tM2vpzf/obL6Rvpm4tCnfNHWY7gk7jjptMstCSE= Date: Sun, 12 Jan 2020 10:44:46 +0900 From: Masami Hiramatsu To: arnaldo.melo@gmail.com Message-Id: <20200112104446.f667df82b061dfb9c7a6bdce@kernel.org> In-Reply-To: <5e191833.1c69fb81.8bc25.a88c@mx.google.com> References: <20200108160713.GI2844@hirez.programming.kicks-ass.net> <20200110140234.GO2844@hirez.programming.kicks-ass.net> <20200111005213.6dfd98fb36ace098004bde0e@kernel.org> <20200110164531.GA2598@kernel.org> <20200111084735.0ff01c758bfbfd0ae2e1f24e@kernel.org> <2B79131A-3F76-47F5-AAB4-08BCA820473F@fb.com> <5e191833.1c69fb81.8bc25.a88c@mx.google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Subject: Re: [Intel-gfx] [PATCH v4 2/9] perf/core: open access for CAP_SYS_PERFMON privileged process X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: , Mark Rutland , Song Liu , Peter Zijlstra , Benjamin Herrenschmidt , Will Deacon , Alexei Starovoitov , Stephane Eranian , james.bottomley@hansenpartnership.com, Paul Mackerras , Jiri Olsa , Andi Kleen , Michael Ellerman , Igor Lubashev , James Morris , Alexander Shishkin , Ingo Molnar , "oprofile-list@lists.sf.net" , Serge Hallyn , Robert Richter , Kees Cook , Jann Horn , "selinux@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , Namhyung Kim , Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" , "linux-parisc@vger.kernel.org" , linux-kernel , "linux-perf-users@vger.kernel.org" , "linux-security-module@vger.kernel.org" , Casey Schaufler , "bpf@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Fri, 10 Jan 2020 21:35:12 -0300 arnaldo.melo@gmail.com wrote: > ,Jann Horn ,Thomas Gleixner ,Tvrtko Ursulin ,Lionel Landwerlin ,linux-kernel ,"linux-security-module@vger.kernel.org" ,"selinux@vger.kernel.org" ,"intel-gfx@lists.freedesktop.org" ,"bpf@vger.kernel.org" ,"linux-parisc@vger.kernel.org" ,"linuxppc-dev@lists.ozlabs.org" ,"linux-perf-users@vger.kernel.org" ,"linux-arm-kernel@lists.infradead.org" ,"oprofile-list@lists.sf.net" > From: Arnaldo Carvalho de Melo > Message-ID: > > On January 10, 2020 9:23:27 PM GMT-03:00, Song Liu wrote: > > > > > >> On Jan 10, 2020, at 3:47 PM, Masami Hiramatsu > >wrote: > >> > >> On Fri, 10 Jan 2020 13:45:31 -0300 > >> Arnaldo Carvalho de Melo wrote: > >> > >>> Em Sat, Jan 11, 2020 at 12:52:13AM +0900, Masami Hiramatsu escreveu: > >>>> On Fri, 10 Jan 2020 15:02:34 +0100 Peter Zijlstra > > wrote: > >>>>> Again, this only allows attaching to previously created kprobes, > >it does > >>>>> not allow creating kprobes, right? > >>> > >>>>> That is; I don't think CAP_SYS_PERFMON should be allowed to create > >>>>> kprobes. > >>> > >>>>> As might be clear; I don't actually know what the user-ABI is for > >>>>> creating kprobes. > >>> > >>>> There are 2 ABIs nowadays, ftrace and ebpf. perf-probe uses ftrace > >interface to > >>>> define new kprobe events, and those events are treated as > >completely same as > >>>> tracepoint events. On the other hand, ebpf tries to define new > >probe event > >>>> via perf_event interface. Above one is that interface. IOW, it > >creates new kprobe. > >>> > >>> Masami, any plans to make 'perf probe' use the perf_event_open() > >>> interface for creating kprobes/uprobes? > >> > >> Would you mean perf probe to switch to perf_event_open()? > >> No, perf probe is for setting up the ftrace probe events. I think we > >can add an > >> option to use perf_event_open(). But current kprobe creation from > >perf_event_open() > >> is separated from ftrace by design. > > > >I guess we can extend event parser to understand kprobe directly. > >Instead of > > > > perf probe kernel_func > > perf stat/record -e probe:kernel_func ... > > > >We can just do > > > > perf stat/record -e kprobe:kernel_func ... > > > You took the words from my mouth, exactly, that is a perfect use case, an alternative to the 'perf probe' one of making a disabled event that then gets activated via record/stat/trace, in many cases it's better, removes the explicit probe setup case. Ah, I got it. If the perf event parser just kicks perf's kprobe creation interface, it will be easy. In that case, there should be following differences. - perf * -e "kprobe":kernel_func will put a local (hidden) kprobe events. So ftrace user can not access it. - perf * -e "kprobe":kernel_func may not support inline/function-body nor trace local variables etc. Hm, if we support inline function via -e "kprobe" interface, we have to expand perf_event_open() to support multi-probe event. Thanks, > > Regards, > > - Arnaldo > > > > >Thanks, > >Song > -- Masami Hiramatsu _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx