From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Wang Nan <wangnan0@huawei.com>
Cc: linux-kernel@vger.kernel.org, pi3orama@163.com,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Ingo Molnar <mingo@kernel.org>, David Ahern <dsahern@gmail.com>,
Jiri Olsa <jolsa@kernel.org>,
Milian Wolff <milian.wolff@kdab.com>,
Namhyung Kim <namhyung@kernel.org>,
Brendan Gregg <brendan.d.gregg@gmail.com>
Subject: Re: [PATCH] perf tools: Add sample types for bpf-output event
Date: Fri, 1 Apr 2016 12:16:10 -0300 [thread overview]
Message-ID: <20160401151610.GG7115@kernel.org> (raw)
In-Reply-To: <1459517202-42320-1-git-send-email-wangnan0@huawei.com>
Em Fri, Apr 01, 2016 at 01:26:42PM +0000, Wang Nan escreveu:
> Before this patch we can see very large time in the events before
> bpf-output event. For example:
>
> # perf trace --ev bpf-output/no-inherit,name=evt/ \
> --ev ./test_bpf_trace.c/map:channel.event=evt/ \
> usleep 10
Thanks, applied and tested, now one idea that occurred to me to shorten
the above command line: automagically create a
"__perf_trace_bpf_stdout__" bpf-output event when a .c bpf event is
specified and no bpf-output is present, i.e. the following command line
would produce the same result as the one above:
# trace --ev test_bpf_trace.c usleep 10
Well, it would have to build test_bpf_trace.c and see if it references
the equivalent of a "stdout", i.e. it expects a bpf-output event to be
present to send output to.
I.e. in this example we have a:
struct bpf_map_def SEC("maps") channel = {
That later on you use to do "puts(msg)" like operations, i.e. to a
"stdout" of sorts:
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(),
&output_str, sizeof(output_str));
if (err)
trace_printk(err_str, sizeof(err_str), err);
return 1;
}
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.
- Arnaldo
next prev parent reply other threads:[~2016-04-01 15:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 13:26 [PATCH] perf tools: Add sample types for bpf-output event Wang Nan
2016-04-01 15:16 ` Arnaldo Carvalho de Melo [this message]
2016-04-01 15:19 ` Arnaldo Carvalho de Melo
2016-04-06 7:10 ` [tip:perf/core] perf bpf: Add sample types for 'bpf-output' event tip-bot for Wang Nan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160401151610.GG7115@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=brendan.d.gregg@gmail.com \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=milian.wolff@kdab.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).