Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754058AbcDHRyf (ORCPT ); Fri, 8 Apr 2016 13:54:35 -0400 Received: from mail.kernel.org ([198.145.29.136]:50579 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751046AbcDHRye (ORCPT ); Fri, 8 Apr 2016 13:54:34 -0400 Date: Fri, 8 Apr 2016 14:54:28 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: pi3orama@163.com, linux-kernel@vger.kernel.org, lizefan@huawei.com, Wang Nan , Arnaldo Carvalho de Melo , Jiri Olsa Subject: Re: [PATCH 4/4] perf bpf: Automatically create bpf-output event __bpf_stdout__ Message-ID: <20160408175428.GA25165@kernel.org> References: <1460128045-97310-1-git-send-email-wangnan0@huawei.com> <1460128045-97310-5-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460128045-97310-5-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1389 Lines: 38 Em Fri, Apr 08, 2016 at 03:07:25PM +0000, Wang Nan escreveu: > struct bpf_map_def SEC("maps") __bpf_stdout__ = { > .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, > .key_size = sizeof(int), > .value_size = sizeof(u32), > .max_entries = __NR_CPUS__, > }; > > static inline int __attribute__((always_inline)) > func(void *ctx, int type) > { > char output_str[] = "Raise a BPF event!"; > char err_str[] = "BAD %d\n"; > int err; > > err = perf_event_output(ctx, &channel, get_smp_processor_id(), I had to change channel here to __bpf_stdout__, then it works :-) > &output_str, sizeof(output_str)); > if (err) > trace_printk(err_str, sizeof(err_str), err); > return 1; Asking for strace-like output for 'nanosleep', the function hooked: [root@jouet bpf]# trace -e nanosleep --ev test_bpf_stdout.c usleep 1 0.007 ( 0.007 ms): usleep/729 nanosleep(rqtp: 0x7ffc5bbc5fe0) ... 0.007 ( ): __bpf_stdout__:Raise a BPF event!..) 0.008 ( ): perf_bpf_probe:func_begin:(ffffffff81112460)) 0.069 ( ): __bpf_stdout__:Raise a BPF event!..) 0.070 ( ): perf_bpf_probe:func_end:(ffffffff81112460 <- ffffffff81003d92)) 0.072 ( 0.072 ms): usleep/729 ... [continued]: nanosleep()) = 0 [root@jouet bpf]# Ok, merged those, now lets see how all this mixes with callchains... - Arnaldo