Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759240AbcDAPUG (ORCPT ); Fri, 1 Apr 2016 11:20:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37384 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932378AbcDAPTe (ORCPT ); Fri, 1 Apr 2016 11:19:34 -0400 Date: Fri, 1 Apr 2016 12:19:30 -0300 From: Arnaldo Carvalho de Melo To: Arnaldo Carvalho de Melo Cc: Wang Nan , linux-kernel@vger.kernel.org, pi3orama@163.com, Adrian Hunter , Ingo Molnar , David Ahern , Jiri Olsa , Milian Wolff , Namhyung Kim , Brendan Gregg Subject: Re: [PATCH] perf tools: Add sample types for bpf-output event Message-ID: <20160401151930.GB9494@redhat.com> References: <1459517202-42320-1-git-send-email-wangnan0@huawei.com> <20160401151610.GG7115@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160401151610.GG7115@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 01 Apr 2016 15:19:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1148 Lines: 29 Em Fri, Apr 01, 2016 at 12:16:10PM -0300, Arnaldo Carvalho de Melo escreveu: > Perhaps, to make all more familiar we could even define equivalents to > stdio.h functions like puts, printf, fputs, etc, that would send to this > bpf-output based "stdout" "channel", then the above would end up being: > > func(void *ctx, int type) > { > char err_str[] = "BAD %d\n"; > int err; > > err = puts("Raise a BPF event!"); > if (err) > trace_printk(err_str, sizeof(err_str), err); > return 1; > } > > This trace_printk() in turn could become error() (glibc's error.h header), i.e. > the error mechanism would use the equivalent to userland's "syslog", i.e. > trace_printk :-) > > In general trying to make BPF C scriptlets fed via perf to be as compact as > possible, hiding all these details while allowing them to be used, if desired. One extra possibility would be that it would look so much like a user space C program that we could test it without loading it to the kernel, with just building it with a different header and feeding it data as it would get inside the kernel :-) - Arnaldo