Improve coverage for kprobe event_re
authorBrenden Blanco <bblanco@plumgrid.com>
Thu, 10 Sep 2015 01:28:21 +0000 (18:28 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Thu, 10 Sep 2015 07:24:40 +0000 (00:24 -0700)
commit7e71aef910c3712ef008b6e0233fc25212deaff9
tree242aad4e5091141a6dfde18fbde745246ba3ce83
parent076e8ab2fdf432984a2b7f2d3234a894db4040a6
Improve coverage for kprobe event_re

This makes the attachment of kprobes to arbitrary events more robust.

Issue 1: Functions with '.' characters should not have similarly named
 probes.
Issue 2: Functions in the blacklist should not be attached to.
Issue 3: Some functions matched by regex cannot actually be attached to,
 despite not being in the blacklist...possibly the blacklist is outdated?
 Instead, warn instead of error during bulk regex attach.
Issue 4: Attaching to large numbers of kprobes gets to be very slow. For
 now, leave this unresolved. For reasonably sized regexes, startup times
 may be acceptable, and shutdown times are actually the worse part. To
 speed up shutdown, one could add the following after the last
 attach_kprobe to disable auto-cleanup:
  ```
  from bcc import open_kprobes
  open_kprobes = {}
  ```
 Then, once the program is exited, one must manually
  echo "" > kprobe_events

Some numbers:
attaching to event_re='tcp_*': 2 sec startup, 15 sec shutdown
attaching to event_re='b*': 10 sec startup, 75 sec shutdown
attaching to event_re='*': unknown (>20 min) startup, unknown shutdown
The slowdowns appear to be exponential, doubtful that '*' will ever
complete.

Fixes: #199
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
src/cc/libbpf.c
src/python/bcc/__init__.py
tests/cc/test_trace4.py