<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/samples/bpf/Makefile, branch v4.6-rc3</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>samples/bpf: Use llc in PATH, rather than a hardcoded value</title>
<updated>2016-04-06T20:01:28+00:00</updated>
<author>
<name>Naveen N. Rao</name>
<email>naveen.n.rao@linux.vnet.ibm.com</email>
</author>
<published>2016-04-04T17:01:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=128d1514be3583c3cfd56d66d7cdfba413b867ae'/>
<id>128d1514be3583c3cfd56d66d7cdfba413b867ae</id>
<content type='text'>
While at it, remove the generation of .s files and fix some typos in the
related comment.

Cc: Alexei Starovoitov &lt;ast@fb.com&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Cc: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Ananth N Mavinakayanahalli &lt;ananth@in.ibm.com&gt;
Cc: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Naveen N. Rao &lt;naveen.n.rao@linux.vnet.ibm.com&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While at it, remove the generation of .s files and fix some typos in the
related comment.

Cc: Alexei Starovoitov &lt;ast@fb.com&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Cc: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Ananth N Mavinakayanahalli &lt;ananth@in.ibm.com&gt;
Cc: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Naveen N. Rao &lt;naveen.n.rao@linux.vnet.ibm.com&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>samples/bpf: add map performance test</title>
<updated>2016-03-09T04:22:03+00:00</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-03-08T23:07:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=26e9093110fb9ceb10093e4914b129b58d49a425'/>
<id>26e9093110fb9ceb10093e4914b129b58d49a425</id>
<content type='text'>
performance tests for hash map and per-cpu hash map
with and without pre-allocation

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
performance tests for hash map and per-cpu hash map
with and without pre-allocation

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>samples/bpf: add bpf map stress test</title>
<updated>2016-03-09T04:22:02+00:00</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-03-08T23:07:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9d8b612d88e81c2cf7dbc0d4a827da6ca0d848e0'/>
<id>9d8b612d88e81c2cf7dbc0d4a827da6ca0d848e0</id>
<content type='text'>
this test calls bpf programs from different contexts:
from inside of slub, from rcu, from pretty much everywhere,
since it kprobes all spin_lock functions.
It stresses the bpf hash and percpu map pre-allocation,
deallocation logic and call_rcu mechanisms.
User space part adding more stress by walking and deleting map elements.

Note that due to nature bpf_load.c the earlier kprobe+bpf programs are
already active while loader loads new programs, creates new kprobes and
attaches them.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this test calls bpf programs from different contexts:
from inside of slub, from rcu, from pretty much everywhere,
since it kprobes all spin_lock functions.
It stresses the bpf hash and percpu map pre-allocation,
deallocation logic and call_rcu mechanisms.
User space part adding more stress by walking and deleting map elements.

Note that due to nature bpf_load.c the earlier kprobe+bpf programs are
already active while loader loads new programs, creates new kprobes and
attaches them.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>samples/bpf: offwaketime example</title>
<updated>2016-02-20T05:21:44+00:00</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-02-18T03:58:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a6ffe7b9df6228d11c5689914eceb488bc4e38df'/>
<id>a6ffe7b9df6228d11c5689914eceb488bc4e38df</id>
<content type='text'>
This is simplified version of Brendan Gregg's offwaketime:
This program shows kernel stack traces and task names that were blocked and
"off-CPU", along with the stack traces and task names for the threads that woke
them, and the total elapsed time from when they blocked to when they were woken
up. The combined stacks, task names, and total time is summarized in kernel
context for efficiency.

Example:
$ sudo ./offwaketime | flamegraph.pl &gt; demo.svg
Open demo.svg in the browser as FlameGraph visualization.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is simplified version of Brendan Gregg's offwaketime:
This program shows kernel stack traces and task names that were blocked and
"off-CPU", along with the stack traces and task names for the threads that woke
them, and the total elapsed time from when they blocked to when they were woken
up. The combined stacks, task names, and total time is summarized in kernel
context for efficiency.

Example:
$ sudo ./offwaketime | flamegraph.pl &gt; demo.svg
Open demo.svg in the browser as FlameGraph visualization.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>bpf: samples: exclude asm/sysreg.h for arm64</title>
<updated>2015-11-16T19:40:49+00:00</updated>
<author>
<name>Yang Shi</name>
<email>yang.shi@linaro.org</email>
</author>
<published>2015-11-12T22:07:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=30b50aa612018bd92f5a85534cc2668423e8c7e8'/>
<id>30b50aa612018bd92f5a85534cc2668423e8c7e8</id>
<content type='text'>
commit 338d4f49d6f7114a017d294ccf7374df4f998edc
("arm64: kernel: Add support for Privileged Access Never") includes sysreg.h
into futex.h and uaccess.h. But, the inline assembly used by asm/sysreg.h is
incompatible with llvm so it will cause BPF samples build failure for ARM64.
Since sysreg.h is useless for BPF samples, just exclude it from Makefile via
defining __ASM_SYSREG_H.

Signed-off-by: Yang Shi &lt;yang.shi@linaro.org&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 338d4f49d6f7114a017d294ccf7374df4f998edc
("arm64: kernel: Add support for Privileged Access Never") includes sysreg.h
into futex.h and uaccess.h. But, the inline assembly used by asm/sysreg.h is
incompatible with llvm so it will cause BPF samples build failure for ARM64.
Since sysreg.h is useless for BPF samples, just exclude it from Makefile via
defining __ASM_SYSREG_H.

Signed-off-by: Yang Shi &lt;yang.shi@linaro.org&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>bpf: add sample usages for persistent maps/progs</title>
<updated>2015-11-03T03:48:39+00:00</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2015-10-29T13:58:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=42984d7c1e563bf92e6ca7a0fd89f8e933f2162e'/>
<id>42984d7c1e563bf92e6ca7a0fd89f8e933f2162e</id>
<content type='text'>
This patch adds a couple of stand-alone examples on how BPF_OBJ_PIN
and BPF_OBJ_GET commands can be used.

Example with maps:

  # ./fds_example -F /sys/fs/bpf/m -P -m -k 1 -v 42
  bpf: map fd:3 (Success)
  bpf: pin ret:(0,Success)
  bpf: fd:3 u-&gt;(1:42) ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m -G -m -k 1
  bpf: get fd:3 (Success)
  bpf: fd:3 l-&gt;(1):42 ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m -G -m -k 1 -v 24
  bpf: get fd:3 (Success)
  bpf: fd:3 u-&gt;(1:24) ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m -G -m -k 1
  bpf: get fd:3 (Success)
  bpf: fd:3 l-&gt;(1):24 ret:(0,Success)

  # ./fds_example -F /sys/fs/bpf/m2 -P -m
  bpf: map fd:3 (Success)
  bpf: pin ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m2 -G -m -k 1
  bpf: get fd:3 (Success)
  bpf: fd:3 l-&gt;(1):0 ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m2 -G -m
  bpf: get fd:3 (Success)

Example with progs:

  # ./fds_example -F /sys/fs/bpf/p -P -p
  bpf: prog fd:3 (Success)
  bpf: pin ret:(0,Success)
  bpf sock:4 &lt;- fd:3 attached ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/p -G -p
  bpf: get fd:3 (Success)
  bpf: sock:4 &lt;- fd:3 attached ret:(0,Success)

  # ./fds_example -F /sys/fs/bpf/p2 -P -p -o ./sockex1_kern.o
  bpf: prog fd:5 (Success)
  bpf: pin ret:(0,Success)
  bpf: sock:3 &lt;- fd:5 attached ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/p2 -G -p
  bpf: get fd:3 (Success)
  bpf: sock:4 &lt;- fd:3 attached ret:(0,Success)

Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds a couple of stand-alone examples on how BPF_OBJ_PIN
and BPF_OBJ_GET commands can be used.

Example with maps:

  # ./fds_example -F /sys/fs/bpf/m -P -m -k 1 -v 42
  bpf: map fd:3 (Success)
  bpf: pin ret:(0,Success)
  bpf: fd:3 u-&gt;(1:42) ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m -G -m -k 1
  bpf: get fd:3 (Success)
  bpf: fd:3 l-&gt;(1):42 ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m -G -m -k 1 -v 24
  bpf: get fd:3 (Success)
  bpf: fd:3 u-&gt;(1:24) ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m -G -m -k 1
  bpf: get fd:3 (Success)
  bpf: fd:3 l-&gt;(1):24 ret:(0,Success)

  # ./fds_example -F /sys/fs/bpf/m2 -P -m
  bpf: map fd:3 (Success)
  bpf: pin ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m2 -G -m -k 1
  bpf: get fd:3 (Success)
  bpf: fd:3 l-&gt;(1):0 ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/m2 -G -m
  bpf: get fd:3 (Success)

Example with progs:

  # ./fds_example -F /sys/fs/bpf/p -P -p
  bpf: prog fd:3 (Success)
  bpf: pin ret:(0,Success)
  bpf sock:4 &lt;- fd:3 attached ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/p -G -p
  bpf: get fd:3 (Success)
  bpf: sock:4 &lt;- fd:3 attached ret:(0,Success)

  # ./fds_example -F /sys/fs/bpf/p2 -P -p -o ./sockex1_kern.o
  bpf: prog fd:5 (Success)
  bpf: pin ret:(0,Success)
  bpf: sock:3 &lt;- fd:5 attached ret:(0,Success)
  # ./fds_example -F /sys/fs/bpf/p2 -G -p
  bpf: get fd:3 (Success)
  bpf: sock:4 &lt;- fd:3 attached ret:(0,Success)

Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>samples: bpf: add bpf_perf_event_output example</title>
<updated>2015-10-22T13:42:15+00:00</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@plumgrid.com</email>
</author>
<published>2015-10-21T03:02:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=39111695b1b88a21e81983a38786d877e770da81'/>
<id>39111695b1b88a21e81983a38786d877e770da81</id>
<content type='text'>
Performance test and example of bpf_perf_event_output().
kprobe is attached to sys_write() and trivial bpf program streams
pid+cookie into userspace via PERF_COUNT_SW_BPF_OUTPUT event.

Usage:
$ sudo ./bld_x64/samples/bpf/trace_output
recv 2968913 events per sec

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Performance test and example of bpf_perf_event_output().
kprobe is attached to sys_write() and trivial bpf program streams
pid+cookie into userspace via PERF_COUNT_SW_BPF_OUTPUT event.

Usage:
$ sudo ./bld_x64/samples/bpf/trace_output
recv 2968913 events per sec

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>samples/bpf: example of get selected PMU counter value</title>
<updated>2015-08-10T05:50:06+00:00</updated>
<author>
<name>Kaixu Xia</name>
<email>xiakaixu@huawei.com</email>
</author>
<published>2015-08-06T07:02:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=47efb30274cbec1bd3c0c980a7ece328df2c16a8'/>
<id>47efb30274cbec1bd3c0c980a7ece328df2c16a8</id>
<content type='text'>
This is a simple example and shows how to use the new ability
to get the selected Hardware PMU counter value.

Signed-off-by: Kaixu Xia &lt;xiakaixu@huawei.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a simple example and shows how to use the new ability
to get the selected Hardware PMU counter value.

Signed-off-by: Kaixu Xia &lt;xiakaixu@huawei.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>bpf: BPF based latency tracing</title>
<updated>2015-06-23T13:09:58+00:00</updated>
<author>
<name>Daniel Wagner</name>
<email>daniel.wagner@bmw-carit.de</email>
</author>
<published>2015-06-19T14:00:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0fb1170ee68a6aa14eca0666e02c4b62cbf1251d'/>
<id>0fb1170ee68a6aa14eca0666e02c4b62cbf1251d</id>
<content type='text'>
BPF offers another way to generate latency histograms. We attach
kprobes at trace_preempt_off and trace_preempt_on and calculate the
time it takes to from seeing the off/on transition.

The first array is used to store the start time stamp. The key is the
CPU id. The second array stores the log2(time diff). We need to use
static allocation here (array and not hash tables). The kprobes
hooking into trace_preempt_on|off should not calling any dynamic
memory allocation or free path. We need to avoid recursivly
getting called. Besides that, it reduces jitter in the measurement.

CPU 0
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 166723   |*************************************** |
    4096 -&gt; 8191     : 19870    |***                                     |
    8192 -&gt; 16383    : 6324     |                                        |
   16384 -&gt; 32767    : 1098     |                                        |
   32768 -&gt; 65535    : 190      |                                        |
   65536 -&gt; 131071   : 179      |                                        |
  131072 -&gt; 262143   : 18       |                                        |
  262144 -&gt; 524287   : 4        |                                        |
  524288 -&gt; 1048575  : 1363     |                                        |
CPU 1
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 114042   |*************************************** |
    4096 -&gt; 8191     : 9587     |**                                      |
    8192 -&gt; 16383    : 4140     |                                        |
   16384 -&gt; 32767    : 673      |                                        |
   32768 -&gt; 65535    : 179      |                                        |
   65536 -&gt; 131071   : 29       |                                        |
  131072 -&gt; 262143   : 4        |                                        |
  262144 -&gt; 524287   : 1        |                                        |
  524288 -&gt; 1048575  : 364      |                                        |
CPU 2
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 40147    |*************************************** |
    4096 -&gt; 8191     : 2300     |*                                       |
    8192 -&gt; 16383    : 828      |                                        |
   16384 -&gt; 32767    : 178      |                                        |
   32768 -&gt; 65535    : 59       |                                        |
   65536 -&gt; 131071   : 2        |                                        |
  131072 -&gt; 262143   : 0        |                                        |
  262144 -&gt; 524287   : 1        |                                        |
  524288 -&gt; 1048575  : 174      |                                        |
CPU 3
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 29626    |*************************************** |
    4096 -&gt; 8191     : 2704     |**                                      |
    8192 -&gt; 16383    : 1090     |                                        |
   16384 -&gt; 32767    : 160      |                                        |
   32768 -&gt; 65535    : 72       |                                        |
   65536 -&gt; 131071   : 32       |                                        |
  131072 -&gt; 262143   : 26       |                                        |
  262144 -&gt; 524287   : 12       |                                        |
  524288 -&gt; 1048575  : 298      |                                        |

All this is based on the trace3 examples written by
Alexei Starovoitov &lt;ast@plumgrid.com&gt;.

Signed-off-by: Daniel Wagner &lt;daniel.wagner@bmw-carit.de&gt;
Cc: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Cc: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org
Acked-by: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
BPF offers another way to generate latency histograms. We attach
kprobes at trace_preempt_off and trace_preempt_on and calculate the
time it takes to from seeing the off/on transition.

The first array is used to store the start time stamp. The key is the
CPU id. The second array stores the log2(time diff). We need to use
static allocation here (array and not hash tables). The kprobes
hooking into trace_preempt_on|off should not calling any dynamic
memory allocation or free path. We need to avoid recursivly
getting called. Besides that, it reduces jitter in the measurement.

CPU 0
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 166723   |*************************************** |
    4096 -&gt; 8191     : 19870    |***                                     |
    8192 -&gt; 16383    : 6324     |                                        |
   16384 -&gt; 32767    : 1098     |                                        |
   32768 -&gt; 65535    : 190      |                                        |
   65536 -&gt; 131071   : 179      |                                        |
  131072 -&gt; 262143   : 18       |                                        |
  262144 -&gt; 524287   : 4        |                                        |
  524288 -&gt; 1048575  : 1363     |                                        |
CPU 1
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 114042   |*************************************** |
    4096 -&gt; 8191     : 9587     |**                                      |
    8192 -&gt; 16383    : 4140     |                                        |
   16384 -&gt; 32767    : 673      |                                        |
   32768 -&gt; 65535    : 179      |                                        |
   65536 -&gt; 131071   : 29       |                                        |
  131072 -&gt; 262143   : 4        |                                        |
  262144 -&gt; 524287   : 1        |                                        |
  524288 -&gt; 1048575  : 364      |                                        |
CPU 2
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 40147    |*************************************** |
    4096 -&gt; 8191     : 2300     |*                                       |
    8192 -&gt; 16383    : 828      |                                        |
   16384 -&gt; 32767    : 178      |                                        |
   32768 -&gt; 65535    : 59       |                                        |
   65536 -&gt; 131071   : 2        |                                        |
  131072 -&gt; 262143   : 0        |                                        |
  262144 -&gt; 524287   : 1        |                                        |
  524288 -&gt; 1048575  : 174      |                                        |
CPU 3
      latency        : count     distribution
       1 -&gt; 1        : 0        |                                        |
       2 -&gt; 3        : 0        |                                        |
       4 -&gt; 7        : 0        |                                        |
       8 -&gt; 15       : 0        |                                        |
      16 -&gt; 31       : 0        |                                        |
      32 -&gt; 63       : 0        |                                        |
      64 -&gt; 127      : 0        |                                        |
     128 -&gt; 255      : 0        |                                        |
     256 -&gt; 511      : 0        |                                        |
     512 -&gt; 1023     : 0        |                                        |
    1024 -&gt; 2047     : 0        |                                        |
    2048 -&gt; 4095     : 29626    |*************************************** |
    4096 -&gt; 8191     : 2704     |**                                      |
    8192 -&gt; 16383    : 1090     |                                        |
   16384 -&gt; 32767    : 160      |                                        |
   32768 -&gt; 65535    : 72       |                                        |
   65536 -&gt; 131071   : 32       |                                        |
  131072 -&gt; 262143   : 26       |                                        |
  262144 -&gt; 524287   : 12       |                                        |
  524288 -&gt; 1048575  : 298      |                                        |

All this is based on the trace3 examples written by
Alexei Starovoitov &lt;ast@plumgrid.com&gt;.

Signed-off-by: Daniel Wagner &lt;daniel.wagner@bmw-carit.de&gt;
Cc: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Cc: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org
Acked-by: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>samples/bpf: bpf_tail_call example for networking</title>
<updated>2015-05-21T21:07:59+00:00</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@plumgrid.com</email>
</author>
<published>2015-05-19T23:59:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=530b2c8619f25f9c332c85510579943aa46df515'/>
<id>530b2c8619f25f9c332c85510579943aa46df515</id>
<content type='text'>
Usage:
$ sudo ./sockex3
IP     src.port -&gt; dst.port               bytes      packets
127.0.0.1.42010 -&gt; 127.0.0.1.12865         1568            8
127.0.0.1.59526 -&gt; 127.0.0.1.33778     11422636       173070
127.0.0.1.33778 -&gt; 127.0.0.1.59526  11260224828       341974
127.0.0.1.12865 -&gt; 127.0.0.1.42010         1832           12
IP     src.port -&gt; dst.port               bytes      packets
127.0.0.1.42010 -&gt; 127.0.0.1.12865         1568            8
127.0.0.1.59526 -&gt; 127.0.0.1.33778     23198092       351486
127.0.0.1.33778 -&gt; 127.0.0.1.59526  22972698518       698616
127.0.0.1.12865 -&gt; 127.0.0.1.42010         1832           12

this example is similar to sockex2 in a way that it accumulates per-flow
statistics, but it does packet parsing differently.
sockex2 inlines full packet parser routine into single bpf program.
This sockex3 example have 4 independent programs that parse vlan, mpls, ip, ipv6
and one main program that starts the process.
bpf_tail_call() mechanism allows each program to be small and be called
on demand potentially multiple times, so that many vlan, mpls, ip in ip,
gre encapsulations can be parsed. These and other protocol parsers can
be added or removed at runtime. TLVs can be parsed in similar manner.
Note, tail_call_cnt dynamic check limits the number of tail calls to 32.

Signed-off-by: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Usage:
$ sudo ./sockex3
IP     src.port -&gt; dst.port               bytes      packets
127.0.0.1.42010 -&gt; 127.0.0.1.12865         1568            8
127.0.0.1.59526 -&gt; 127.0.0.1.33778     11422636       173070
127.0.0.1.33778 -&gt; 127.0.0.1.59526  11260224828       341974
127.0.0.1.12865 -&gt; 127.0.0.1.42010         1832           12
IP     src.port -&gt; dst.port               bytes      packets
127.0.0.1.42010 -&gt; 127.0.0.1.12865         1568            8
127.0.0.1.59526 -&gt; 127.0.0.1.33778     23198092       351486
127.0.0.1.33778 -&gt; 127.0.0.1.59526  22972698518       698616
127.0.0.1.12865 -&gt; 127.0.0.1.42010         1832           12

this example is similar to sockex2 in a way that it accumulates per-flow
statistics, but it does packet parsing differently.
sockex2 inlines full packet parser routine into single bpf program.
This sockex3 example have 4 independent programs that parse vlan, mpls, ip, ipv6
and one main program that starts the process.
bpf_tail_call() mechanism allows each program to be small and be called
on demand potentially multiple times, so that many vlan, mpls, ip in ip,
gre encapsulations can be parsed. These and other protocol parsers can
be added or removed at runtime. TLVs can be parsed in similar manner.
Note, tail_call_cnt dynamic check limits the number of tail calls to 32.

Signed-off-by: Alexei Starovoitov &lt;ast@plumgrid.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
</feed>
