[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMEtUuxFmGz7hEYf+_Kux5ir28ehJjTPFPfc0k4xfSZ6RcbM+g@mail.gmail.com>
Date: Thu, 14 Aug 2014 23:19:57 -0700
From: Alexei Starovoitov <ast@...mgrid.com>
To: Brendan Gregg <brendan.d.gregg@...il.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Ingo Molnar <mingo@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andy Lutomirski <luto@...capital.net>,
Steven Rostedt <rostedt@...dmis.org>,
Daniel Borkmann <dborkman@...hat.com>,
Chema Gonzalez <chema@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
"H. Peter Anvin" <hpa@...or.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <keescook@...omium.org>,
Linux API <linux-api@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH RFC v4 net-next 25/26] samples: bpf: counting eBPF example
in C
On Thu, Aug 14, 2014 at 3:13 PM, Brendan Gregg
<brendan.d.gregg@...il.com> wrote:
> On Wed, Aug 13, 2014 at 12:57 AM, Alexei Starovoitov <ast@...mgrid.com> wrote:
>> this example has two probes in C that use two different maps.
>>
>> 1st probe is the similar to dropmon.c. It attaches to kfree_skb tracepoint and
>> count number of packet drops at different locations
>>
>> 2nd probe attaches to kprobe/sys_write and computes a histogram of different
>> write sizes
>>
>> Usage:
>> $ sudo ex2
>>
>> Should see:
>> writing bpf-5 -> /sys/kernel/debug/tracing/events/skb/kfree_skb/filter
>> writing bpf-8 -> /sys/kernel/debug/tracing/events/kprobes/sys_write/filter
>> location 0xffffffff816efc67 count 1
>>
>> location 0xffffffff815d8030 count 1
>> location 0xffffffff816efc67 count 3
>>
>> location 0xffffffff815d8030 count 4
>> location 0xffffffff816efc67 count 9
>>
>> syscall write() stats
>> byte_size : count distribution
>> 1 -> 1 : 3141 |**** |
>> 2 -> 3 : 2 | |
>> 4 -> 7 : 14 | |
>> 8 -> 15 : 3268 |***** |
>> 16 -> 31 : 732 | |
>> 32 -> 63 : 20042 |************************************* |
>> 64 -> 127 : 12154 |********************** |
>> 128 -> 255 : 2215 |*** |
>> 256 -> 511 : 9 | |
>> 512 -> 1023 : 0 | |
>> 1024 -> 2047 : 1 | |
>
> This is pretty awesome.
>
> Given that this is tracing two tracepoints at once, I'd like to see a
> similar example where time is stored on the first tracepoint,
> retrieved on the second for a delta calculation, then presented with a
> similar histogram as seen above.
Very good point. The time related helpers are missing. In V5 I'm
thinking to add something like bpf_ktime_get_ns().
To associate begin and end events I think bpf_gettid() would be
needed, but that doesn't feel generic enough for helper function,
so I'm leaning toward 'bpf_get_current()' helper that will return
'current' task pointer. eBPF program can use this pointer for
correlation of events or can go exploring task fields with
bpf_fetch_() helpers...
Thank you very much for trying things out and for your feedback!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists