Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755375AbbFMC6J (ORCPT ); Fri, 12 Jun 2015 22:58:09 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:36468 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751362AbbFMC6E (ORCPT ); Fri, 12 Jun 2015 22:58:04 -0400 Message-ID: <557B9C3A.50101@plumgrid.com> Date: Fri, 12 Jun 2015 19:58:02 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo , Masami Hiramatsu CC: David Ahern , Jiri Olsa , Namhyung Kim , Ingo Molnar , Linux Kernel Mailing List Subject: Re: perf probe and structs References: <20150612192716.GE6850@kernel.org> In-Reply-To: <20150612192716.GE6850@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1530 Lines: 45 On 6/12/15 12:27 PM, Arnaldo Carvalho de Melo wrote: > Alexei, is this already possible with eBPF? > I want to decode that attr_uptr thing :-) yes, it's already possible :) Here is working example from our experimental c+python thingy: #!/usr/bin/env python from bpf import BPF from subprocess import call prog = """ #include #include int hello(struct pt_regs *ctx) { struct perf_event_attr attr = {}; bpf_probe_read(&attr, sizeof(attr), (void *) ctx->di); char fmt[] = "type %x size %d config %d\\n"; bpf_trace_printk(fmt, sizeof(fmt), attr.type, attr.size, attr.config); return 0; } """ b = BPF(text=prog) fn = b.load_func("hello", BPF.KPROBE) BPF.attach_kprobe(fn, "SYSC_perf_event_open") try: call(["cat", "/sys/kernel/debug/tracing/trace_pipe"]) except KeyboardInterrupt: pass running above gives me output: # ./example.py perf_4.1.0-5544 [001] d.h3 3818.231428: : type 1 size 0 config 0 perf_4.1.0-5544 [001] d.h3 3818.231494: : type 0 size 112 config 0 perf_4.1.0-5544 [001] d.h3 3818.231530: : type 0 size 112 config 0 perf_4.1.0-5544 [001] d.h3 3818.231554: : type 0 size 112 config 0 perf_4.1.0-5544 [001] d.h3 3818.231564: : type 0 size 112 config 0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/